TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to remove a token from the stream from within a command (ignoring spaces). The next token will be a { (actually, I've just thought that it might not be ... but I'll continue as if it were). In "ordinary" TeX I would end the command with \let\junk=. LaTeX3 has lots of \peek_<something>_remove_ignore_spaces:NTF commands which would do it, except that there's an unnecessary conditional there which seems like overkill.

So what's the LaTeX3 equivalent of let\junk=?

share|improve this question
I don't think there is; \cs_new_protected:Npn \stacey_remove_token_ignore_spaces: { \peek_charcode_remove_ignore_spaces:NF \scan_stop: {} } – egreg Jun 18 '13 at 12:50
IIRC, @egreg's suggestion will only remove the next token if it is a control sequence, no? There is no \let\junk= in LaTeX3, because it is quite rare that you wish to unconditionally remove whatever tokens follow, I believe. One option is always \cs_set_eq:NN \junk, but it is not very appealing. – Bruno Le Floch Jul 7 '13 at 3:48
Could you expand the context here? As Bruno says, this is quite a rare thing to need to do other than inside \peek_... type constructs. – Joseph Wright Aug 11 '13 at 19:14
@JosephWright The context is that I've just done an "If next char is X" test. I don't want to remove the token at that stage because if it isn't X then I need to keep it where it is. But if it is X then I want to ignore it and move on to the next token. – Loop Space Aug 11 '13 at 19:21

Sounds very much like you are after the 'peek and remove if true' functions, for example

\cs_new_protected:Npn \demo
    \peek_meaning_remove:NTF a
      { Nope,~an~`a' \par }
      { It's~OK~ma,~it's~only~ } 

\demo ab

\demo c
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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