W3cubDocs

/LaTeX

\typeout

Synopsis:

\typeout{msg}

Print msg on the terminal and in the log file.

This

\newcommand{\student}{John Dee}
\typeout{Recommendation for \student .}

outputs ‘Recommendation for John Dee’. Like what happens here with \student, commands that are defined with \newcommand or \renewcommand (among others) are replaced by their definitions before being printed.

LaTeX’s usual rules for treating multiple spaces as a single space and ignoring spaces after a command name apply to msg. As above, use the command \space to get a single space, independent of surrounding spaces. Use ^^J to get a newline. Get a percent character with \csname @percentchar\endcsname.

This command can be useful for simple debugging, as here:

\newlength{\jhlength}
\setlength{\jhlength}{5pt}
\typeout{The length is \the\jhlength.}

produces on the command line ‘The length is 5.0pt’.

© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/_005ctypeout.html