This post explains how to typeset multi-part definitions in LaTeX.
The absolute value function is a simple example of a two-part definition.
![]()
The Möbius function is a more complicated example of a three-part definition.

Here’s how you could write LaTeX for the absolute value definition.
|x| =
\left\{
\begin{array}{ll}
x & \mbox{if } x \geq 0 \\
-x & \mbox{if } x < 0
\end{array}
\right.
The right-hand side of the equation is an array with an opening brace sized to fit on the left. Braces are special characters and so the opening brace needs to be escaped with a backslash. LaTeX requires a right for every left but the dot in right. says to make the matching container on the right side empty.
Since this pattern comes up fairly often, it’s handy to have a command to encapsulate it. We define twopartdef as follows.
\newcommand{\twopartdef}[4]
{
\left\{
\begin{array}{ll}
#1 & \mbox{if } #2 \\
#3 & \mbox{if } #4
\end{array}
\right.
}
Then we could call it as follows:
|x| = \twopartdef { x } {x \geq 0} {-x} {x < 0}
The command threepartdef is very similar to twopartdef.
\newcommand{\threepartdef}[6]
{
\left\{
\begin{array}{lll}
#1 & \mbox{if } #2 \\
#3 & \mbox{if } #4 \\
#5 & \mbox{if } #6
\end{array}
\right.
}
You could call threepartdef for the Möbius function as follows.
mu(n) = \threepartdef
{1} {n=1}
{0} {a^2 ,|, n \mbox{ for some } a > 1}
{(-1)^r} {n \mbox{ has } r \mbox{ distinct prime factors}}
More LaTeX posts
- Typesetting music in LaTeX
- How to display side-by-side figures in LaTeX
- Including images in LaTeX
- LaTeX and PowerPoint presentations
- How to put PDF properties in a LaTeX file


