Knowledge base dedicated to Linux and applied mathematics.
Home > Latex > FAQ > Latex - FAQ > Latex piecewise function
How to write Latex piecewise function with left operator or cases environment.
First of all, modifiy your preamble adding
\usepackage{amsfonts}
\begin{equation*}
y = f(x) = \lvert x \rvert = \left\{
\begin{array}{ll}
-x & \quad x \leq 0 \\
x & \quad x \geq 0
\end{array}
\right.
\end{equation*}
$$ \begin{equation*} y = f(x) = \lvert x \rvert = \left\{ \begin{array}{ll} -x & \quad x \leq 0 \\ x & \quad x \geq 0 \end{array} \right. \end{equation*} $$
\begin{equation*}
g(x)=\begin{cases}
x \quad &\text{if} \, x \in \mathbb{Q} \\
-x \quad &\text{if} \, x \notin \mathbb{Q} \\
\end{cases}
\end{equation*}
$$ \begin{equation*} g(x)=\begin{cases} x \quad &\text{if} \, x \in \mathbb{Q} \\ -x \quad &\text{if} \, x \notin \mathbb{Q} \\ \end{cases} \end{equation*} $$