Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

3 Answers 3

up vote 6 down vote accepted

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.

share|improve this answer

You can use \hspace{} to do it.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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