showstream

Martin Münch Martin.Muench at Uni-Bonn.de
Mon May 8 14:54:50 CEST 2023


When compiling the code

     \documentclass{minimal}
     \newwrite\teststream
     \immediate\openout\teststream="teststream"
     %\showstream=\teststream
     \def\example{\message{This}\message{is}\message{a}\message{test.}}
     \show\example
     \AddToHook{begindocument}[foobar]{\message{Hi!}}
     \ShowHook{begindocument}
     \begin{document}
     \end{document}

the log-file contains:

     > \example=macro:
     ->\message {This}\message {is}\message {a}\message {test.}.
     l.6 \show\example

     ?

     -> The hook 'begindocument':
     > Code chunks:
     >     foobar -> \message {Hi!}
     > Document-level (top-level) code (executed last):
     >     ---
     > Extra code for next invocation:
     >     ---
     > Rules:
     >     ---
     > Execution order:
     >     foobar.
     <recently read> }

     l.8 \ShowHook{begindocument}

     ?

and the `teststream.tex` file is empty.

When the `%` before `\showstream=\teststream` is removed and the code is 
compiled, in the log-file (and on screen) it is

     -> The hook 'begindocument':
     > Code chunks:
     >     foobar -> \message {Hi!}
     > Document-level (top-level) code (executed last):
     >     ---
     > Extra code for next invocation:
     >     ---
     > Rules:
     >     ---
     > Execution order:

and the `teststream.tex` contains:

     > \example=macro:
     ->\message {This}\message {is}\message {a}\message {test.}

     >     foobar

i.e. the output from `\show` is moved from log and screen to 
`teststream.tex` (as expected), but `\ShowHook` only removes

     >     foobar.
     <recently read> }

     l.8 \ShowHook{begindocument}

     ?
from screen and log and except `>     foobar` neither writes it into 
`teststream.tex`.

My expectation was: Either
- showstream also working for `\ShowHook`: Everything from `\ShowHook` 
is removed from screen and log and printed in `teststream.tex`
or
- showstream not working for `\ShowHook`: Nothing from `\ShowHook` is 
removed from screen and log and printed in `teststream.tex`.

Is my expectation wrong or is the behaviour of `showstream` strange?


More information about the texhax mailing list.