1

If an "end-user" is preparing documents with LaTeX and using the current version of LaTeX(as of now, LaTeX2e <2021-06-01> patch level 1), which automatically loads L3 programming layer <2021-10-12>, and if the user is writing and applying macros that use \NewDocumentCommand, etc., is there any reason to either:

  1. include \usepackage{xparse}, or
  2. use \ExplSyntaxOn ?

As, for example, in the following source derived from https://tex.stackexchange.com/a/393188/13492:

\documentclass{article}

\NewDocumentCommand\test{o}{\IfNoValueTF{#1}{test}{#1}}
\begin{document}
\test[hello], and \test[hello]{\ world!}
\end{document}

I am aware, of course, of discussions such as those in What do ExplSyntaxOn and ExplSyntaxOff do?, but I am asking a practical question from a document writer's point of view, not from the point of view of a package author or LaTeX developer!

3
  • 3
    xparse was included in the kernel release of 2020-10-01, I think. And you only need to enable \ExplSyntaxOn (and then Off) in your document if you are including expl3 code in it (meaning, directly, not inside a package).
    – gusbrs
    Commented Oct 15, 2021 at 1:22
  • 4
    In one sense, you need \ExplSyntaxOn if you're trying to write some macro that needs expl syntax. So I think the answer ends up being, "it depends on what you're wanting to do in your document".
    – Teepeemm
    Commented Oct 15, 2021 at 1:47
  • 1. No. 2. Only if the document author needs to write expl3 code. The \ExplSyntaxOn, \ExplSyntaxOff switches handle changing the category codes of _, spaces, etc, which otherwise would be treated as math mode commands, glue, etc.
    – Cicada
    Commented Oct 15, 2021 at 8:18

1 Answer 1

5

If you know a recent LaTeX is available then you only need to explicitly use

\usepackage{xparse}

If you want to use one of the features that were trialled in the xparse package but were not included in the final version (ltcmd) that was incorpoated into the format. Notably the g argument type. But g is evil so hopefully you won't need that.

\ExplSyntaxOn is like \makeatletter, it was never needed to access commands such as the \IfNoValueTF that you show, but just as \makeatletter allows occasional access to commands with @ in their name (which would be better in package code rather than the document), \ExplSyntaxOn allows access to commands with _ and : in their names (and some control over white space) again to access code that would probably be better in a package but can be placed in the preamble if needed.

You must log in to answer this question.

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