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:
- include
\usepackage{xparse}
, or - 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!
Best Answer
If you know a recent LaTeX is available then you only need to explicitly use
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 theg
argument type. Butg
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.