TeX - LaTeX Asked by A.Ellett on March 9, 2021
When I’m writing my own private style packages, such as when developing them, I find it useful to use typeout
to help me see what I’ve currently created or figure out what line of code is the source of the issues (particularly when a mysterious error message is getting thrown).
Currently, I’m refractoring some old expl3
code I created back when I understood very little expl3
. Throughout that code I’ve got things like typeout
and a judicious sprinkling of space
thrown in there to make terminal output simple and easy to read. I’ve come to actually like this terminal output because it helps me debug things, but I can’t find anything expl3
equivalents of typeout
. The best I can find is msg_warning:...
which throws too much to the terminal.
Similarly, I like that I can concatenate space
to create larger white space on the terminal screen. Concatenating ~
doesn’t work.
A third macro I’ve come to really appreciate when debugging and outputting to terminal is detokenize
.
It would seem that when write expl3
, I should stick with expl3
macros and such. Does anyone have any suggestions about writing expl3
equivalents for:
typeout{....}
detokenize{....}
space
You want iow_term:n
that expands macros in the usual way.
RequirePackage{expl3}
ExplSyntaxOn
iow_term:n {Hi,~Andrew,~how~are~you?~This~message~will~automatically~
wrap~when~reaching~a~predefinedc_space_tl limit. \ \
You~can~force~a~break~and~use~exp_not:N tl_to_str:n
for~showing~tl_to_str:n{whatever~you~want}}
This will output
*************************************************
* Hi, Andrew, how are you? This message will automatically wrap when
* reaching a predefined limit.
*
* You can force a break and use tl_to_str:n for showing whatever you want
*************************************************
So iow_term:n
is the analog of typeout
, while tl_to_str:n
is detokenize
; a space is c_space_tl
, which is exactly the same as space
.
There's also iow_log:n
for writing to the log file only.
Correct answer by egreg on March 9, 2021
The first answer is no longer accurate, no more stars and the expansion policy has changed. One must adapt to use either iow_term:n
or iow_term:x
, the former expands nothing while the latter expands... what is expandable.
Here is an example with various settings to illustrate how to expand some macros, or not.
documentclass{minimal}
ExplSyntaxOn
tl_set:Nn l_tmpa_tl { 2 + 2 }
int_set:Nn l_tmpa_int { l_tmpa_tl }
iow_term:n{****~iow_term:n :~l_tmpa_tl~=~l_tmpa_int}
iow_term:x{****~iow_term:x :~l_tmpa_tl~c_space_tl=~l_tmpa_int}
iow_term:x{****~iow_term:x :~l_tmpa_tl~c_space_tl=~int_use:Nl_tmpa_int}
iow_term:x{****~iow_term:x :~exp_not:N l_tmpa_tl~=~int_use:Nl_tmpa_int}
ExplSyntaxOff
begin{document}
end{document}
The terminal output reads
**** iow_term:n : l_tmpa_tl = l_tmpa_int
**** iow_term:x : 2+2 = l_tmpa_int
**** iow_term:x : 2+2 = 4
**** iow_term:x : l_tmpa_tl = 4
The c_space_tl
was sometimes necessary to insert a space before the =
.
Answered by Jérôme LAURENS on March 9, 2021
grep
is your friend:
l3kernel/l3tl.dtx:cs_new_eq:NN tl_to_str:n etex_detokenize:D
l3kernel/l3tl.dtx:tl_const:Nn c_space_tl { ~ }
for messages if you don't like the msg
functions, probably typeout
is still your friend.
Answered by David Carlisle on March 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP