# [texhax] dual-use input/output macro

Uwe Lück uwe.lueck at web.de
Tue Oct 17 22:37:59 CEST 2006

(found this by accident again, now having definite concise answers:)

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

\def\showme#1{%
\def\toshow{#1}\@onelevel at sanitize\toshow

-- tested! \@onelevel at sanitize is from latex.ltx. --
Note that this doesn't use any external file,
it neither changes catcodes explicitly, so even works
in \footnote{...} etc. -- This is essentially from TeXbook
p. 382 top; using that \meaning produces "other"
characters only. And I have learnt this from the index
package, to which it came from Donald Arseneau.

At 21:54 17.11.05, Lars Madsen wrote:
>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.

Indeed, Peter Szabo,

CTAN: /macros/latex/contrib/examplep/[eurotex_2005_examplep.pdf]

I would estimate it "impressive" rather than "exotic" [;-) to Lars Madsen].

Cheers,
Uwe.