2

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?

6
  • 5
    aligned is an environment. Use it as such and it will work :-)
    – campa
    Sep 5, 2017 at 13:26
  • 4
    \[\begin{aligned} &\abs{X} \end{aligned}\]
    – Zarko
    Sep 5, 2017 at 13:38
  • 1
    Plus this has nothing to do with mathtools, aligned comes from amsmath which mathtools loads. Though it is interesting why & makes \aligned fail.
    – daleif
    Sep 5, 2017 at 13:51
  • 1
    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.
    – Tohiko
    Sep 5, 2017 at 13:57
  • Would you (@campa or @Zarko) add an answer to the question? Or is there a duplicat question?
    – Bobyandbob
    Oct 18, 2017 at 15:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.