With expl3, I can \peek_charcode:NTF. For debugging, I would like to actually see the peeked-ahead tokens for each iteration of my loop, but have not seen a suitable token variable in the documentation.

  • Maybe the documentation is not clear, but the token is available in \l_peek_token
    – egreg
    Nov 14, 2013 at 20:36

1 Answer 1


The documentation about \peek_after:Nw tells that the looked at token is available in \l_peek_token and this is how work all the following functions (which are based on \futurelet).

Probably the documentation should make this clearer.

Here's an example:

 { \tl_show:N \l_peek_token } 
 { \tl_show:N \l_peek_token \tl_show:N }  

 { \tl_show:N \l_peek_token } 
 { \tl_show:N \l_peek_token \tl_show:N }  


Here's the relevant part of the log file:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013) (format=pdflatex 2013.11.14)  14 NOV 2013 21:50
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
LaTeX2e <2011/06/27>


> \l_peek_token=the letter A.
<recently read> }

l.8 A

> A=the letter A.
<recently read> }

l.8 A

> \l_peek_token=the letter B.
<recently read> }

l.14  B

Here is how much of TeX's memory you used:
 5223 strings out of 493308
 95482 string characters out of 6137815
 131918 words of memory out of 5000000
 8695 multiletter control sequences out of 15000+600000
 3640 words of font info for 14 fonts, out of 8000000 for 9000
 957 hyphenation exceptions out of 8191
 31i,1n,33p,203b,85s stack positions out of 5000i,500n,10000p,200000b,80000s

No pages of output.
PDF statistics:
 0 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

Since I used \peek_charcode_remove:NTF only the meaning of A appears twice.

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.