[Tex/LaTex] Relation spacing error using =& in aligned equations

amsmathmath-moderelation-symbolsspacing

The middle equation in the following example seems to have wrong spacing around the = sign. The only difference is that I used =& for aligning around the = sign rather than &=.

This worries me, because sometimes I want to emulate "multline equations", and I want the equations to be aligned like that but without putting an = sign at all.

Is it known, explainable behaviour? I.e., is it a bug or a feature?

\documentclass{minimal}
\usepackage{amsmath}
\begin{document}
\[
 a=b
\]
 \begin{align*}
  a =& b\\
  c =& d
 \end{align*}
 \begin{align*}
  a &= b\\
  c &= d
 \end{align*}
\end{document}

output

Best Answer

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.