ASND@TRIUMFRG.BITNET (Donald Arseneau) (04/06/91)
David Gilbert was looking for a modified verbatim mode in LaTeX.
I hesitated to publicly show such a beast beacuse I am not convinced
that a macro which works *sometimes* (as another macro's parameter)
is really better than one that works *never*. But after modifying
what I had so I could send it to David, I thought What the hell,
someone else might want it. So...
% here is what I use in my draftcite.sty to write the citation key
% instead of its normal label. It works for all the special characters
% that can be used in such a key but not as a universal verbatim mode.
%
\def\citeverb#1{%
\expandafter \expandafter \expandafter \@gobble % do \csname, \string, ...
\expandafter \string\csname#1\endcsname} % \@gobble, in that order.
%
% Here is one that does more; I combined it with LaTeX's method of
% catcoding special characters as "other" so it will work as documented
% by the LaTeX manual, with the added feature of working in the argument
% to another command as long as there are no %'s in the verbatim text and
% any braces are balanced (like {this}). If there are \'s in the verbatim
% text, there might be some extra space inserted (\that) -> (\that ).
% it goes to some pain to fix doubled # signs.
%
\def\verb{\begingroup \tt \let\do\@makeother \dospecials % from LaTeX
\catcode`\#=6\relax % so \meaning always generates ## for #
\obeyspaces\frenchspacing % perhaps some other settings
\verb@A}
%
\def\@meaningless#1:->{\@undoublehash}%
%
{\catcode`\&=6 \@makeother # % use & for macro parameters while # is "other"
%
\gdef\verb@A&1{\def\verb@B&1&&1&1{%
\toks@={&&1}\edef\n@@t{\the\toks@}% prevents error message with #
\expandafter\@meaningless\meaning\n@@t#\@gobblethree#\endgroup}%
\verb@B&1}
\gdef\@undoublehash &1#&2#{&1%
% if ## emit #\@undoublehash
% if #\@gobble# emit nothing
% if #other# emit #other#\@undoublehash (can't happen(?))
\ifx&2\@gobblethree\@gobblethree #\expandafter\@undoublehash
\else #&2#\expandafter\@undoublehash\fi}
}
\def\@gobblethree#1#2#3{}
Donald Arseneau
asnd@reg.triumf.ca