# Always use \NewDocumentCommand instead of \newcommand?

Are compelling reasons to stick with \newcommand or should one always use \NewDocumentCommand instead, even when not using any of the additional features offered by xparse?

• If I already require xparse to define one of the macros of my document / package / class, is it a good idea to use \NewDocumentCommand for all my other macro definitions?

• Will \newcommand eventually get deprecated / discouraged in favor of \NewDocumentCommand with LaTeX3?

-
You should use \newcommand which will never be deprecated. \NewDocumentCommand is from the experimental LaTeX3 and more a command for package writers. –  Herbert Feb 14 '13 at 7:25
@Herbert I have to disagree here. yes \DeclareNewCommand is from the latex3 code in the version that runs on top of current LaTeX but the days that we classified all of that as experimental is long gone. These days there is a large stable part (kernel code of expl3 and some packages of which xparse is one). Also xparse is "user interface" for LaTeX2e-like syntax. –  Frank Mittelbach Feb 14 '13 at 22:17
@Frank: then you should change the description of what LaTeX3 will be ;-) –  Herbert Feb 15 '13 at 6:43

\NewDocumentCommand is part of xparse, which is 'LaTeX3-in-2e' code. The team have marked this part as 'stable', meaning that we will maintain this code for use with LaTeX2e in an ongoing sense. As such, there is no danger of \NewDocumentCommand vanishing.


Predicting the future is risky, but I think it's extremely unlikely that any stand-alone LaTeX3 format would not define \newcommand, even if the recommendation might be to use other methods. In any case, there are lots of other concepts that I suspect mean that for some arbitrary LaTeX2e document, you won't just be able to process with a stand-alone LaTeX3 format without adjustment.

-
Sorry to dredge up an old thread, but \NewDocumentCommand can create a command that takes no arguments, so this way would (presumeably) be preferred for things like \maketitle (not variables). Has there been any further discussion on this since February that can be referenced? –  Sean Allred Jun 11 '13 at 3:54
@SeanAllred I know it can, but what I mean is that 'insert a token list' can be viewed as a command with no arguments or the use of a token list variable. –  Joseph Wright Jun 11 '13 at 6:14
Ahhh, I see. I.e. what is actually stopping something like make title from being used as, say, a stack. Gotcha. –  Sean Allred Jun 11 '13 at 11:22

To expand Joseph's answer about commands and values: Macros defined with \NewDocumentCommand are robust, they don't get expanded when e.g. moved to the .toc. This is a good thing for commands like \cite which should do something in the .toc but in general is not wanted for values which can change in a document and where you want to transport the current content to the .toc and not only the name of the command. As an example:

\documentclass{article}
\usepackage{xparse}

\begin{document}
\NewDocumentCommand\testA{}{ABC}
\newcommand\testB{ABC}

\tableofcontents

\RenewDocumentCommand\testA{}{CDE}
\renewcommand\testB{CDE}

\section{\testA, \testB}

\end{document}

-
As I understand it \NewDocumentCommand and its associates are still classed as 'experimental' which means when you use them, there is a chance that they will break or even that later versions will change their syntax. So, if you want your tex file to last until LaTeX3 comes out, I would stick with \newcommand. However, some things are just easier to do with xparse and if you're not too bothered about having to change your tex file to reflect some change in the package, using xparse seems the way to go.
And yes, I'm pretty sure one day we'll all be using \NewDocumentCommand (Just think how \def is discouraged in favour of \newcommand now).