9

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}
12

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.

| improve this answer | |
2

You can use \hspace{} to do it.

| improve this answer | |
2

I propose a simple solution relying on the empheq package (that loads amsmath and mathtools) and the align(ed) or align(ed)at environments. It lets you define what's on the left or on the right of a math environment.I give 5 variation on how to control the horizontal spacing, not only between the brace and the subsequent formulae (with extravagant value) but also between the numerical values and the conditions, and different alignments for the conditions.

\documentclass[ngerman]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage{fourier}

\usepackage[overload]{empheq}

\begin{document}

\begin{equation}[left = {f(x) =} \empheqlbrace\qquad ]
    \begin{aligned}
          &  1 &   & \text{if  }   x \text{ is even}\\
         & 0  &  &    \text{else}
    \end{aligned}
    \end{equation}
\bigskip

Controlling the horizontal spacing between the numerical values and the conditions:

\begin{equation}[left = {f(x) =} \empheqlbrace\qquad ]
    \begin{alignedat}{2}
          &  1 & \qquad  & \text{if  }   x \text{ is even}\\
         & 0  &  &    \text{else}
    \end{alignedat}
    \end{equation}

    Condition right aligned:

\begin{equation}[left = {f(x) =} \empheqlbrace\qquad ]
\begin{alignedat}{2}
      1 & \qquad  & \text{if  }   x \text{ is even}\\
    0  &  &    \text{else}
\end{alignedat}
\end{equation}
\bigskip

If there is no equation numbering,   the syntax is slightly simpler. 

\begin{alignat*}{2}[left = {f(x) =} \empheqlbrace\qquad ]
        1 & \quad  & \text{if  }   x \text{ is even}\\
        0  &  &    \text{else}
\end{alignat*}

\begin{alignat*}{3}[left = {f(x) =} \empheqlbrace\qquad ]
        1 &  & \quad  \text{if  }   x \text{ is even}&\\
        0  &   & \text{else}&
\end{alignat*}

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.