2

I am trying to understand how & behaves in an aligned environment. So far I have been getting what I need by trial and error.

Consider the following MWE

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
  A =& & & B, \\
     & &+&C
\end{align*}

\begin{align*}
  A =& &B, \\
     &+&C
\end{align*}
\end{document}

I think of aligned as a table. So the first equation has 4 columns and 2 rows. For some reason, the second column introduces a lot of spacing (and is left aligned, which is not shown in this example).

In the second example, there are 3 columns on every line. However, again for some reason, the + is left-aligned while B and C are right-aligned.

Can someone explain to me what the rules are? Or point me to a place where I can find them?

Tohiko
  • 1,789
  • 2
    Alignments alternate rlrlrl... After l columns, space is autoadded (Can't recall amount). If you want to avoid space added, you can use alignat with slightly altered syntax – Steven B. Segletes Mar 19 '20 at 12:47
  • That explains a lot. Thanks! What happens when there are multiple l columns? How much space is added? (just read your edit). – Tohiko Mar 19 '20 at 12:51
  • 1
    Note that the tabstackengine package also has some aligning macros (not environments) that will allow you to customize (or eliminate) the amount of space added after l columns. As I said in earlier comment, alignat environments can be used to eliminate space added after l columns, for example, \begin{alignat*}{2} A =& &B, \\ &+&C \end{alignat*} – Steven B. Segletes Mar 19 '20 at 12:53
  • Actually, in these codes you have only 2 columns with an alignment. More generally, n alignment columns require 2n–1 ampersands: each column but the first is introduced by an ampersand, and inside that column, the alignment point is marked with another ampersand. – Bernard Mar 19 '20 at 13:17
  • your align should be A&=B\\&\quad+C (I assume you don't want a comma before +?) – David Carlisle Mar 19 '20 at 13:58
  • Have you read the description in the amsmath user guide (texdoc amsldoc)? If it isn't clear, please say why, and (if possible) suggest how it can be improved. – barbara beeton Mar 19 '20 at 18:58
  • Sort of related: https://tex.stackexchange.com/questions/159723/ – Torbjørn T. Mar 28 '20 at 08:01
  • 5
    I’m voting to close this question because explanations are provided in comments. – Marijn Sep 11 '20 at 14:48

0 Answers0