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*}
3
  • You can't align one set of equations in two different places. Just use gather*, remove all & and it'll be ok.
    – yo'
    Mar 12 '15 at 13:59
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
    – user11232
    Mar 12 '15 at 14:21
  • relevant: Aligning multiple binary operators Mar 12 '15 at 14:42
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

3
  • 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

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.