4

I would like to have a few tabs in a cases environment so that the "for"s and the "u"s in my example (and in the best case the "j"s as well) are on one line, respectively. I tried different environments for equations but I haven't found a solution. The quad-distances don't satisfy me...

\begin{align*}
    \phi_{C}(u)= 
        \begin{cases}
            (j-1)\cdot \lambda & \text{for } d_{j-1}\leq u \leq d_{j}-\lambda \qquad j=1,\ldots ,r\\
            j\cdot \lambda +u-d_{j} & \text{for } d_{j}-\lambda\leq u\leq d_{j} \qquad \qquad j=1,\ldots ,r-1 \qquad  \text{with } r\geq 2 \\
            r\cdot \lambda +u-d_{r} & \text{for } d_{r}-\lambda\leq u
    \end{cases}
\end{align*}
Okapi
  • 43

3 Answers3

4

We can define a multicases environment modeled on cases that accepts as argument the number of conditions:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newenvironment{multicases}[1]
  {\let\@ifnextchar\new@ifnextchar
   \left\lbrace\def\arraystretch{1.2}%
   \array{@{}l*{#1}{@{\quad}l}@{}}}
  {\endarray\right.\kern-\nulldelimiterspace}
\makeatother

\begin{document}
\begin{equation*}
\phi_{C}(u)= 
   \begin{multicases}{2}
   (j-1)\cdot \lambda      & \text{for } d_{j-1}\leq u \leq d_{j}-\lambda & j=1,\dots ,r\\
   j\cdot \lambda +u-d_{j} & \text{for } d_{j}-\lambda\leq u\leq d_{j}    & j=1,\dots ,r-1 \text{ with } r\geq 2 \\
   r\cdot \lambda +u-d_{r} & \text{for } d_{r}-\lambda\leq u
   \end{multicases}
\end{equation*}
\end{document}

enter image description here

Use \dots and not \ldots. It's possibly improved by adding parentheses around the additional conditions:

enter image description here

egreg
  • 1,121,712
3

Easy with alignat and empheq to replace the cases environment. Empheq loads mathtools, hence amsmath:

\documentclass[a4paper, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{fourier}

\usepackage[overload]{empheq}

\begin{document}

\begin{alignat*}{4}[left = {ϕ_{C}(u)=\empheqlbrace}]
    & (j-1) · λ & \quad & \text{for\enspace } & d_{j-1} & \leq u \leq d_{j}-λ & \qquad & j=1,\ldots ,r \\
    & j · λ +u-d_{j} & & \text{for } & d_{j}-λ & \leq u\leq d_{j} & & j=1,\ldots ,r-1 \quad \text{with } r\geq 2 \\
  & r · λ +u-d_{r} & & \text{for } & d_{r}-λ & \leq u
\end{alignat*}

\end{document} 

enter image description here

azetina
  • 28,884
Bernard
  • 271,350
0

Isn't an elegant response, but it works.

\begin{align*}
  \phi_{C}(u)= 
    \begin{cases}
        (j-1)\cdot \lambda & \text{for } \;\,d_{j-1}\;\leq u \leq    d_{j}-\lambda \qquad j=1,\ldots ,r\\
        j\cdot \lambda +u-d_{j} & \text{for } d_{j}-\lambda\leq u\leq d_{j} \qquad \quad\;\;\, j=1,\ldots ,r-1 \qquad  \text{with } r\geq 2 \\
        r\cdot \lambda +u-d_{r} & \text{for } d_{r}-\lambda\leq u
    \end{cases}
\end{align*}
Sigur
  • 37,330
juanuni
  • 1,987