I would like to completely understand all the differences between using the amsmath
environment cases
and using the array
environment to write functions with cases.
Here is my current understanding after reading other questions in the forum:
array
comes with padding on the left and the right. It can be suppressed using{@{}ll@{}}
as explained in this related question.array
creates vertical spacing issues that I don't fully understand. See this related question.- Both
array
andcases
allow changing the space between lines using, for instance,\\[2ex]
. - It is much easier to change the alignment of columns with
array
than withcases
. - The left brace from
cases
seems to be taller than the left brace fromarray
. But I don't understand why. - Using
cases
is semantically more appropriate. cases
requires loadingamsmath
Overall, it seems like the default version of cases
is better, but array
is more customizable.
Are there other differences that I am missing? Is there an aspect of functions with cases that can be formatted using one of the environments but not the other one?
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
|x| =
\begin{cases}
x & \text{if}\ x\geq 0\\
-x & \text{if}\ x<0\\
\end{cases}.
\]
\end{document}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
|x| =
\left\{\begin{array}{ll}
x & \text{if}\ x\geq 0\\
-x & \text{if}\ x<0\\
\end{array}\right..
\]
\end{document}
What I really want to know is which of the two environments is better and why. I have been using array
for years, but I am considering switching to cases
.