# mathtools bug with aligned

The following code does not compile

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\begin{document}
\aligned &\abs{X} \endaligned
\end{document}


If I add a character before the alignment character like a & \abs{X}, the code compiles

Is this expected? Is there a better workaround?

• aligned is an environment. Use it as such and it will work :-) Sep 5, 2017 at 13:26
• \begin{aligned} &\abs{X} \end{aligned} Sep 5, 2017 at 13:38
• Plus this has nothing to do with mathtools, aligned comes from amsmath which mathtools loads. Though it is interesting why & makes \aligned fail. Sep 5, 2017 at 13:51
• The code \aligned & X \endaligned compiles. So it's the combinations of aligned and \DeclarePairedDelimiter. However, using the aligned environment as suggested by @campa and @Zarko suggested resolves this issue. Sep 5, 2017 at 13:57
• Would you (@campa or @Zarko) add an answer to the question? Or is there a duplicat question? Oct 18, 2017 at 15:45