I try to use these commands to print some geometrical parameters in my LaTeX source file to the terminal and the log file. However, sometimes there are problems after compilation with pdftex and it says that Process exited with error(s) in TeXstudio. Is this a problem since these commands are TeX primitives and it is really hard to fish for the output of these commands in the terminal or the log file, so is there an easier way to accomplish this task?

  • \show and \showthe share code with the error display procedures, so they “fool” the OS because when one of them is used, the error exit code is nonzero. Unfortunately, TeX only produces zero or nonzero, there's no way for setting different exit codes.
    – egreg
    Commented Dec 22, 2016 at 12:26
  • 5

3 Answers 3


\show lets you see (in the log) what the definition of a control sequence is. If it is a macro, you get the definition, for others it tells how it is defined (e.g. whether it is a counter, token list, or length, etc.) For a non-macro, \the typesets its value. And \showthe shows that value in the log file.

\newcommand{\somemacro}[2]{this has #1 and #2}


In the log file you get three shows:

> \somelength=\skip43.
l.5 \show\somelength

> 10.0pt.

l.7 \showthe\somelength

> \somemacro=\long macro:
#1#2->this has #1 and #2.
l.9 \show\somemacro

and \the\somelength prints 10.0pt in the output document.

  • By the way when I compile with it with pdftex using Texstudio it says process exited with errors when I use \show or \showthe. Why is it interpreted as an error?
    – Vesnog
    Commented Dec 22, 2016 at 10:12
  • 4
    If you run pdflatex interactively (from the command line), it will stop after each \show, so that you can examine its output. Then you have to hit ENTER to continue. Apparently TeXStudio interprets this as an error. Commented Dec 22, 2016 at 11:08
  • 3
    @Vesnog essentially \show is a user requested error with the error text showing the meaning, but it stops the tex run and allows the usual error prompts x to stop the run, h for more help etc. Commented Dec 22, 2016 at 12:34

Basically, the difference between \the and \showthe is that the former inserts its result into the current token stream, for example among other material that TeX is typesetting, while the latter displays its result on the terminal (and in the transcript file) in the form of an error message. See The \the command for a description of what these commands do.

The \show command is similar to \showthe in that it displays it results as an error message shown on the terminal, but, instead of returning the current value of some internal quantity, as \showthe does, it gives the current meaning of a token (typically a control sequence, but, as @egreg has remarked in his comment, \show works with any token). In practice, the returned information is meaningful only if this token, or control sequence, represents a macro, in which case \show displays its current definition on the terminal. When the token represent a TeX primitive, \show just informs you of this fact.

Let’s make an example that can shed some light on the difference: if you say


TeX will answer with

> \parindent=\parindent.

which is its way of saying that \parindent is a primitive command (more exactly, in this case, it is a <dimen parameter>, see The TeXbook, p. 274). On the other hand, if you ask for


TeX might answer, for example

> 20.00003pt.

displaying the current value of the \parindent parameter. And here’s an example of applying \show to a token that represents a macro: if you say


you’ll get the answer

> \mbox=\long macro:
#1->\leavevmode \hbox {#1}.

It works in the same way for macro tokens that are not control sequences: for instance,

\show ~

causes the following reply

> ~=macro:
->\nobreakspace {}.

Last example: \show applied to a token that represents a primitive command:

\show x


> the letter x.

showing that x is a primitive command that instructs TeX to add the character for the letter “x” (in the current font) to the current horizontal list.

A loose analogue of \the for the \show command is \meaning, that inserts into the current token stream (for example, into the text being typeset) essentially the same information that \show would display on the terminal.

It should also be noted that the \the operation is performed during token expansion (on the contrary, \show and \showthe are commands that are executed in TeX’s stomach), and that its result can be used for purposes quite different than typesetting, e.g., they can be used to initialize a macro. A typical idiom is


that saves the current value of \parindent for later use.

  • 2
    \show~ and \show x are useful as well: \show stops processing and displays the meaning of the following token.
    – egreg
    Commented Dec 22, 2016 at 12:23
  • @egreg: Oh, obviously! Answer updated: thanks for noting!
    – GuM
    Commented Dec 22, 2016 at 16:22

As explained in the answers to Using \show in nonstopmode causes TeXmaker to raise false alarms. Any fix?, \show and \showthe interrupt TeX just in the same way as for errors (and they cause the process to exit with nonzero code).

If you want to record the value of some parameters in the log file and the terminal, the best is to use \typeout:

    *** Vesnog message ***^^J%
    Value of \detokenize{#1}: \the#1^^J%

Full example:


    *** Vesnog message ***^^J%
    Value of \detokenize{#1}: \the#1^^J%






Output on the terminal:

*** Vesnog message ***
Value of \textwidth : 345.0pt
*** Vesnog message ***
Value of \count 0: 1
*** Vesnog message ***
Value of \value {page}: 1

Using a distinctive string makes it easier to find the information in the log file.

  • Thanks for the advice, I think using a distinctive string is essential as the message is written among a lot of information.
    – Vesnog
    Commented Dec 22, 2016 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .