[Tex/LaTex] Align two inequalities

equationshorizontal alignmentmath-mode

I am trying to align two inequlities vertically. The \le signs should have the same horizontal positions and the term in the should be centered. My first attempt:

\begin{align*}
\sum a &\le \sum b &\le \sum c \\
\log \sum a &\le \log \sum b &\le \log \sum c
\end{align*}

Doesn't work. My second attempt:

\[
\begin{array}{rcccl}
\sum a &\le& \sum b &\le& \sum c \\
\log \sum a &\le& \log \sum b &\le& \log \sum c
\end{array}
\]

The alignment is good, but the sum signs are smaller than in the align environment.

What is the "best" way to do this LaTeX?

Best Answer

alignat is your friend:

\begin{alignat*}{2}
\sum a &\le &\sum b &\le \sum c \\
\log \sum a &\le{} &\log \sum b &\le \log \sum c
\end{alignat*}

produces:

alt text

I needed to add two extra alignment characters between the columns, and a {} to make the \le a binary operator. The number of &'s should be 2n-1 where n is the argument given (2 in the case above).


Although now that I read the question again I realize I didn't answer it. It seems that you want the \sum term to be centered...

The only way I can think of doing it is a bit ugly:

\newlength{\yuckkyhack}
\settowidth{\yuckkyhack}{$\displaystyle\log \sum b$}
\begin{alignat*}{2}
\sum a &{}\le{} &\makebox[\yuckkyhack]{$\displaystyle\sum b$} {}&\le \sum c \\
\log \sum a &\le{} &\log \sum b &\le \log \sum c
\end{alignat*}

which gives the desired result (I think):

alt text

but requires manual selection of the largest bit of text, and use of a length...any ideas for improvement?

Related Question