(I'm still curious as to the right amount of spacing, though.)
–
Loop SpaceNov 7 '12 at 10:22

The missing space is \mskip\thickmuskip, the space TeX inserts between a Rel and an Ord atom. Writing ={} automatically supplies it, because any subformula (even an empty one) is considered as an Ord atom.
–
egregNov 7 '12 at 10:34

1

@egreg That looks awfully like an answer. If you feel it is a bit short, you could add (a link/reference to - is it in TeXbyTopic?) a list of the spaces that TeX inserts between the various elements.
–
Loop SpaceNov 7 '12 at 10:37

If the number is in parentheses, then the space is inserted only if the formula (or subformula) is eventually typeset in display or text style, but not in subscript/superscript styles.

Another example: the formula $(a+b)\cdot c=ac+bc$ becomes

Open Ord Bin Ord Close Bin Ord Rel Ord Ord Bin Ord Ord

A subformula is anything in braces; it is eventually treated as an Ord atom.

How does align guess the right spacing? When you type

\begin{align*}
a &= b+c
\end{align*}

LaTeX transforms this into an alignment basically with the following template:

\hfil $\displaystyle #$ & $\displaystyle {}#$ \hfil

where # represents the actual contents of the cell. So we have a first column with right alignment and the second column left aligned, but an empty subformula is always added before the actual contents. So the formula that's typeset in the right column is $\displaystyle {}=b+c$ that get read as

Ord Rel Ord Bin Ord

and the spacing is just right.

The same would happen with

\begin{align*}
a ={}& b+c \\
a=\mskip\thickmuskip & b+c
\end{align*}

Note that explicit spacing commands (or rules) do not appear in the list of atoms and are inserted along with the automatically provided spaces.

Abbreviations for \mskip\thinmuskip, \mskip\medmuskip and \mskip\thickmuskip are \,\:\; respectively; \! is an abbreviation fo \mskip-\thinmuskip (which can come handy for removing a thin space automatically added).

One can force a single symbol or subformula to be considered as one of the above atom types by feeding it as argument to

By adding an empty subformula, you let TeX do the job which it's paid for and don't need to remember that table. Well, that table can come handy in some tough situation when we end up scratching our head, asking where that damn space is coming from or doesn't show up.

Brilliant (as always)! Thanks to this I will now remember that sticking a {} in is the right thing to do because now I understand what's going on - without that remembering {} is about as easy as remembering that six times nine is forty-two.
–
Loop SpaceNov 7 '12 at 12:02

How does TeX "know" to treat the - in $-1$ as a unary rather than a binary operator -- and thus not insert \medmuskip between - and 1? Is the atom type of - maybe converted "on the fly" from mathbin to mathord?
–
MicoMay 29 at 16:40

@Mico That's the rule implemented by Knuth: the cases marked * in the table are declared “impossible” and the atom is turned into an ordinary one. Perhaps also the “start or end” of formula should also be treated, but, basically, an object in the Bin type with no left atom is turned into Ord: to be spaced as Bin, an object must have something compatible on either side. For instance, ”Rel Bin Ord“ is not possible and the Bin is turned into Ord. The same is for “nothing Bin Ord”; the same for “end of formula” (or subformula, of course): “Ord Bin nothing” is impossible.
–
egregMay 29 at 16:52