[tex-k] TeX: spurious newline after \showbox in log file

Tyge Tiessen tttex at mailbox.org
Mon Mar 6 22:15:30 CET 2023


Hi Igor,

This behavior stems from the way "print_nl" is implemented in module 62 in the
TeX code.  The function prints a string but ensures that it is printed at the
beginning of a line.  If both terminal and log file output are selected, i.e.,
if "selector" is set to "term_and_log", this function will start a new line on
both the terminal and the log file, even if only one of them is not currently
at the beginning of a new line. This can lead to a spurious new line for the
output target that was already at the beginning of a new line.

In the case of your example, if "\tracingonline" is not positive, the
"\showbox" command will only print to the log file. At the end of "\showbox",
one empty line is printed by "end_diagnostic" in module 1298, before "selector"
is reset to "term_and_log". At this point "print_err" is invoked, which calls
"print_nl" to ensure that the "error" message starts at the beginning of a new
line.  Because the terminal is not at the start of a new line at this point in
your example, a new line will be started an both the terminal and the log file,
leading to the second empty line.

If you invoke "\showbox" at this point again, the terminal will be at the
beginning of a new line so the call to "print_ln" adds no blank lines. You can
recreate the effect though by ensuring that the terminal is not at the
beginning of a new line, e.g.,

  \setbox0=\hbox{A}
  \showbox0
  \showbox0
  \message{Some text}
  \showbox0
  \end

Best,
Tyge

> Igor Liferenko <igor.liferenko at gmail.com> hat am 06.03.2023 13:48 CET geschrieben:
> 
>  
> Hi,
> 
> Run TeX on this file:
> 
>     \setbox0=\hbox{A}
>     \showbox0
>     \end
> 
> The log file is:
> 
>     .\tenrm A
> 
> 
>     ! OK.
> 
> (notice two blank lines)
> 
> I also observed that:
> 1) If we use \showbox0 second time, spurious newline does not appear
> second time.
> 2) If we use \tracingonline=1, spurious newline does not appear.
> 
> Best regards,
> Igor


More information about the tex-k mailing list.