The command \typeout{argument} expands its argument and writes the result to the log and the terminal. Writing l3build tests, I sought for an equivalent command in LaTeX3, but only found \iow_log:x and \iow_term:x which it essentially is a combination of.

How does \typeout translate to LaTeX3?

  • The accepted answer is correct, but I've always found \msg_term:n and the \*_show:N family of functions to be more useful in practice. – Sean Allred Sep 23 '15 at 12:54
  • @SeanAllred I already knew of the \msg_ family of commands, but actually wanted something without that much decoration. Thanks for the note though, as other people stumbling onto this question may need exactly that. – XZS Sep 23 '15 at 12:57
  • @SeanAllred The question was about \typeout, which in an expl3 context is 'lower level' :-) – Joseph Wright Sep 23 '15 at 14:55

In cases where the 'built-in' x-type expansion of primitives is useful, such as \(pdf)strcmp, the team provide \<name>_x:n wrappers. That applies if the underlying primitive is expandable. In the case of \typeout, there is no expandable implementation and so this is not necessary. For these cases, a normal x-type variant of an n-type function is set up. In this case, \iow_term:x is the correct choice: this writes to the terminal and to the log and does x-type expansion. (Anything in the terminal output is in the log, but the converse is not true.)

\iow_term:x { \foo }

Note that \typeout works with the LaTeX2e robust mechanism (setting the behaviour of \protect) which a LaTeX3 x-type expansion does not do. Thus if you are dealing with mixed material and it might contain robust commands you should use \typeout.

| improve this answer | |
  • 2
    Not everything in the terminal output is also in the log. The important exception is the output of \write18. The log only contains, if the command was executed. The output of the command is in the terminal only. – Heiko Oberdiek Sep 23 '15 at 11:38
  • 1
    @HeikoOberdiek OK, fair enough but that's outside of the control of \write-1 ;-) – Joseph Wright Sep 23 '15 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.