[Tex/LaTex] Why does not `\shortintertext` command work if we load `nccmath` after `mathtools`

alignamsmathmath-modemathtoolsnccmath

If you load nccmath after mathtools and use \shortintertext, you will get an error message "Package amsmath Error: Invalid use of \shortintertext". If you load nccmath before mathtools, the error message disappears.

Is there any overlap between the two packages functionalities? Do they overlap when it comes to modifying the internal commands of the standard LaTeX?

\documentclass[]{book}


\usepackage[T1]{fontenc}

\usepackage{mathtools}
\usepackage{nccmath}

\begin{document}

\begin{align}
    (A + B \thinspace C) \thinspace x + C \thinspace y &= 0,
    \\
    \shortintertext{Short Intertext}
    E \thinspace x + (F + G) \thinspace y &= 23.
\end{align}

\end{document}

Best Answer

The \intertext and \shortintertext commands are only valid in certain contexts; nccmath modifies the meaning of \intertext@ (which is the internal command defined by amsmath and used also by mathtools) and eventually this conflicts with the redefinitions done by mathtools.

Solution: load nccmath before mathtools. This will remove the redefinition of \intertext done by nccmath, but it's not needed because you can use \shortintertext with similar features.

\documentclass[]{book}

\usepackage[T1]{fontenc}

\usepackage{nccmath}
\usepackage{mathtools}

\begin{document}

\begin{align}
    (A + B C) x + C y &= 0,
    \\
    \shortintertext{Short Intertext}
    E x + (F + G) y &= 23.
\end{align}

\end{document}

I removed all the \thinspace commands which are not needed and wrong anyhow: for a thin space in math mode you should use \,. But, really, it is not needed in those places.

enter image description here