Next: , Previous: , Up: \write   [Contents][Index]

#### 27.5.2 \message

Synopsis:

\message{string}

Write string to the log file and the terminal.

Typically, LaTeX authors use \typeout (see \typeout). It allows you to use \protect on any fragile commands in string (see \protect). But \typeout always inserts a newline at the end of string while \message does not, so the latter can be useful.

With this example document body.

before\message{One Two}\message{Three}\message{Four^^JI}
\message{declare a thumb war.}After

under some circumstances (see below) LaTeX writes the following to both the terminal and the log file.

One Two Three Four
I declare a thumb war.

The ^^J produces a newline. Also, in the output document, between ‘before’ and ‘After’ will be a single space (from the end of line following ‘I}’).

While \message allows you more control over formatting, a gotcha is that LaTeX may mess up that formatting because it inserts line breaks depending on what it has already written. Contrast this document body, where the ‘Two’ has moved, to the one given above.

before\message{One}\message{Two Three}\message{Four^^JI}
\message{declare a thumb war.}After

This can happen: when LaTeX is outputting the messages to the terminal, now the message with ‘One’ is shorter and it fits at the end of the output terminal line, and so LaTeX breaks the line between it and the ‘Two Three’. That line break appears also in the log file. This line break insertion can depend on, for instance, the length of the full path names of included files. So producing finely-formatted lines in a way that is portable is hard, likely requiring starting your message at the beginning of a line.