[Tex/LaTex] Remove unnecessary horizontal space from amsmath align between two &

alignamsmathspacing

How do you remove unnecessary horizontal space in an amsmath align environment between two &?

Consider:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

Version 1:
\begin{align*}
a &= b = d\\ 
bb &= cc = d 
\end{align*}

Version 2:
\begin{align*}
a &= b &= d\\ 
bb &= cc &= d 
\end{align*}

\end{document}

I want all the equal signs to line up. I could do manual spacing, but thats a horrible solution.

I apologize if this a repost: I cannot find this answer anywhere.

Best Answer

you should use the alignat environment, which removes the space between the pairs of left and right hand sides. Skipping the left hand side of the second equation gives the result :

\begin{alignat*}{2}
a &= b &&= d\\ 
bb &= cc &&= d 
\end{alignat*}

See for instance this question for a more detailed explanation.