Parenthesis vertically misaligned in “cases” environment

I'm writing a paper using the "aps" document class, and I'm struggling with the cases environment -- which usually works like a charm for me. In one of my sections I present two equations that I want gathered as "cases":

\documentclass[aps,preprint,a4paper]{revtex4-1}

\usepackage{amsmath}
\newcommand{\delay}[1]{\mathcal{D}_{#1}}
\newcommand{\filter}{\mathcal{F}}

\begin{document}
$$\begin{cases} s_1 =& \filter \delay{3} p_2' - \filter p_1, \\ s_1' =& \filter \delay{2'} p_3 - \filter p_1'. \end{cases} \label{eq:definition-s1}$$
\end{document}


I would expect this to work fine and the two equations to be vertically aligned with the big opening parenthesis... but it seems that the layout comes out wrong: Here we see that the parenthesis is clearly shifted up with respect to the equations.

Any idea why and how to fix this?

Thanks very much for your time, Cheers!

• Welcome to TeX.SE! How are the macros \filter and \delay defined. Most likely they have something in their definitions that causes the issue. Please provide us with a minimal document which starts with \documentclass, ends with \end{document}, and has the definitions of the macros in it and shows the issue. – marmot Sep 11 '18 at 11:42
• Quite likely you have something like \doublespacing in your document. – egreg Sep 11 '18 at 11:53

The issue is surely due to you having set double spacing in your document. The following example indeed shows the problem:

\documentclass{article}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{etoolbox}

\newcommand{\filter}{\mathcal{F}}
\newcommand{\delay}[1]{\mathcal{D}_{#1}}

\begin{document}

$$\begin{cases} s_1 =& \filter \delay{3} p_2' - \filter p_1, \\ s_1' =& \filter \delay{2'} p_3 - \filter p_1'. \end{cases} \label{eq:definition-s1}$$

\doublespacing

$$\begin{cases} s_1 =& \filter \delay{3} p_2' - \filter p_1, \\ s_1' =& \filter \delay{2'} p_3 - \filter p_1'. \end{cases} \label{eq:definition-s2}$$

\makeatletter
\patchcmd{\env@cases}{1.2}{0.72}{}{}
\makeatother

$$\begin{cases} s_1 =& \filter \delay{3} p_2' - \filter p_1, \\ s_1' =& \filter \delay{2'} p_3 - \filter p_1'. \end{cases} \label{eq:definition-s3}$$

\end{document}


Equation 1 is normal, equation 2 is under the scope of \doublespacing and shows the problem. Equation 3 is after the cure. The magic constant 0.72 is 1.2/1.667 (1.2 is the \arraystretch used by cases, 1.667 is the \baselinestretch used by double spacing).

Here's how to do it for the whole document:

\documentclass{article}
\usepackage{amsmath}
\usepackage[doublespacing]{setspace}
\usepackage{etoolbox}

\newcommand{\filter}{\mathcal{F}}
\newcommand{\delay}[1]{\mathcal{D}_{#1}}

\makeatletter
\patchcmd{\env@cases}{1.2}{0.72}{}{}
\makeatother

\begin{document}

$$\begin{cases} s_1 =& \filter \delay{3} p_2' - \filter p_1, \\ s_1' =& \filter \delay{2'} p_3 - \filter p_1'. \end{cases} \label{eq:definition-s1}$$

\end{document}


You may also want to fix the vertical spacing in matrices:

\makeatletter
\patchcmd{\env@cases}{1.2}{0.72}{}{}
\pretocmd\env@matrix{\renewcommand{\arraystretch}{0.6}}{}{}
\makeatother


With revtex4-1 the correct patches should be slightly different:

\documentclass[
aps,
preprint,
a4paper,
]{revtex4-1}
\usepackage{amsmath}

\usepackage{etoolbox}

\newcommand{\filter}{\mathcal{F}}
\newcommand{\delay}[1]{\mathcal{D}_{#1}}

\makeatletter
\preprintsty@sw{%
\patchcmd{\env@cases}{1.2}{0.72}{}{}%
\pretocmd\env@matrix{\renewcommand{\arraystretch}{0.6}}{}{}%
}{}
\makeatother

\begin{document}

$$\begin{cases} s_1 =& \filter \delay{3} p_2' - \filter p_1, \\ s_1' =& \filter \delay{2'} p_3 - \filter p_1'. \end{cases} \qquad \begin{bmatrix} abc \\ def \end{bmatrix} \label{eq:definition-s1}$$

\end{document}


This way the patches will only be done when preprint is active.

• Awesome, thanks for the very comprehensive answer and the fix! That's a pity that "cases" uses the line height to compute the parenthesis' height and does not automatically vertically center the content... – Jean-Baptiste Sep 11 '18 at 13:10
• @Jean-Baptiste The fault is in double spacing; no reasonable typesetting can be done with that constraint. – egreg Sep 11 '18 at 13:13
• @Jean-Baptiste I added the correct patches for revtex4-1. – egreg Sep 11 '18 at 13:20

As a workaround you could instead use the array environment.

\documentclass{article}
\newcommand{\filter}{\mathcal{F}}
\newcommand{\delay}{\mathcal{D}}
\begin{document}
$$\bigg\{ \begin{array}{@{}ccc@{}} s_1 &=& \filter \delay{3} p_2' - \filter p_1, \\ s_1' &=& \filter \delay{2'} p_3 - \filter p_1'. \end{array} \label{eq:definition-s1}$$
\end{document}