# Strange spacing with gathered and aligned

I often want to list a number of short equations (like the non-zero components of a tensor) under a single equation number. To do this I use combinations of the amsmath environments equation, gathered and aligned. However, for some reason, the different parts of the gathered environment are not all centered. Consider the example

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{gathered} \begin{aligned} q &= r \,, & x &= y \,, & z &= w \,, \end{aligned} \\ \begin{aligned} A a &= B b \,, & C c &= D d \,, \\ a &= b \,, & c &= d \,. \end{aligned} \end{gathered}

\end{document}


I would expect the first two lines both to be centered, but instead they come out more or less aligned at the right hand side. For a real world example consider

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{gathered} \begin{aligned} \omega_t{}^{01} = -\omega_t{}^{10} &= \sinh\rho \,, & \omega_\phi{}^{12} = -\omega_\phi{}^{21} &= -\cosh \rho \,, & \omega_\rho{}^{AB} &= 0 \,, \end{aligned} \\ \begin{aligned} \omega_{\varphi_+}{}^{35} = -\omega_{\varphi_+}{}^{53} &= 2\sin\beta_+ \cos\gamma_+ \,, & \omega_{\varphi_+}{}^{45} = -\omega_{\varphi_+}{}^{43} &= 2\sin\gamma_+ \,, \\ \omega_{\varphi_-}{}^{68} = -\omega_{\varphi_-}{}^{86} &= 2\sin\beta_- \cos\gamma_- \,, & \omega_{\varphi_-}{}^{78} = -\omega_{\varphi_-}{}^{87} &= 2\sin\gamma_- \,. \end{aligned} \end{gathered}

\end{document}


Here the first line is pushed even more to the left. It seems like there is some extra space introduced at the end of the first line, but where does this space come from?

-

for some reason, a one-line "aligned" is not properly centered. this appears to be a bug, and i am entering it as such in the amsmath bugs list.

this (unwanted) result can be easily demonstrated by two additions to your test file:

(1) replicate the (simple) example with the content of the first aligned duplicated, to give a two-line aligned;

(2) replicate the same example replacing the first aligned element by

  q = r \,, \quad
z = w \,,\\


the modified elements will be centered as expected. i haven't determined the reason that the one-line aligned element is shifted to the left. however, for the purpose of posting the problem to the bugs list, the reason isn't necessary; a demonstration is sufficient.

please consider sending reports of problems with amsmath directly to tech-support@ams.org .

-
Thank you for confirming that this is a bug, and for reporting it. – Olof Jan 2 '11 at 22:23

the first array isn't really needed here, because it has only one line to be centered and using \, before the comma is not a correct typesetting of math

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{flalign}
\arraycolsep=1.35pt\def\arraystretch{1.3}
\begin{array}{c}
q &= r \,, &  x &= y \,, & z &= w \,,
\end{array}\\
A a &= B b \,, &  C c &= D d \,, \\
a &= b \,, & c &= d \,.
\end{array}
\end{array}
\end{flalign}

\end{document}

-
I'm interested in what is the correct spacing before a comma, but I think it deserves a question on it's own. – Olof Jan 2 '11 at 22:21

I was googling a bit. I doubt it is a solution on your problem, it is just i little suggestion: Instead of equation + gathered + aligned It is sufficient tu use just gather + aligned. I suppouse that gather is standalone math environment.

\begin{gather}
\begin{aligned}
q &= r \,, &
x &= y \,, &
z &= w \,,
\end{aligned} \\
\begin{aligned}
A a &= B b \,, &
C c &= D d \,, \\
a &= b \,, &
c &= d \,.
\end{aligned}
\end{gather}


Or, may I ask why you do not simply use only equation + aligned?

-
This will give two equation numbers, but I only wanted a single number for the three lines. equation + aligned doesn't work either. The two aligned environments are just placed side by side. – Olof Feb 10 '11 at 7:53