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.

Objective

I want to align the following:

expr_a1 <= expr_a2 <= expr_a3 \\
expr_b2 <= expr_b2 <= expr_b3 \\

Now, I want the <= to be aligned with each other; the expr_*2 to be centered; the expr_*1 to be right aligned, and the expr_*3 to be left aligned

What I have tried:

\begin{flalign}, \begin{align}

Question:

Is this possible to do with flalign/align, or should I be looking into other packages in AmsMath, or other packages in LaTeX?

Minimal Broken Example:

\begin{flalign}
a_1    & \leq &    a_2    & \leq &   a_3 \\
b_1    & \leq &    b_2    & \leq &   b_3 \\
\end{flalign}
share|improve this question
1  
Possible duplicate of tex.stackexchange.com/q/4273/1410 –  morbusg Jul 17 '12 at 14:14
add comment

3 Answers

up vote 4 down vote accepted

Here's how to obtain the desired alignment - using an array:

enter image description here

\documentclass{article}
\begin{document}
\[
  \begin{array}{r@{{}\leq{}}c@{{}\leq{}}l}
    a_1 a_1 a_1 & a_2         & a_3 a_3 a_3 \\[\jot]
    b_1         & b_2 b_2 b_2 & b_3
  \end{array}
\]
\end{document}

The alignment for the relational operators is specified as the column separation, with the appropriate spacing (of a relational mathematical operator via {}\leq{} - the addition of an empty object on either side is important). \jot adds a little vertical space between the expressions, for presentation.

If you wish to have the expressions numbered, a little more work is required.

share|improve this answer
    
Apparently, I'm not allowed to accept the answer until 1 more minute has passed. –  user13546 Jul 17 '12 at 6:04
    
Why \mathrel{\leq}? As far as I know, \leq is a math relation. :) –  egreg Jul 17 '12 at 7:06
    
@egreg: Thanks. I was overly cautious in my spacing... :) –  Werner Jul 17 '12 at 14:09
add comment

For multiple alignment points I would recommend the alignat environment:

enter image description here

Similar to the align environment, the alignat provides multiple rl alignments but without the spacing in between the pairs of rl equations. The && was necessary to make the following column left aligned (and skip past the right aligned column).

If you want to center a column you could use \makebox{}{} macro once you know the widest entry in the column:

enter image description here


Code (left aligned column):

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{alignat}{3}
a_1 a_1 a_1 & \le a_2         && \le a_3 a_3 a_3 \\
    b_1     & \le b_2 b_2 b_2 && \le b_3
\end{alignat}
\end{document}

Code (centered column):

\documentclass{article}
\usepackage{amsmath}
\usepackage{calc}

\newcommand*{\Widest}{b_2 b_2 b_2}%
\newcommand*{\Center}[1]{\makebox[\widthof{$\Widest$}]{$#1$}}%

\begin{document}
\begin{alignat}{3}
a_1 a_1 a_1 & \le \Center{a_2        } && \le a_3 a_3 a_3 \\
    b_1     & \le \Center{b_2 b_2 b_2} && \le b_3
\end{alignat}
\end{document}
share|improve this answer
    
But this does not centre the middle column of elements, as per the request. –  Werner Jul 17 '12 at 6:12
    
@Werner: Didn't see that initially, so have provided an updated solution for that case. –  Peter Grill Jul 17 '12 at 6:18
1  
This seems a more flexible solution than the others as each line in the example can be given its own equation number if this is desired. –  Jason Whyte Jul 17 '12 at 6:34
add comment

Have you tried using a table structure? I think something like this might work:

\begin {tabular} {r @{$\leq$} c @{$\leq$} l}
  $a_1$ & $a_2$ & $a_3$ \\
  $b_1$ & $b_2$ & $b_3$
\end {tabular}
share|improve this answer
add comment

Your Answer

 
discard

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