[texhax] dual-use input/output macro
Lars Madsen
daleif at imf.au.dk
Thu Nov 17 21:54:00 CET 2005
Karl Berry :
> Suppose I want to show both the TeX input and its corresponding output
> as an example. Not big files, but just small fragments. As in:
>
> \showme{hello, \relax there}
>
> and the typeset output could be, say, two lines:
>
> hello, \relax there % in typewriter
> hello, there % in roman
>
> I cannot think of any easy way to do this. 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.
>
> Is there a simpler way? Has anyone programmed the above? I imagine
> e-tex's \scantokens and \readfile (or something else?) might be useful,
> but didn't see a quick application.
>
> I browsed through the fancyvrb, verbatim, etc., doc but nothing jumped
> out at me.
>
> Just wondering :).
>
> k
>
There is of course the way lshort does it, i.e. write the argument to an
external file, do a verbatim input and a normal input. I use the same
thing for internal examples i my LaTeX book.
But there should be a rather exotic package by Peter Sabo (if it's spelled
like that), I've forgotten the name, but he gave a talk about it at
EuroTeX 2005.
/daleif
More information about the texhax
mailing list