[Tex/LaTex] the difference between \write16 and \message

tex-core

\write16 sends to terminal, \message also does this. Why there are two commands for this and in which cases each one must be used?

Best Answer

Here's in D. Knuth's words

An ‘\immediate\write16’ differs from \message in that \write prints the text on a line by itself; the results of several \message commands might appear on the same line, separated by spaces.

Sample.tex

First page
\write16{** one **}  \message{** two **}

\vfill\eject
Second page
\immediate\write16{** one W **}\immediate\write16{** two W **} 
\message{** one M **}\message{** two M **}
\bye

sample.log shows

(sample.tex ** two ** [1{[....]/texmfs/data/pdftex/config/pdftex.map}
** one **
]
** one W **
** two W **
** one M ** ** two M ** [2] )