[tex-eplain] Verbatim text as macro parameter
Oleg Katsitadze
olegkat at gmail.com
Mon Oct 5 07:01:52 CEST 2009
Hi Helmut,
On Tue, Sep 29, 2009 at 10:06:09PM +0200, Helmut Jarausch wrote:
> E.g. I want verbatim text in enumerated list or a footnote.
Footnotes shouldn't require anything special, see example below.
> Is it possible to get verbatim text into an hbox or a token register?
Here's an example, based on Eplain's \idx at getverbatimarg:
------------------------------>%------------------------------
\input eplain
\makeatletter
\def\verbargopen{`\{}%
\def\verbargclose{`\}}%
\newtoks\verbtoks
\def\setverbtoks{%
\begingroup
\uncatcodespecials
\catcode\verbargopen=1
\catcode\verbargclose=2
\catcode`\ =10 % Swallow multiple consequent spaces.
\catcode`\^^I=10 % Just in case, to avoid dependence on
\catcode`\^^M=5 % current meanings of tabs and newlines.
\@finsetverbtoks
}
\def\@finsetverbtoks#1{%
\global\verbtoks={#1}%
\endgroup
}
\makeatother
\setverbtoks{$#%^}
{\tt \the\verbtoks}
\def\verbargopen{`\<}%
\def\verbargclose{`\>}%
\setverbtoks<$#%^{>
{\tt \the\verbtoks}
% Note that footnotes should work without any tricks.
Blah\footnote*{This is verbatim: \verbatim $#%^|endverbatim}
\bye
------------------------------%<------------------------------
If you need to rescan the verbatim argument with "normal" catcodes,
Eplain provides \scantokens. It is actually a primitive in e-TeX, but
Eplain emulates it on other engines so it's always available. See
Eplain's \idx at scanterm for some caveats.
HTH,
Oleg
More information about the tex-eplain
mailing list