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

How do I typeset something like, X = 0 if a=1, 1 otherwise, using those huge left braces and specifying each condition in a line?

share|improve this question
up vote 37 down vote accepted

The cases environment from amsmath does the trick.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
  \begin{equation}
    X=
    \begin{cases}
      0, & \text{if}\ a=1 \\
      1, & \text{otherwise}
    \end{cases}
  \end{equation}
\end{document}

Result

share|improve this answer

Another method, which is especially helpful if one needs to have more control over the items alignment, is the array construct.

\documentclass{article}
\usepackage{amsmath}    
\begin{document}

\begin{equation}
  X=\left\{
  \begin{array}{@{}ll@{}}
    0, & \text{if}\ a=1 \\
    1, & \text{otherwise}
  \end{array}\right.
\end{equation} 

\end{document}

enter image description here

Instead of ll, one may choose cc, rr, rl, etc. Besides, all the array capabilities can be applied here (\arraycolsep, \arraystretch, \extrarowheight by loading the array package, etc).

One more alternative could be using the aligned environment and adding the pseudo-parenthesis ., which can be used to terminate an opening parenthesis {.

\documentclass{article}
\usepackage{amsmath}    
\begin{document}

\begin{equation}
  X = \left \{
  \begin{aligned}
    &0, && \text{if}\ a=1 \\
    &1, && \text{otherwise}
  \end{aligned} \right.
\end{equation} 

\end{document}

enter image description here

share|improve this answer

Iverson bracket can also be used: $x=[a=1]$.

share|improve this answer
x = \begin{cases}
  0, & \text{if } a = 1, \\
  1, & \text{otherwise}.
\end{cases}

amsmath is needed for \text.

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.