[Tex/LaTex] Strange spacing with gathered and aligned

amsmath

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{equation}
  \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{equation}

\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{equation}
  \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{equation}

\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?

Best Answer

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
  x = y \,, \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 .