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 quite a strange tex style from the conference. Everything is fine, but the following code does not work here:

\begin{eqnarray}
a = \begin{cases} 1 \\
                  2
\end{cases}
\end{eqnarray}

does not seem to work here in conjunction with eqnarray, which is also required. Is it possible to mimic the behaviour of cases in this case?

share|improve this question
2  
I threw that into the tex file contained in your link and it seemed to produce the correct output after adding \usepackage{amsmath} to the preamble. Have you loaded amsmath? –  Scott H. Jul 15 '12 at 18:11
    
Yep, it seems so. Thank you! –  Ivan Oseledets Jul 15 '12 at 23:43

1 Answer 1

up vote 8 down vote accepted

eqnarray is not required in order for cases to work. Moreover, it's deprecated in terms of its support/usage and should therefore not be used. Rather use align (see \eqnarray vs \align. You're most likely after:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align*}
  a = \begin{cases}
      x & \text{if $y=1$} \\
      z & \text{if $b=2$}
    \end{cases}
\end{align*}
\end{document}

amsmath provides cases as well as \text and align, although align is technically not needed for such an elementary equation. Using an equation environment (or unnumbered \[ ... \]) would suffice.

You could also obtain the above output manually using

\documentclass{article}
\begin{document}
\[
  a = \left\{\begin{array}{@{}l@{\quad}l}
      x & \mbox{if $y=1$} \\[\jot]
      z & \mbox{if $b=2$}
    \end{array}\right.
\]
\end{document}
share|improve this answer
    
Why not use a simple \[...\]? align is not needed here! –  Hendrik Vogt Jul 16 '12 at 15:59
    
@HendrikVogt: That's correct. In the spirit of the original question, I kept the align. I'll update the answer accordingly. –  Werner Jul 16 '12 at 16:02
    
@Werner The original question uses eqnarray where it shouldn't to begin with, because there's no alignment. The "correct" answer would use equation. –  egreg Jul 16 '12 at 16:37

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.