TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

In addition and more specifically,

  • 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?

share|improve this question
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
up vote 19 down vote accepted

\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.

Conceptually, \NewDocumentCommand is intended for 'package authors' to define commands, while \newcommand is rather more fluid as it is also used to create variables (macros used as storage). This makes \newcommand a better choice if what you are defining is a variable: we do not have a 'document level' LaTeX3 command for this concept at present. So the decision will depend to some extent on how you see the macros you are defining (commands with no arguments and variables are pretty hard to distinguish!).

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.

share|improve this answer
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:





\section{\testA, \testB}

share|improve this answer

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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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