[Tex/LaTex] Horizontal spacing after cases bracket in equation

casesequationsspacing

How can I add a little horizontal spacing after the cases bracket, at the depicted position, so that 1 and 0 move to the right (the given screenshot looks okayish, but I'm using a different font where the spacing is too tight):

casesSpacing

MWE:

\documentclass[ngerman]{scrbook}
\usepackage{amsmath}
\begin{document}
\begin{equation}
    f(x) = 
    \begin{cases}
      1 & \text{if } x \text{ is even}\\
      0 & \text{else}
    \end{cases}
\end{equation}
\end{document}

Best Answer

You can redefine the way amsmath defines the cases specification by updating \env@cases. Below I removed the zero-width column padding that was stripped from the array column specification:

enter image description here

\documentclass{scrbook}
\usepackage{amsmath}
\makeatletter
\def\env@cases{%
  \let\@ifnextchar\new@ifnextchar
  \left\lbrace
  \def\arraystretch{1.2}%
  \array{l@{\quad}l@{}}% Formerly @{}l@{\quad}l@{}
}
\makeatother
\begin{document}
\begin{equation}
    f(x) = 
    \begin{cases}
      1 & \text{if $x$ is even} \\
      0 & \text{else}
    \end{cases}
\end{equation}
\end{document}

Alternatively, you can define your own width using something like

@{\hspace{<len>}}l@{\quad}l@{}

where you specify the length <len>. The above manages the spacing for cases at a document-wide level. If you want to make a one-off change, you can write your own case manually:

enter image description here

\documentclass{scrbook}
\usepackage{amsmath}
\begin{document}
\begin{equation}
  \renewcommand{\arraystretch}{1.2}
  f(x) = \left\{
    \begin{array}{@{\quad}l@{\quad}l@{}}
      1 & \text{if $x$ is even} \\
      0 & \text{else}
    \end{array}
    \right.
\end{equation}
\end{document}

For more on the use of the @{...} specification, see Column and row padding in tables.