[texhax] dual-use input/output macro

Karl Berry karl at freefriends.org
Thu Nov 17 20:40:38 CET 2005

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 :).


More information about the texhax mailing list