5

For journal submissions, we obviously have to use doublespace mode. But I don't want to take up even more of the page using a multi-branch cases command, which by default puts double spaces between each branch. Obviously one can manually reduce the gap between branches with \\[-xpt] at the end of each branch, but it's incredibly kludgy and fragile and messes up the space between the current line and the following one. I'm wondering if there's a package or a nice macro that would shrink the gaps in a robust way and manage the vertical height of the left brace. Here's an MWE where the default spacing within the cases command is ridiculous. Thanks!

\documentclass{amsart}
\usepackage{lipsum}
\usepackage{setspace}
\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}
5

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

1
  • Ahhh, I can't tell you how long I've been waiting for this!!!! Thanks so much tho i know I'm not allowed to say thank you – Leo Simon Dec 9 '16 at 7:07
2

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.

5
  • Hi egreg, what's the advantage of your approach with respect to \AtBeginEnvironment{cases}{\setstretch{1}}?Thanks. – CarLaTeX Jul 30 '20 at 5:58
  • @CarLaTeX That it doesn't depend on setspace. – egreg Jul 30 '20 at 11:02
  • OK, thanks, but if I have already setspace loaded, does it make any difference? – CarLaTeX Jul 30 '20 at 11:05
  • @CarLaTeX Yes: \setstretch{1} does a wealth of useless things. And I wouldn't recommend the currently accepted answer, which has the same defect, only made worse. Besides, \renewenvironment{cases} is not the best, as amsmath has an indirect way to define cases, in order to catch foreign syntax. – egreg Jul 30 '20 at 11:18
  • Thanks for the explanation – CarLaTeX Jul 30 '20 at 11:49
1

You can accomplish this by setting \baselinestretch back to 1 inside the definition of the cases environment. This is a multiplier for the distance between lines in a paragraph (and also between the rows of the cases environment) and it was set to 1.667 by \doublespacing.

To patch cases, you can add the following snippet to your preamble:

\usepackage{etoolbox}
\AtBeginEnvironment{cases}{\renewcommand\baselinestretch{1}\selectfont}

Demonstration

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

\usepackage{etoolbox} %% <- added
\AtBeginEnvironment{cases}{\renewcommand\baselinestretch{1}\selectfont} %% <- added

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

output


Notes:

  • The change to \baselinestretch only takes effect after \selectfont is called, which is why that command is there.
  • Simply putting \renewcommand\baselinestretch{1}\selectfont inside the cases environment doesn't work because its scope will be limited to just the first cell of the environment.
0

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.