[texhax] dual-use input/output macro

Oleg Katsitadze geolsoft at mail.ru
Thu Nov 17 22:26:32 CET 2005

On Thu, Nov 17, 2005 at 01:40:38PM -0600, Karl Berry wrote:
> About all I can imagine is
> changing all the catcodes to other before reading the argument, printing
> the arg in tt, then writing the arg to an external file, and 
> reading it back with normal catcodes to get the normal output.

Wouldn't it be easier the other way around?  I mean, write
the argument to an external file through the \toks0 to avoid
expansion, read it by some kind of verbatim macro, and
typeset the result as `#1'.  As a side effect, there will be
spaces after macro names in the verbatim text, so this
approach is no good if this is critical.

This is what I mean (I use Eplain for the \listing macro):

-------------------- Cut --------------------
\input eplain




\showme{hello, \relax here}

\showme{hello, {\it there}}

\showme{\line{hello,\hrulefill everywhere}}


It's also possible to avoid writing/reading the file, if the
argument is not too complex to be processed by the
``inline'' \verbatim.  For example (\verbatim...\endverbatim
and \sanitize also come from Eplain):


Unfortunately, this approach also suffers from the spurious
spaces after macro names.

Hope this helps.

Best regards,
Oleg Katsitadze

More information about the texhax mailing list