2

I feel that I very often write

\begin{equation}
    \begin{aligned}
        a+b&=c\\
        y&=x^2+c
    \end{aligned}
\end{equation}

in order to align equations that I wish to group. My problem with the "align" environment is that each equation will get its own number as opposed to the above method where both of these equations are assigned one collective number.

Is there a more universally accepted way to go about this or a more "right" way to typeset these equations? It low-key feels like something that isn't necessarily meant to be so typical but maybe that's just my perception.

2
  • you are using aligned without specifying any alignment point (&) which is a bit strange, probably better would be to use &= if you want aligment or use gathered rather than aligned if there is no alignment. Otherwise what you show is the intended usage. Dec 12, 2019 at 14:26
  • Oh sorry I think I was a little too hasty when I drafted the example. Thanks for pointing that out. Dec 13, 2019 at 13:33

1 Answer 1

5

Since you use this a lot, that is a good sign for creating a new environment, say numalign, that will do that automatically for you.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}

\newenvironment{numalign}
{\begin{equation}\begin{aligned}}
{\end{aligned}\end{equation}}

\begin{numalign}
    a + b &= c \\
    y &= x^2 + c
\end{numalign}

\end{document}

enter image description here

2
  • Thank you, this is more or less what I was looking for. I had tried creating a custom command but I thought the syntax for calling it was slightly clunky but this is more or less perfect. Dec 13, 2019 at 13:35
  • Personally I'd write something like \newenvironment{numalign}{\equation\def\@currenvir{numalign}\aligned}{\endaligned\endequation}. In this way if you misspell the argument of \end{numalign} the error message will be slightly less cryptic. But +1 anyway :-)
    – campa
    Dec 13, 2019 at 13:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.