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 want to write a conditional expression such as the following.

enter image description here

What is the best way to express such conditional expressions in Latex?

share|improve this question
    
use cases or dcases. –  Peter Grill Mar 7 '12 at 20:05
add comment

2 Answers

up vote 40 down vote accepted

I think this is a job for cases from the amsmath package

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
    f(x)= 
\begin{cases}
    \frac{x^2-x}{x},& \text{if } x\geq 1\\
    0,              & \text{otherwise}
\end{cases}
\]
\end{document}

or if you would prefer a displaystyle fraction, then you could use dcases from the mathtools package, which extends (and loads) the amsmath package.

enter image description here

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\[
    f(x)= 
\begin{dcases}
    \frac{x^2-x}{x},& \text{if } x\geq 1\\
    0,              & \text{otherwise}
\end{dcases}
\]
\end{document}
share|improve this answer
add comment

Just for the sake of completeness: There is a pseudo-parenthesis . that can be used to terminate an opening parenthesis:

\documentclass{standalone}

\begin{document}
$\left\{a+b=c\right.$
\end{document}

Output: Result of compilation

share|improve this answer
1  
You should expand this answer to show how to use this to produce the output in the original image. –  Peter Grill Mar 10 '12 at 1:04
    
@PeterGrill: Well, there are ways, but cases and dcases are much much more suitable for this task. Are there conditions where these environments are not available? –  krlmlr Mar 10 '12 at 5:48
add comment

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.