2

I want an align* environment with two columns, to display two equality signs per line, both aligned to the corresponding equality signs in the other lines.

For example:

\begin{align*}
    a &= 1 + 2 + 3 &= 6 \\
    b &= 1 + 2     &= 3
\end{align*}

However, when I try this in LaTeX, I get the following output:

Output

I'd like to avoid the large space in front of =6 and =3. Does anybody know what is wrong with my code? I extracted the syntax from wikibooks.org. I also tried to add an additional & in the middle, but the result stays the same for me:

\begin{align*}
    a &= 1 + 2 + 3  &  &= 6 \\
    b &= 1 + 2      &  &= 3
\end{align*}

1 Answers1

1

You can use alignat* for aligning at 2 points.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \begin{alignat*}{2}
    a &= 1 + 2 + 3  &&= 6 \\
    b &= 1 + 2      &&= 3
\end{alignat*}
\end{document}

enter image description here

  • You can, if you're willing to let your document to look disasterous :D – yo' Mar 12 '15 at 14:00
  • Thank you, Harish. Just what I was looking for. Actually, I had imagined that align* is designed to work as alignat* does. @yo', what's wrong with that solution? I've introduced this method at several places in my documents and couldn't find any drawbacks. I use it for formular comments, too. – Illuminat Mar 13 '15 at 17:23
  • @Illuminat The empty space is horrible. I don't really think that by aligning the numbers, you increase the readability of the text. Unwanted space (horizontal or vertical) can only confuse people. As I said, I would typeset this as \begin{gather*} a = 1+2+3 = 6, \\ b = 1+2 = 3. \end{gather*}. Formular comments -- if you mean putting something on the right in parentheses in a series of equalities -- is what I call a "high-school style" and I don't consider it as good mathematical typography. – yo' Mar 13 '15 at 17:29