I want to write a conditional expression such as the following.

What is the best way to express such conditional expressions in Latex?
I want to write a conditional expression such as the following.

What is the best way to express such conditional expressions in Latex?
I think this is a job for cases from the amsmath package

\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.

\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}
\, before text punctuation inline with math, no?
– Translunar
Sep 12 '17 at 14:56
Just for the sake of completeness (i.e. environments where amsmath may not be available): There is a pseudo-parenthesis . that can be used to terminate an opening parenthesis:
\documentclass{standalone}
\begin{document}
$\left{
\begin{array}{ c l }
\frac{x^2 - x}{2} & \quad \textrm{if } x \geq 1 \
0 & \quad \textrm{otherwise}
\end{array}
\right.$
\end{document}
Output:
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 05:48
cases isn't suitable.
– drmuelr
Oct 13 '18 at 05:31
amsmath package, so expanding this to perform what the question asked for would certainly help me!
– Connor McCormick
Jan 25 '21 at 16:26
casesordcases. – Peter Grill Mar 07 '12 at 20:05