# Command \nr already defined (datetime2 and nccmath incompatibility)

It seems that the datetime2 and the nccmath packages are incompatible when I load the [useregional] option in the first (I get command \nr already defined).

I used a solution for reducing spacing around my equations that needed the latter, and I suppose I could find another one just as easily (even though maybe not as convenient), but maybe someone here could find a way to fix this.

MWE:

\documentclass{article}

\usepackage[useregional]{datetime2}
\usepackage{nccmath}
\usepackage{lipsum}

\title{Example}
\author{Isabella B.}

\begin{document}
\maketitle

\lipsum[1]

\useshortskip

$2\times2=4$

\lipsum[1]
\end{document}


The nccmath \useshortskip command still works, but maybe some other functionality is being compromised.

With \useshortskip:

Without \useshortskip:

• Change the order of packages loading: first nccmath than datetime2 Oct 19, 2019 at 13:50
• The update to datetime2, v1.5.4 dated 2019/10/21 solves the issue. See dickimaw-books.com/bugtracker.php?action=view&key=137 Oct 23, 2019 at 9:03


\lipsum[1]
\end{document}

• The usage of \nr stems from examples in the manual of xkeyval (see page 6); it's wrong: a scratch macro used by a package should always have @ in its name. On the other hand, I have no clue as to why nccmath chose the name \nr for \\[0.5ex]. Oct 19, 2019 at 17:16
• I filed a bug report. By the way, also \val should be changed in, say, \DTM@val Oct 19, 2019 at 17:33
• @egreg Thank you for your comments. Now I understand why these macro names were used. I am going fix \val in my answer. Oct 19, 2019 at 18:31
• It turns out that the optional argument to \define@choicekey should consist of two tokens that are used as scratch macros. Neither \val nor \nr appear in the package code; when checking with \tracingmacros=1, I found that the code does \def\val{...}, where \val is absorbed as the first argument to a macro, the second argument, in the example case is \nr that receives various integer values according to the number of items in the following argument. Oct 19, 2019 at 22:18
• @egreg Oh, I think I get it. For example, \val would be text, and then \nr would be 1 (which is then used in the \ifcase). So the name of these two macros don't really matter as long as they are the same as in the code of the option... After your comment I tried to understand the code in xkeyval but I got lost after the 7th or 8th variation of \XKV@d@f@ne@ch@ic@k@y XD Oct 19, 2019 at 22:35

You can load packages in this order, neutralising the \nr command from nccmath:

\usepackage{nccmath}%
\let\nr\relax%
\usepackage[useregional]{datetime2}


You can replace the nccmath \nr either with what it's for: \\[0.5ex], or use the linespread environment from mathtools (needless to load amsmath in this case).

• That's what @Zarko said in the comment and I in my answer. Perhaps \let\NCnr\nr\let\nr\relax to preserve the \nr command somewhere... Oct 19, 2019 at 14:06
• Excellent suggestion! Oct 19, 2019 at 14:15