amsmath: cases and \arraystretch

The amsmath cases environment is using the array environment internally, like its matrix environments. If you want to change the interline spacing of matrices you could redefine \arraystretch, like for any array environment. But it won’t work for cases – amsmath defines an arraystretch value of 1.2 internally.

A solution is to redefine the \env@cases macro. Here’s a redefinition, introducing an optional parameter controlling the spacing:

\makeatletter
\renewcommand*\env@cases[1][1.2]{%
  \let\@ifnextchar\new@ifnextchar
  \left\lbrace
  \def\arraystretch{#1}%
  \array{@{}l@{\quad}l@{}}%
}
\makeatother

Now by \begin{cases} … \end{cases} the default value of 1.2 will be used, but by using the optional parameter like \begin{cases}[0.8] … \end{cases} the spacing will be adjusted accordingly.

This topic was discussed on mrunix.de.

24. September 2008 by stefan
Categories: Uncategorized | 6 comments

Comments (6)

  1. “it’s”?

    Otherwise nice post, thanks.

  2. Hi Tom,

    thank you for pointing out the typo in the first sentence, I’ve changed it to “its”, meaning the matrix environments of amsmath.

  3. Nice macro :-)
    Thank you so much!

  4. This was exactly what I needed for my thesis. Thank you!

  5. What I see here is art. It is so beautiful. And so frustrating.
    How can I produce something like
    begin{tikzpicture}
    matrix (m) [matrix of math nodes, row sep=3em,
    column sep=3em]{
    & f^ast E_V& & vphantom{f^ast}E_V \
    f^ast E & & vphantom{f^ast}E & \
    & U & & V \
    M & & N & \};
    path[-stealth]
    (m-1-2) edge (m-1-4) edge (m-2-1)
    edge [densely dotted] (m-3-2)
    (m-1-4) edge (m-3-4) edge (m-2-3)
    (m-2-1) edge [-,line width=6pt,draw=white] (m-2-3)
    edge (m-2-3) edge (m-4-1)
    (m-3-2) edge [densely dotted] (m-3-4)
    edge [densely dotted] (m-4-1)
    (m-4-1) edge (m-4-3)
    (m-3-4) edge (m-4-3)
    (m-2-3) edge [-,line width=6pt,draw=white] (m-4-3)
    edge (m-4-3);
    end{tikzpicture}

    or

    begin{tikzpicture}[start chain] {
    node[on chain] {$0$};
    node[on chain] {$A$} ;
    node[on chain, join={node[above]
    {$scriptstylevarphi$}}] {$B$};
    node[on chain, join={node[above]
    {$scriptstylepsi$}}] {$C$};
    node[on chain] {$0$}; }
    end{tikzpicture}

    What preamble will allow me to produce those pretty diagrams?
    Thank you
    Adel

  6. Hi Adel,

    I see you refer to other posts, even if you commented to this amsmath post. The other posts contain links to the complete source code of the examples you mentioned. Just read the text.

    I.e. for the first one a possible preamble is:

    documentclass{article}
    usepackage{tikz}
    usetikzlibrary{matrix}

Leave a Reply

Required fields are marked *