I have a quite specific question and I haven't found it in the documentation
of xparse or in the forum. In the documentation of xparse, page 3, there
are three examples:
\NewDocumentCommand{\foo}{o}{#1}
\NewDocumentCommand{\foobar}{o}{#1}
\NewDocumentCommand{\foobaz}{o}{#1}
in which {\foo}, {\foobar} and {\foobaz} are written in braces {...}.
Later, on page 4, there are other examples, but, now they are not in the braces {...}:
\NewDocumentCommand \foo { m o m } { ... }
\NewDocumentCommand \foobar { m o } { ... }
\NewDocumentCommand \foobar { m !o } { ... }
And this is where my question comes in. When is it necessary to put the
name of the command between the {braces}?
\NewDocumentCommandis a single token, TeX will treat either the same way. Personally, I prefer the unbraced version, as it looks (to me, of course) better and less likely that someone will try to define\NewDocumentCommand{\foo123}when the braces aren't there, as it happens quite often for\newcommand... – Phelype Oleinik Dec 26 '19 at 12:58\newcommand,\def, etc ... this examples are a little unfortunate at this point :( – Pablo González L Dec 26 '19 at 13:13\newcommandyes but not\defthat can not have braces around the command name. – David Carlisle Dec 26 '19 at 13:20\def.\def{\foo}{...}will raise an error because it's a TeX primitive.\newcommand(and family) and\NewDocumentCommand(and family) will grab the command name as argument and eventually pass it unbraced to the underlying\def. On the other hand,\def\foo123{...}will work. The examples mix styles (they probably shoudn't), so you get misleading examples. – Phelype Oleinik Dec 26 '19 at 13:21