5

The xparse documentation gives examples of names of \NewDocumentCommands enclosed in braces, and without braces, as demonstrated in the two commands below. Is there any difference in functionality whatsoever between the two? I never use braces and better be safe than sorry.

\documentclass{article}
%=======================
\usepackage{xparse}
%-----------------------
\ExplSyntaxOn
\NewDocumentCommand\myExp{m}{#1}
\NewDocumentCommand{\myExpAlt}{m}{#1}
\ExplSyntaxOff
%-----------------------
\begin{document}
  \myExp{101}

  \myExpAlt{123}
\end{document}
  • 3
    In your example, there is no need for \ExplSyntaxOn...\ExplSyntaxOff. – Werner Dec 10 '18 at 7:34
  • Agreed, they are part of my MWE template as is \usepackage[...]{expl3} and I failed to remove them. – Reinhard Neuwirth Dec 10 '18 at 9:44
5

There is no difference, similar to the notation used with \newcommand and friends, as long as you pass it a control sequence. Technically you're passing an argument to \newcommand, which is then set using \def internally, so you should use {<csname>}. However, if you don't use braces, the first token is grabbed.

  • Reassuring that there is no harm in not using braces, but formal correctness would dictate to use {<csname>}. – Reinhard Neuwirth Dec 10 '18 at 8:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.