[Tex/LaTex] What changed related to \ne in TeXLive 2019

amsmathmacrosmath-modetexlive-2019

Did something change related to \ne recenetly?

The MWE below in TeXLive 2018 yields the expected output

enter image description here

but with TeXLive 2019 (with all packages up to date as of today) I get

Argument of \ne  has an extra }.

Code

\documentclass{article}
\usepackage{mathtools}
\usepackage{xparse}

\let\OldNe\ne

\RenewDocumentCommand{\ne}{o}{%
    \mathrel{\OldNe}
}

\begin{document}
$a \ne b$
\end{document}

Best Answer

With the last LaTeX release (October 2019) a lot of commands which are not usually supposed to expand were made robust, so \ne, which usually was \not=, now expands to \protect\ne␣ (\ne␣ is \csname ne \endcsname).

With \let\OldNe\ne, when your command does \mathrel{\OldNe}, \OldNe expands to \protect\ne␣, and now \ne␣ is a macro delimited by a ], but a } is found before that, so TeX raises the Argument of \ne has an extra } (note the extra space in the error message).


Usually, this would have worked, because \ne␣ would expand to \not=. However, xparse uses the command \ne␣ as a temporary macro to grab the arguments of \ne so that in case you forget a } somewhere, the error message will show you something meaningful:

Runaway argument?
[oops 
! Paragraph ended before \ne  was complete.
<to be read again> 
                   \par

(see that the error occurred while grabbing the argument of \ne␣) rather than expose some xparse internal that doesn't give a clue about the source of the error:

Runaway argument?
[oops 
! Paragraph ended before \__xparse_grab_delimited_argument_of_some_macro:w was complete.
<to be read again> 
                   \par

To work around the issue, for the time being, load the letltxmacro and use \LetLtxMacro\OldNe\ne instead of \let\OldNe\ne. \LetLtxMacro takes care of the fact that \ne is now protected. The 2020-10-01 release, the LaTeX kernel will feature a brand new \NewCommandCopy, which can be used the same way as \LetLtxMacro to copy commands without worrying about their definition.