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


    4 & \hbox{for~odd~$i$} \\
    3 & \hbox{for~even~$i$,}

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



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.

  • 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 '16 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):



  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.

  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*}


enter image description here


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:



        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,
        1,&\text{if }i=m,\\
        2,&\text{if }i=1,\\
        5,&\text{if }2 \leq i \leq m-1.


In plain TeX, it should be done by this:

  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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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