inline spacing within the `cases` command when document is in doublespace mode

Here's a version that redefines the cases environment to temporarily switch to single line spacing within the environment. The extra definition of \new@setfontsize is only necessary to suppress a warning about setting text commands in math mode; it's otherwise the same as the original definition.

This pattern should be easily adaptable for other math environments, if necessary.

\documentclass{amsart}
\usepackage{lipsum}
\usepackage{setspace}

\makeatletter
\newcommand\new@setfontsize[3]{%
    \ifx \protect \@typeset@protect \let \@currsize #1\fi \fontsize {#2}{#3}\selectfont
}
\let\orig@setfontsize\@setfontsize
\let\orig@cases\cases
\let\endorig@cases\endcases

\renewenvironment{cases}{%
    \let\@setfontsize\new@setfontsize
    \setstretch{\setspace@singlespace}%
    \let\setfontsize\orig@setfontsize
    \orig@cases
}{%
    \endorig@cases
}
\makeatother

\begin{document}
\doublespacing
\lipsum[1]
$x = 
\begin{cases} 
a & \text{if } x < -3 \\
b & \text{if } -2 < x < 0 \\
c & \text{if } 0 < x < 2 \\
d & \text{if } x > 2 
\end{cases}
$
\lipsum[1]
\end{document}

enter image description here


Rather than redefining cases to use \singlespacing or \setstretch{1}, I believe it's better to correctly set the \arraystretch.

Something similar should probably also be done for array, but one can use \fixarraystretch{<factor>} everywhere.

\documentclass{amsart}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{xfp,etoolbox}

\makeatletter
\patchcmd{\env@cases}
  {\def\arraystretch{1.2}}
  {\fixarraystretch{1.2}}
  {}{}
\makeatother
\newcommand{\fixarraystretch}[1]{%
  \edef\arraystretch{\fpeval{#1/(\baselinestretch)}}%
}

\begin{document}
\doublespacing
\lipsum[1]
$x = 
\begin{cases} 
a & \text{if } x < -3 \\
b & \text{if } -2 < x < 0 \\
c & \text{if } 0 < x < 2 \\
d & \text{if } x > 2 
\end{cases}
$
\lipsum[1]
\end{document}

enter image description here

Just a final comment: using double spacing for submissions is a relic of the past; nowadays everybody receives PDF files and leaving space for annotations makes little sense; it just hinders reading the document on the screen.

Tags:

Spacing

Cases