1

By default, the cases environment adds some blank space between the end of the first part of the line and what's followed by & (unlike, say, aligned environment). I'm wondering what is the default value of this space, and if I can globally adjust it?

Werner
  • 603,163
mavzolej
  • 556
  • 1
    The space between the two parts of a line in the cases environment is hard coded as \quad. Here is the relevant component of the definition: \array{@{}l@{\quad}l@{}}. It could be redefined by patching, but if a change is wanted for only some instances of the environment, patching is not the best way. – barbara beeton Dec 23 '19 at 03:09
  • Got it, thanks! – mavzolej Dec 23 '19 at 03:13

1 Answers1

1

As mentioned by barbara beeton, the default gap between the elements and their conditions within the cases environment is \quad. It stems from the following definition combinations in amsmath.dtx:

\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@{}}%
}

The \env@cases part uses a vertically stretched array that has two left-aligned columns, separated by \quad. For consistency, you can patch this definition and replace \quad with (say) ~:

enter image description here

\documentclass{article}

\usepackage{amsmath,etoolbox}

\makeatletter
\patchcmd{\env@cases}% <cmd>
  {\quad}% <search>
  {~}% <replace>
  {}{}% <success><failure>
\makeatother

\begin{document}

\[
  f(x) = \begin{cases}
     x & \text{if $x \geq 0$} \\
    -x & \text{otherwise}
  \end{cases}
\]

\end{document}

In the above image, the original spacing (with \quad) is shown at the top with the updated spacing (with ~) at the bottom.

Werner
  • 603,163