Relation spacing error using =& in aligned equations

It is a feature, and an important one: it is simple and efficient for the vast majority of cases, because quite frequently align is used for aligning successive rows at a relation symbol. With &= you are guaranteed to get the correct spacing around the = sign.

On the other hand, sometimes one can need also to "align after the equals". There are various ways to accomplish this task.

For example, if the right hand side of an equation to be aligned is too long, you can use aligned:

\begin{align}
a &= b\\
c &= \!\begin{aligned}[t]
     &axy+b\\
     &+y
     \end{aligned}
\end{align}

This is by no means a "workaround": it marks correctly what one is going to achieve (apart from a small adjustment that may indeed qualify as a small bug, but would also be there with a =& syntax).

Why did the developers of amsmath chose this instead of =&? Well, one reason is that they borrowed some ideas from the TeXbook. But, more importantly, many cases of align follow the pattern

\begin{align}
x &= <some expression> \\
  &= <a development of that expression> \\
  &= <a further development>
\end{align}

where a =& syntax would be cumbersome.

In some cases it can be handy to align differently; I've found some of them and

a = {} &

solves the spacing problem.


The technical reason is that the align environment adds an empty math object {} to the beginning of the second cell in each aligned column, but doesn't add it to the end of the first one. This is precisely so that the equals sign behaves as though it comes between two variables when you write &=. I honestly can't figure out why it doesn't add one in the first cell also; although it does occasionally change the spacing (such as when writing =&) it never seems to do so in a way that is obviously wrong.

As others have suggested, you can write ={}& when you want the equals sign to have the correct spacing.


In the align environment, it treats A & B as $A$ ${}B$. which means if you input

\begin{align*}
 A  &  B  \\
 C  &  D
\edn{align*}

What it actually outputs is a tabular with four items like

That's how align works.

As for your question, the spacing is added only when there's something after it. If nothing is after the "=", no space would be added.

I've also figured out why they do not add {} in the first cell $A{}$ ${}B$. Consider A&=-B. If add {} in both cell, the spacing between the "=" and "-" would become bigger(space is added twice). Also, "=" should be on the right-hand side, or the minus sign would be recognized as an binary operator, thus cause extra space between minus sign and B.

You can see none but the first one made the correct spacing.

enter image description here

In real life, the Relation sign is often followed by Ordinary, But to proceed with Ordinary/Binary/Operator. Thus, the author made suggestions "=" must on the right so that character after "=" could be classified (Ord/Bin/Op) correctly.

In our little example, only when the Rel is on the right can the TeX figured out the minus sign as Ordinary rather than a Binary.

As for your question, if you don't mind adjusting the spacing manually, you can use A={} & B. or you can use

A & = B \\
  &\phantom{\;=\;}C

The \; is normally added by TeX automatcally.