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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a newbie here and I got stuck in the following situation. Let me type the portion first

\documentclass{article}

\begin{document}
\begin{eqnarray*}
f_2(u_iu_{i+1})&=&\left\{
  \begin{array}{ll}
    4 & \hbox{for~odd~$i$} \\
    3 & \hbox{for~even~$i$,}
  \end{array}
\right.\\[.2cm]
f_2(v_mv_1)&=&5,\\
f_2(u_mu_1)&=&5,\\

for $2\leq i\leq m-1,$

f_2(v_iu_i)&=&5,\\
f_2(v_mu_m)&=&1,\\
f_2(v_1u_1)&=&2.
\end{eqnarray*}

\end{document}

My problem is: I want the sentence "for $2\leq i\leq m-1,$" at the extreme left while all other equality signs shown above should be aligned. But I falied to maintained that. Please someone help me on it.

P.S. Please feel free to edit the above if necessary.

share|improve this question
    
Welcome to TeX SX! A first comment: you shouldn't use eqnarray: it yields bad spacings and is obsolete. Use one of the amsmath environments instead (align,aligned, &c.) – Bernard Mar 24 at 10:00

I propose two solutions, based on align*, and the cases* environment from mathtools (it is like the standard cases, except the second column is typeset in text mode):

\documentclass{article}
\usepackage{mathtools}
\usepackage[showframe]{geometry}

\begin{document}

\begin{align*}
  f_2(u_iu_{i+1}) & =\begin{cases*}
  4 & for odd $ i $ \\
  3 & for even $ i $, \end{cases*} \\
  f_2(v_mv_1) & = 5, \\
  \text{for $2\leq i\leq m-1$,}
  \quad f_2(v_iu_i) & = 5, \\
  f_2(v_mu_m) & = 1, \\
  f_2(v_1u_1) & = 2.
\end{align*}

\begin{align*}
  f_2(u_iu_{i+1})&=\begin{cases*}
  4 & for odd $ i $\\
  3 & for even $ i $,
  \end{cases*} \\
  f_2(v_mv_1)&= 5,\\
  f_2(v_iu_i) & = \begin{cases*}5 & for $ 2\leq i\leq m-1 $, \\
  1 & for $ i = m$,\\
  2 & for $ i = 1$. \end{cases*}
\end{align*}

\end{document}

enter image description here

share|improve this answer

You can combine several of these branches so I'd go for something like this:

enter image description here

Rather than eqnarray I recommend using the align* from the amsmath package. There is also a cases environment for typesetting piece-wise functions and a \text{...} command for writing text inside equations. Putting these together, here is the code I used:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

  \begin{align*}
      f_2(u_iu_j)&=\begin{cases}
        3,&\text{if $i$ is odd and }j=i+1,\\
        4,&\text{if $i$ is even and }j=i+1,\\
        5,&\text{if $i=m$ and }j=1,
      \end{cases}\\
      f_2(v_iu_i)&=\begin{cases}
        1,&\text{if }i=m,\\
        2,&\text{if }i=1,\\
        5,&\text{if }2 \leq i \leq m-1.
      \end{cases}
  \end{align*}

\end{document}
share|improve this answer

In plain TeX, it should be done by this:

$$\eqalignno{
  f_2(u_i u_{i+1}) &= \cases{4 & for odd $i$, \cr 3 & for even $i$,} \cr
  f_2(v_m v_1) &= 5, \cr
  f_2(u_m u_1) &= 5, \cr
\noalign{\hbox{for $2 \leq i \leq m-1$,}}
  f_2(v_i u_i) &= 5, \cr
  f_2(v_m u_m) &= 1, \cr
  f_2(v_1 u_1) &= 2.
}$$

\bye
share|improve this answer

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.