[Tex/LaTex] Difference between \the, \showthe and \show commands

tex-core

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?

Best Answer

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

\documentclass{article}
\begin{document}
\newlength\somelength
\somelength=10pt
\show\somelength
\the\somelength
\showthe\somelength
\newcommand{\somemacro}[2]{this has #1 and #2}
\show\somemacro

\end{document}

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.