TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing some macros for general debugging purposes (See Yiannis' question). I am basically expanding a given input step by step, and printing the result to the terminal and log. In order for this to happen step by step, I am using \show, which interrupts TeX and gives the user the opportunity to follow what is going on.

However, \show is quite verbose: at least six lines, most of which are useless. Can this number be reduced? (I don't mind dropping \show for a better alternative.)


\errorcontextlines=-1\relax % attempt to have less lines
\def\deep{A \deeper macro}

writes the following to the terminal:

> \deepest=undefined.
\deeper ->\show \deepest 
l.6     \deep

share|improve this question
Is stopping the TeX run a key part of the question here, of is the main concern writing to the log? (For example would it be acceptable to write several lines to the log and only interrupt the run once?) – Joseph Wright Feb 1 '11 at 20:04
@Joseph: the best would be to stop TeX, but not write anything else than the prompt "?" to the terminal. I don't care much about the log: it can be post-processed later if we need to extract information. – Bruno Le Floch Feb 1 '11 at 20:09
up vote 13 down vote accepted

You can define your own \show using \message and \meaning. You can stop the compilation by reading some dummy input:

    {\read-1 to \dummy}%


\def\example{Example macro}

Results in:

\example=macro:->Example macro

See The TeXBook in Chapter 20: "Definitions (also called Macros)" on page 217 for more details.

share|improve this answer
thanks, \read0 to is exactly what I needed! (I already take care of finding the meaning etc., and outputting it using the hardwrap package) And \read also allows to take user input in a much cleaner way than \show (e.g., no need for I at the start). – Bruno Le Floch Feb 1 '11 at 20:19
Please note that I edited to \read-1 to suppress the prompt. I just had to look \read up in the TeXBook again to check how to do it. – Martin Scharrer Feb 1 '11 at 20:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.