Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Hi @Olof, if you are interested at the end of the week, our new higher-level physics site outside the SE network with the intention to some kind of revive the closed Theoretical Physics SE with a slightly broadend scope and lowered bar to ask questions (graduate-level upward) will go online. The content of the former theoretical physics site is successfully imported into the new site, called PhysicsOverflow. You can access it and see what we are doing here. In case of technical problems you can mail to admin@physicsoverflow.org –  Dilaton Apr 2 at 18:10
add comment

3 Answers

up vote 9 down vote accepted

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 .

share|improve this answer
    
Thank you for confirming that this is a bug, and for reporting it. –  Olof Jan 2 '11 at 22:23
add comment

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?

share|improve this answer
    
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
add comment

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}
    \begin{array}{@{}rl@{\quad}rl@{\quad}rl@{}}
      q &= r \,, &  x &= y \,, & z &= w \,,  
    \end{array}\\
    \begin{array}{@{}rl@{\quad}rl@{}}
      A a &= B b \,, &  C c &= D d \,, \\
      a &= b \,, & c &= d \,.
    \end{array}
  \end{array}
\end{flalign}

\end{document}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.