# Equations and Double Spacing

If a document (in any class) is double spaced, how do you redefine the spacing around centered equations as if there was single spacing? Whenever I use double spacing, I feel like the space before and after a centered equations is too large.

If you are using the setspace package to change to doublespacing, you could use the etoolbox package and its \BeforeBeginEnvironment and \AfterEndEnvironment to append \begin{singlespace} before, and \end{singlespace} after the environments for displayed equations. The following example illustrates this approach for the equation and align environments (similar declarations will have to be made for the other environments and for their starred versions):

\documentclass{article}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{etoolbox}
\usepackage{lipsum}% just to generate text for the example

\BeforeBeginEnvironment{equation}{\begin{singlespace}}
\AfterEndEnvironment{equation}{\end{singlespace}\noindent\ignorespaces}
\BeforeBeginEnvironment{align}{\begin{singlespace}}
\AfterEndEnvironment{align}{\end{singlespace}\noindent\ignorespaces}

\doublespacing

\begin{document}

\lipsum[2]
$$a=b.$$
\lipsum[2]

\end{document}

• What does \lipsum[2] mean? – richtera Mar 29 '12 at 1:07
• @AlexRichter The lipsum package generates filler text; lipsum[2] means "use the second paragraph of the predefined text"; more generally, \lipsum[i-j] (with i<j) means "use the paragraphs i to j of the predefined text". – Gonzalo Medina Mar 29 '12 at 1:11
• @AlexRichter: Mico's answer is better and you should accept it instead of mine. – Gonzalo Medina Mar 29 '12 at 2:47
• It seems Mico's answer is not the same as this answer. Using nodisplayskipstretch does not make align environments singlespaced. However, this answer definitely does. – Umang Jan 5 '14 at 3:58
• @Umang - I only now noticed your comment, which you posted nearly 5 years ago. Your application, which appears to involve align environments, is fundamentally different from what the OP posted and the answers provided by both Gonzalo Medina and myself, which treated single-line equations. – Mico Nov 16 '18 at 7:45

You could simply set the nodisplayskipstretch option of the setspace package, viz., write

\usepackage[nodisplayskipstretch]{setspace}


in the preamble. An advantage of this solution is that it applies automatically to all display-math environments. (Aside: In the MWE below, the \namdui command serves to produce some filler text -- specifically, the first few sentences of the second stanza of the lipsum package's text.)

\documentclass{article}
\usepackage[nodisplayskipstretch]{setspace}

\newcommand{\namdui}{Nam dui ligula, fringilla a, euismod sodales,
sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
pretium at, lobortis vitae, ultricies et, tellus.}  % filler text

\doublespacing
\begin{document}

\namdui
$$a=b.$$
\namdui
\end{document}


A potentially better alternative to setspace with nodisplayskipstretch or etoolbox is instead to use setspace as follows:

\usepackage{setspace}\setdisplayskipstretch{}


This usually results in a more compact document. For example, the following code produces a document with 77 pages:

\documentclass[a4paper]{article}  %  For a consistent page count, specify a paper size.
\usepackage{setspace}\setdisplayskipstretch{}
\doublespacing
\usepackage{blindtext}  %  Introduces the "Lorem ipsum..." filler text command \blindtext
\usepackage{pgffor}     %  Introduces the \foreach command

\begin{document}
\foreach \n in {1,...,200}{  % repeat 200 times
$$a=b.$$
\blindtext  % "Lorem ipusm..." filler text
}
\end{document}


In comparison, the page counts corresponding to the various possible setspace commands are:

╔════════════╦════════════════════════════════════════════════════╗
║ Page count ║ setspace command                                   ║
╠════════════╬════════════════════════════════════════════════════╣
║         77 ║ \usepackage{setspace}\setdisplayskipstretch{}      ║
║         80 ║ Gonzalo Medina's answer using etoolbox             ║
║         81 ║ \usepackage[nodisplayskipstretch]{setspace}        ║
║         86 ║ \usepackage{setspace}                              ║
║         93 ║ \renewcommand{\baselinestretch}{2} % (no setspace) ║
╚════════════╩════════════════════════════════════════════════════╝



### Explanation

I will contrast \usepackage{setspace}\setdisplayskipstretch{} with \usepackage[nodisplayskipstretch]{setspace}. Looking into setspace.sty, we see the following relevant lines:

\newcommand{\displayskipstretch}{\baselinestretch}
\DeclareOption{nodisplayskipstretch}{\setdisplayskipstretch{1.0}}

\everydisplay\expandafter{%
\the\everydisplay
\abovedisplayskip \displayskipstretch\abovedisplayskip
\belowdisplayskip \displayskipstretch\belowdisplayskip
\abovedisplayshortskip \displayskipstretch\abovedisplayshortskip
\belowdisplayshortskip \displayskipstretch\belowdisplayshortskip
}


Therefore, the option nodisplayskipstretch is equivalent to setting the factor \displayskipstretch=1.0. One may expect that multiplying by 1 should do nothing, but of course TeX is not that simple. ;) The displayskip commands are <glue> types, which means they contain a ± range called "stretch and shrink." Multiplying by 1 removes the stretch and shrink, because it converts <glue> to <dimen>. Thus setspace normally clobbers TeX's built-in flexibility to shrink the gaps above and below equations. The \setdisplayskipstretch{} command prevents the multiplication, preserving the <glue> which allows the gaps to shrink. That's why the resulting page count is lower.

Many thanks to David Carlisle for explaining to me what was going on.