If you want to display macro and register contents in the terminal and the log, then the two primitives you want are \show
and \showthe
. Macros are displayed using \show
:
\def\foo{some tokens}
\show\foo
leads to
> \foo=macro:
->some tokens.
l.5 \show\foo
for example. If you try \show
with a register it's not so helpful, with for example
\newcount\foo
\show\foo
giving
> \foo=\count201.
l.5 \show\foo
This is where \showthe
comes in, as with
\newcount\foo
\foo 10\relax
\showthe\foo
you get
> 10.
l.7 \showthe\foo
The same applies to other register types (toks, dimens, skips).
\message
writes the terminal and the log without interrupting the run and with expansion. So
\def\foo{bar}
\message{Hello world \foo}
writes
Hello world bar
to the terminal bu tdoes not stop the run. If you want to write the content of a register via \message
you need to include \the
:
\newtoks\foo
\foo{bar}
\message{Hello world \the\foo}
once again outputs
Hello world bar
Another useful primitive in this context is e-TeX's \showtokens
, which can be used to show arbitrary tokens in the terminal and so is useful for constructing 'interactive' messages without issuing an error. The latter is carried out using \errmessage
, which takes a little setting up if you want 'pretty printing' (see for example how this is handled by LaTeX2e in latex.ltx
).