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=?

  • 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, 2013 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. Jul 7, 2013 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, 2013 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. Aug 11, 2013 at 19:21

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .