7

I have obviously missed some updated information about specifying LaTeX commands What I am used to is along the lines of

\newcommand{<command-name>}[<numargs>][<default>]{<command definition>}

and now I have seen that there is a definition like

\NewDocumentCommand \sidenote { o o +m }

which means nothing to me and which has no obvious relationship to the way I have specified new commands for the last 3 or so decades.

Where can I find out about this complete change in the command definition facilities and, possibly, why weren't there any obvious announcements about it?

I am on the comp.text.tex newgroup and I run TeXlive 2021 but am waiting for the DVD to arrive before updating to 2022.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Peter Wilson
  • 28,066

1 Answers1

8

It's newish in the format (October 2020) but has been available as the xparse package for a decade or so and some versions of this form have been available for longer than that: xparse.dtx has copyright dates going back as far as 1999.

The new code in the format is documented in texdoc source2e chapter g (ltcmd) although more convenient is the updated user guide (currently texdoc usrguide3 although we will probably merge this back with usrguidesoon)

\NewDocumentCommand \sidenote { o o +m }{...#1 ... #2 ... #3}

defines \sidenote with two optional arguments and one mandatory argument. The + here denotes a \long argument that may accept blank lines (\par) like using \newcommand rather than \newcommand* except that \NewDocumentCommand allows this to be separately specified for each argument.

So
\sidenote[a][b]{main}
which can not easily be defined using \newcommand, which only allows declaration of a single optional argument.

In general the new features of each release are described in ltnews

texdoc ltnews

shows a pdf with the full series, you want LaTeX News 32 (2020/10) which documents this.

David Carlisle
  • 757,742