Preserve spacing while using align with amsmath

While

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
&   A \\
& = B
\end{align}
\end{document}


preserves the horizontal space after the equals sign,

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
& A \\
= & B
\end{align}
\end{document}


gobbles this. Is there a way to preserve the space? (OK, in the MWE alignment could be placed behind A and B, but it is just a minimal example.) If it is not: How wide is the space (as to use \hspace{ something })?

-
Your two fragments are identical. did you post the wrong thing? (Also the & should be before the = in AMS alignments) –  David Carlisle Oct 12 '12 at 12:42
@DavidCarlisle: Yes, my mistake, I just corrected it. –  Stephen Oct 12 '12 at 13:53

in order to be able to add the correct space, (la)tex needs to know exactly what precedes and follows the equals sign. in this case, the & is "hiding" the letter that follows, so the space added is the default -- none.

in most cases, signs of relation are preceded and followed by "ordinary" characters (like letters). you can emulate this situation in your example by adding an empty group -- {} before and/or after the equals sign:

{} = {} & B


this is actually overkill; only the group after the equals sign is needed, but the extra group doesn't hurt, and may make the intention more clear to a reader of the input.

if you are aligning on a character of some other class, the "correct" spacing is shown in a little table in the texbook, p.170.

-
+1 and accepted, thanks! –  Stephen Oct 12 '12 at 14:02

The AMS alignments are designed so that you use the & before not after the alignment operator, If you really can't do that for some reason using {}={} rather than = will ensure the equals sign gets the infix relation spacing.

-
OK, upvoted your answer (as well as BB's one), but because I do not know which one was given first (both labelled as "answered 1 hour ago"), and BB's answer is a little bit more extensive, I just accepted her answer. (With >50k reputation I hope this is no problem for you, but I just had to decide for one answer, sorry!) –  Stephen Oct 12 '12 at 13:58
Mine was first by a second or two but I've known @barbara a long time and they are effectively her packages to look after so I don't begrudge her the green tick:-) –  David Carlisle Oct 12 '12 at 14:24
@Stephen OT: If you hover over "3 hours ago" you see the exact timestamp (in UTC). –  Qrrbrbirlbel Oct 12 '12 at 16:21