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:-)
\[\begin{aligned} &\abs{X} \end{aligned}\]
mathtools
,aligned
comes fromamsmath
whichmathtools
loads. Though it is interesting why&
makes\aligned
fail.\[\aligned & X \endaligned \]
compiles. So it's the combinations ofaligned
and\DeclarePairedDelimiter
. However, using thealigned
environment as suggested by @campa and @Zarko suggested resolves this issue.