Equations and Double Spacing
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
\begin{equation}
a=b.
\end{equation}
\namdui
\end{document}
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]
\begin{equation}
a=b.
\end{equation}
\lipsum[2]
\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
\begin{equation}
a=b.
\end{equation}
\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}
\newcommand{\setdisplayskipstretch}[1]{\renewcommand{\displayskipstretch}{#1}}
\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.