These commands are part of the LaTeX3 Project xparsepackage. This question is to satisfy curiosity…

From xparse documentation released on 25 Nov 2014:

\DeclareDocumentCommand will always create the new definition, irrespective of any existing with the same name.

\NewDocumentCommand will issue an error if has already been defined.

Is this the equivalent of \def and \newcommand?

In what situation would I need this?

  • 3
    No but the equivalent of \long\def and \newcommand ;-)
    – touhami
    Jul 27, 2015 at 6:55
  • 1
    @touhami Just to clarify for future reference: \long\def being just a \def that accepts \par tokens (both explicit and implicit paragraphs) in its input... Jan 11, 2017 at 12:26

1 Answer 1


Is this the equivalent of \def and \newcommand?

Not quite: \DeclareDocumentCommand has the same syntax as \NewDocumentCommand, unlike \def with respect to \newcommand. But the documentation seems clear about it: with \DeclareDocumentCommand, there is no check that the command name you give as argument already has a definition.

Don't forget there's also \RenewDocumentCommand.

In what situation would I need this?

I know a few ones, but I usually recommend using \NewDocumentCommand. Don't use \DeclareDocumentCommand. I hope the team will also provide \NewExpandableDocumentCommand.

What's the usage of \DeclareDocumentCommand? Every time you have to do \let\foo\relax and \DeclareRobustCommand\foo{...}, then it's time to \DeclareDocumentCommand. If you don't know what I mean, then use \NewDocumentCommand and live happier.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .