3

I am trying to achieve what is written in here: Equations and Double Spacing

However, my "larger" displayed equations and aligned environments still seem to have added space above.

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

\newcommand{\beq}{\begin{equation}}
\newcommand{\eeq}{\end{equation}}

\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}
Q_k(x)=\sum_{j=0}^{[k/2]} \frac{(-1)^j}{j!(k-2j)!2^{k-j}}. 
\end{equation}
\lipsum[2]
\begin{equation}
6x+7=5.
\end{equation}
\lipsum[2]

\newpage
\lipsum[2]
\begin{align}
5x
&=9x+8 \\
&=4x+3 \\
&=2x
\end{align}
\lipsum[2]
\begin{align}
Q_{k+2n}^{(k)}(0)
&=\sum_{j=0}^{[(k+2n)/2]} \\
&=\sum_{j=0}^{n} \frac{(-1)^j}{j!(k+2(n-j))!2^{k+n+(n-j)}} \\
&=\sum_{j=0}^{n} \frac{(-1)^{n-j}}{(n-j)!(k+2j)!2^{k+n+j}} \\
&=\sum_{j=0}^{n} \frac{(-1)^{n-j}}{(n-j)!(k+2j)!2^{k+n+j}}
\end{align}
\lipsum[2]

\end{document} 

Help. Thanks in advance.

Another example to demonstrate the spacing issue.

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

\doublespacing

\makeatletter
\preto{\spread@equation}{\linespread{1}\selectfont}
\makeatother

\begin{document}
MMMMMMMMMMMMMMMMMMMMMM.
\begin{equation}
6x+7=5.
\end{equation}
MMMMMMMMMMMMMMMMMMMMMM.
\begin{align}
5x
&=9x+8 \\
&\nonumber\\
&=4x+3 \\
&\nonumber\\
&=2x
\end{align}
MMMMMMMMMMMMMMMMMMMMMM.
\end{document}
Bobby Ocean
  • 855
  • 1
  • 8
  • 12
  • 1
    Have you tried loading the setspace package with the option nodisplayskipstretch? – Mico Sep 07 '14 at 21:56
  • Yes, that seems to remove a little extra space around the equations/aligns, but it doesn't let equations/aligns behave equally with spacing. – Bobby Ocean Sep 07 '14 at 22:01
  • @Mico Oh my, scratch my last comment. I forgot to remove \preto line before calling the nodisplayskipstretch. Why wasn't that selected as the answer in the other problem? Thank you seems to be working fine now. – Bobby Ocean Sep 07 '14 at 22:10
  • By the way, your MWE might be more representative of real spacing issues if you used \lipsum*[2] instead of \lipsum[2] -- the latter (which is what you're using now) inserts a paragraph break at the end, which is typically not good practice when typesetting equations. If you go with \lipsum*[2], you'll see that some of the serious problem in the MWE disappear on the their own. – Mico Sep 07 '14 at 22:24

1 Answers1

2

The simplest solution is to redefine \spread@equation so that it calls \linespread{1}\selectfont, which is only done in multiline displays.

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

\doublespacing

\makeatletter
\preto{\spread@equation}{\linespread{1}\selectfont}
\makeatother

\begin{document}
\lipsum*[2]%<--------------- \lipsum* won't end a paragraph
\begin{equation}
Q_k(x)=\sum_{j=0}^{[k/2]} \frac{(-1)^j}{j!(k-2j)!2^{k-j}}. 
\end{equation}
\lipsum*[2]
\begin{equation}
6x+7=5.
\end{equation}
\lipsum[2]

\lipsum*[2]
\begin{align}
5x
&=9x+8 \\
&=4x+3 \\
&=2x
\end{align}
\lipsum*[2]
\begin{align}
Q_{k+2n}^{(k)}(0)
&=\sum_{j=0}^{[(k+2n)/2]} \\
&=\sum_{j=0}^{n} \frac{(-1)^j}{j!(k+2(n-j))!2^{k+n+(n-j)}} \\
&=\sum_{j=0}^{n} \frac{(-1)^{n-j}}{(n-j)!(k+2j)!2^{k+n+j}} \\
&=\sum_{j=0}^{n} \frac{(-1)^{n-j}}{(n-j)!(k+2j)!2^{k+n+j}}
\end{align}
\lipsum[2]

\end{document}

First align

enter image description here

Second align

enter image description here

egreg
  • 1,121,712
  • This answer seems to reverse the problem. Now the smaller equation/align have extra space below them. Is there a reason for this? – Bobby Ocean Sep 07 '14 at 05:00
  • Upon further investigations it only seems that "align" with "small" formulas is adding the extra space. – Bobby Ocean Sep 07 '14 at 05:16
  • I am also noticing an additional issue: If a the line before a displayed equation has one-two words, then the displayed extra has reduced space around it (above and below), but if the line before a displayed equation extends across the page, then the displayed equation has proper spacing. – Bobby Ocean Sep 07 '14 at 05:23
  • @BobbyOcean If the last line above a display is short, then \abovedisplayshortskip and \belowdisplayshortskip below are used for the vertical space. Look for those on the site. My opinion is that you shouldn't worry: double spaced typesetting is irremediably ugly. – egreg Sep 07 '14 at 09:19
  • While I agree double spacing is "irremediably ugly" I am required to produce and publish my dissertation with it (certainly an irritating requirement). Since, I demand perfection from myself, then I must get these spacing issues resolved. So, I can't settle for "oh well, that's the best I can do". Your explanation of "\abovediplayshortskip" explains my second comment-question, however I am still concerned about the extra space added in the "align" equation from your example. Why are small-align-equations receiving added space below them? – Bobby Ocean Sep 07 '14 at 21:29
  • @BobbyOcean The space is the same, it's just that the second display fills the available vertical space in lines. – egreg Sep 07 '14 at 21:31
  • I still don't understand. If I pull out a ruler and physically measure, say above and below the equation number (which is supposed to be centered on the equation line) then (3) and (5) have different spacing above and below, while (6) and (9) have the same spacing? – Bobby Ocean Sep 07 '14 at 21:34
  • @BobbyOcean This is just apparent; the second set of equations has a very high term in the top line. – egreg Sep 07 '14 at 21:39
  • You are right about the two align-equations. However, an equation environment gives different spacing to an align environment, see the added example above. Equation (2) seems to have less space above it than equation (1). – Bobby Ocean Sep 07 '14 at 21:53
  • @BobbyOcean That's due to \abovedisplayshortskip/\belowdisplayshortskip used when the line preceding the display is short. See http://tex.stackexchange.com/questions/198859/increasing-vertical-space-after-equation-in-paragraph-with-short-previous-line – egreg Sep 07 '14 at 22:11