• Free forever
  • No sign-up
  • Private — runs in your browser

Cases (piecewise function) in LaTeX

The LaTeX command for cases (piecewise function) is \begin{cases} a & x > 0 \\ b & x \le 0 \end{cases}. Try it in the editor below.

Loading the math renderer…

How to write cases (piecewise function) in LaTeX

Use \begin{cases} a & x > 0 \\ b & x \le 0 \end{cases} in math mode — between $…$ in a document, or directly in the editor above.

LaTeX command\begin{cases} a & x > 0 \\ b & x \le 0 \end{cases}
Notesamsmath

Some forms need a package — add \usepackage{amsmath, amssymb} to your preamble; MathJax, Notion, Obsidian and most Markdown editors already include them.

Example

|x| = \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases}

The editor above is pre-filled with this example — tweak it and export it as PNG, SVG or a Word equation.

More structures

SymbolCommand
Matrix\begin{pmatrix} a & b \\ c & d \end{pmatrix}
Binomial coefficient\binom{n}{k}
Absolute value\lvert x \rvert
⌊⌋\lfloor x \rfloor
Subscripts and superscriptsx_{i}^{2}

See every LaTeX symbol →

Related

← Back to the full LaTeX Equation Editor