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 have equations of the form

a = b + d     for i <= 4, j < 3
  = c         for i = 5
  = d - e + u for i > 5 

I am writing them using the following code in latex:

\begin{equation} 
  a = \left\{
 \begin{array}{lr}
 b + d  & \mbox{for } i \le 4, j < 3 \\
 c & \mbox{for } i = 5 \\
 d - e + u & \mbox{for } i > 5
\end{array}
\right.
\label{eqn:simple_one} 
\end{equation}

But the problem is that the conditional statements starting with "for" are always right aligned and the output looks like this (with a left brace after the "=" sign, which i cannot draw :) ).

a = b + d     for i <= 4, j < 3
    c                 for i = 5
    d - e + u         for i > 5 

I wanted to make the condtional part left aligned such that the words "for" come exactly one below the other. How can this be done?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

They are right aligned because you have {array}{lr} change that to {array}{ll} to left align both columns. But generally it is best not to use array for laying out whole equations, it is designed for matrices/arrays. Here I think the amsmath package and its cases environment would be better.

share|improve this answer
    
Thanks! I will also try out "cases" environment. –  maths-help-seeker Jun 27 '12 at 21:23
    
@David Carlisle: Maybe its also good to note the other cases environment if needed such as: rcases (used for a right-aligned brace), dcases (used for display-math inside of the cases environment, and others that maybe available. –  night owl Jun 27 '12 at 22:51

using amsmath and \cases allows this to be accomplished with simpler coding:

\begin{equation} 
  a = \begin{cases}
 b + d  & \text{for $i \le 4$, $j < 3$} \\
 c & \text{for $i = 5$} \\
 d - e + u & \text{for $i > 5$}
\end{cases}
\label{eqn:simple_one} 
\end{equation}

with this result:

enter image description here

also note the use of \text instead of \mbox. \text will produce the correct size whether it's used at the base level or in sub- or superscripts or limits.

share|improve this answer
    
+1 for the suggestion related to \text! –  maths-help-seeker Jun 27 '12 at 21:28
4  
I'd type \text{for $i \le 4$, $j < 3$}, but it's a matter of taste. –  egreg Jun 27 '12 at 21:33
    
@egreg -- you're absolutely right. updated in example. –  barbara beeton Jun 27 '12 at 21:42

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.