150

This question already has an answer here:

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?

marked as duplicate by Werner, user13907, Reinstate Monica - M. Schröder, Heiko Oberdiek, Paul Gaborit Jun 18 '15 at 6:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    use cases or dcases. – Peter Grill Mar 7 '12 at 20:05
191

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}
  • I had thought you usually want a \, before text punctuation inline with math, no? – Doctor Mohawk Sep 12 '17 at 14:56
  • Is it possible to change the curly braces to bracket in this environment? – H. R. Sep 19 '17 at 7:31
33

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

  • 5
    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
  • 4
    @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
  • 2
    I actually like your answer better. – 0rkan Sep 25 '15 at 3:09
  • I like this answer for its flexibility. It shows how to create a single-sided brace (or any other grouping symbol) for applications where cases isn't suitable. – drmuelr Oct 13 '18 at 5:31

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