In LaTeX3, there are some functions like \use:n and \use:nn etc. In the documentation, they will remove the braces surrounding each argument and leave the remaining tokens in the input stream. So

\use:n { some code }

results in the input stream containing

some code

What's the differences of this and simply using some code?

  • 2
    not a lot, latex2e has \@firstofone which does the same, consider \foo{xxx} where you decide later if \foo is \@firstofone or \@gobble – David Carlisle Jul 31 '17 at 13:35

As with any TeX programming, the need to absorb and re-emit tokens arises in expl3 code. There are at least two reasons we may want to do this. The first is that tokenization occurs when an argument is absorbed. Thus we might want for example to switch category code setup and read a file:

\use:n { \ExplSyntaxOff \file_input:n {#1} }

In the above, \file_input:n is a single token but within the file that is then read both _ and : are not letters.

The second common thing we need to do is to have a case where \use:n goes with some no-op or similar: we want a braced group for convenience but don't want the braces to affect the output. Thus

\if_meaning:w #1 #2
  \exp_after:wN \use_none:n
  \exp_after:wN \use:n
  { tokens-here }

will insert the tokens without any surrounding group when the test is false, and otherwise will remove them entirely.

  • 1
    Could you please explain why \file_input:n itself will not be affected by \ExplSyntaxOff? – stone-zeng Jul 31 '17 at 13:41
  • 3
    @Stone-Zeng The argument is tokenized before the tokens are expanded/executed, so \file_input:n is read as it should before \ExplSyntaxOff does its working. – egreg Jul 31 '17 at 13:43

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.