# Cases vs. Array environments

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 and cases allow changing the space between lines using, for instance, \2ex]. • It is much easier to change the alignment of columns with array than with cases. • The left brace from cases seems to be taller than the left brace from array. But I don't understand why. • Using cases is semantically more appropriate. • cases requires loading amsmath 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.

## 1 Answer

The code for cases in amsmath is just

\renewenvironment{cases}{%
\matrix@check\cases\env@cases
}{%
\endarray\right.%
}
\def\env@cases{%
\let\@ifnextchar\new@ifnextchar
\left\lbrace
\def\arraystretch{1.2}%
\array{@{}l@{\quad}l@{}}%
}


so it is array with a column specification of {@{}l@{\quad}l@{}} and arraystretch of 1.2

• Thank you, this is very useful! Mar 21, 2020 at 15:01
• You might mention cases* from mathtools, which allows r/l adjustments. And, although not used in a "cases" situation, array also allows c to center a column. (May as well be complete.) Mar 21, 2020 at 22:02
• You can use \hfil to center a column in cases if desired: \begin{cases} \hfil x & \text{if } x\geq 0\\ -x & \text{if } x<0. \end{cases}. More manipulation is possible with arrays, but when copyediting authors' tex files, I almost always change cases to the cases environment. The more "opportunity" authors are given to adjust spacing, the more likely it is that infelicities will be introduced. (In a similar vein, \text{if } is preferable to \text{if}\ or \text{if}\; etc.) In my opinion, cases should be the default choice, unless you need to do something complicated. May 5, 2020 at 16:00