# Uneven spacing around blockquote

For my dissertation, which I am in the final stages of formatting, I am required to use double-spacing for the main text and single-spacing for blockquotes. But this has somehow produced the annoying result that the space before and the space after a blockquote are not the same size. Oh LaTeX experts, help me fix it!

Example code:

\documentclass[11pt,oneside]{book}
\usepackage[letterpaper]{geometry}

\usepackage{setspace}

\expandafter\def\expandafter\quote\expandafter{\quote\singlespacing}
\expandafter\def\expandafter\quotation\expandafter{\quotation\singlespacing}

\doublespacing
\parskip=0pt

\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{quotation}Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.  \end{quotation}
\lipsum[1]
\end{document}


Example image:

• Are you talking about your horizontal spacing, or vertical spacing? top space to big, bottom space too small etc. – A Feldman Apr 24 '16 at 22:45
• The reason I ask, is that when I compiled your MWE, the spacing looks good. – A Feldman Apr 24 '16 at 23:35
• Vertical spacing. Space above is larger than space below. If you draw a rectangle on the PDF to measure the space and then copy it you'll see the diff. (I assume it's because the previous is double spacedand blockquote is single space. So I could probably just add more vertical space below? But I don't know exactly how to do that or how much would make it precisely even.) – Joe M. Apr 25 '16 at 2:17
• You can use \vskip1in to add an inch, use a minus to subtract. Maybe you are detecting something having to do with tex using baseline skips, rather than otherwise. – A Feldman Apr 25 '16 at 2:18

The setspace package has a long history that dates back (perhaps with a different name, I don’t remember) to the late Eighties of the past century, to the ancient days of LaTeX 2.09 and TeX2; the comments at the beginning of setspace.sty witness to this, as well as to a long and not always linear incremental development, during which provisional solutions were being added to solve problems and bugs as they were reported. The comments also warn you that, even in the latest release (my version, distributed with TeX Live 2015, is copyrighted 2011), some issues may remain unresolved; in particular, lines 284–285 read

\begin{singlespace}\begin{quote} produces the wrong spacing before the quote (extra glue is inserted).

Indeed, the anomalous behavior complained about in the question comes, IMHO, out of a tiny bug in the \singlespacing command; I will try to analyze it in detail in this answer, and to propose a correction.

## Detailed analysis

Quoting again from the comments of setspace.sty, lines 54–58:

The extra \vskip in the definition of \singlespacing seems to make for a cleaner transition from multiple spacing back to single spacing. These did not appear warrranted [sic] for other size changes.

What is this about? Well, multiple spacing is achieved, obviously, by incrementing the leading between the lines, that is (Oxford Dictionary of English, as presented by the Dictionary application of Mac OS X), “the distance from the bottom of one line of type to the bottom of the next”. Now, (La)TeX applies the same leading not only to all lines of a given paragraph, but also between the first line of that paragraph and the last line of the previous one. This means that, when two successive paragraphs are typeset with different leadings, the leading between the last line of the first and the first line of the second will always be the same as the leading between the lines of the second paragraph. When you change from a smaller leading to a larger one, this looks right, but it does not the other way around (just think of it): in the latter case, it rather seems that the larger leading should be used between the two paragraphs too.

In an attempt to make up for this, the \singlespacing command adds an extra blank line, that has the new (single-line) leading both above and below itself:

\newcommand{\singlespacing}{%
\setstretch {\setspace@singlespace}%  normally 1
\vskip \baselineskip  % Correction for coming into singlespace
}


But this would yield the desired effect only if the “old” leading were exactly twice as tall as the “new” one; so:

• it evidently does not work when changing from \onehalfspacing to \singlespacing, as it is perhaps hinted at by the comment on lines 54–58;

• it doesn’t work even when changing from \doublespacing to \singlespacing, because the leading of the former style is not at all twice as much as the leading of the latter.

Indeed, what is normally considered “double spacing” is a spacing in which the baselines of text are separated by an amount of vertical space that is twice as much as the font size; for example, for a font size of 11 points, as it is in the question, the baselines should be 22 points apart. But the leading in \singlespacing conditions is already set to 120%—125% of the font size, e.g., to 13.6 points for a size of 11 points: setting the leading to twice as much would result in a leading of 27.2 point, that is, in almost “two-lines-and-a-half spacing”. For this reason, the setspace package implements \doublespace by setting the multiplication factor for the leading to values actually smaller than two:

\newcommand{\doublespacing}{%
\setstretch {1.667}%  default
\ifcase \@ptsize \relax % 10pt
\setstretch {1.667}%
\or % 11pt
\setstretch {1.618}%
\or % 12pt
\setstretch {1.655}%
\fi
}


As you see, for 11pt a multiplier of 1.618 is used (reminiscent of the golden ratio?), yielding an effective leading of 1.618 * 13.6pt = 22,0048pt, that is, almost exactly the double of the font size, as intended. In conclusion, the \vskip \baselineskip issued by the \singlespacing command turns out to be overcompensation, and this is precisely the source of the extra space that has been asked about.

We can easily confirm this by compiling a slightly modified version of the OP’s MWE:

\documentclass[11pt,oneside]{book}
\usepackage[letterpaper]{geometry}

\usepackage{setspace}

\expandafter\def\expandafter\quote\expandafter{\quote\singlespacing}
\expandafter\def\expandafter\quotation\expandafter{\quotation\singlespacing}

\doublespacing
\parskip=0pt

\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{quotation}
Curabitur dictum gravida mauris.  Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.  Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames
ac turpis egestas.
\end{quotation}
\lipsum[2]

\singlespacing

\lipsum[3]

\showboxdepth = 10
\showlists

\end{document}


This code produces the following output:

The tracing commands included near the end of the code write into the transcript file (among other things) detailed information about the space that goes between the lines. The beginning of this diagnostic tracing reads as follows:

### vertical mode entered at line 0
### current page:
\write-{}
\glue(\topskip) 3.39584
\hbox(7.60416+2.12917)x430.00462, glue set - 0.16643
.\hbox(0.0+0.0)x17.0
.\OT1/cmr/m/n/10.95 L
.\OT1/cmr/m/n/10.95 o
.\OT1/cmr/m/n/10.95 r
.\OT1/cmr/m/n/10.95 e
.\OT1/cmr/m/n/10.95 m
.\glue 3.65 plus 1.825 minus 1.21666


…96 lines omitted…

.\glue(\rightskip) 0.0
\penalty 150
\glue(\baselineskip) 12.27142
\hbox(7.60416+2.12917)x430.00462, glue set 0.52057
.\OT1/cmr/m/n/10.95 p
.\OT1/cmr/m/n/10.95 l
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 c


The \hbox that begins on the fifth line is the first typeset line of the first paragraph, which ends with .\glue(\rightskip) 0.0 about a hundred lines below; we can see that the depth of this line is 2.12917 (points). A \penalty 150 follows, coming from \clubpenalty, and then an “interline glue” of 12.27142 points (\glue(\baselineskip) 12.27142), which is precisely the vertical space that TeX inserts between two typeset lines to ensure that their respective baseline are as much apart as desired. Since the next typeset line, that begins with \hbox(7.60416+2.12917)x430.00462..., has a height of 7.60416 points, we see that TeX is assuming a leading of 2.12917 + 12.27142 + 7.60416 = 22,00475 points, as claimed above (within rounding errors.

Let‘s now have a look to the excerpt that corresponds to the beginning of the quotation environment:

\hbox(7.60416+2.12917)x430.00462, glue set 115.40472fil
.\OT1/cmr/m/n/10.95 s
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 g
.\OT1/cmr/m/n/10.95 i
.\OT1/cmr/m/n/10.95 t


…60 lines omitted…

.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 r
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 r
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 m
.\OT1/cmr/m/n/10.95 .
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
\penalty -51
\glue 12.0 plus 4.0 minus 6.0
\glue 13.6
\glue(\parskip) 0.0 plus 1.0
\glue(\baselineskip) 3.86668
\hbox(7.60416+2.12917)x375.2545, glue set 0.4625, shifted 27.37506


The \hbox whose contents begin with the five characters “s-a-g-i-t” and ends with “r-u-t-r-u-m” + other stuff + .\glue(\rightskip) 0.0 is the last typeset line of the first paragraph, immediately above the quotation; we report this line too, because we need to know that its depth is (again) 2.12917 points. After this box we find:

• \penalty -51 (bonus for breaking the page before the quotation);

• \glue 12.0 plus 4.0 minus 6.0 (vertical space inserted above quotations);

• \glue 13.6, which is the (over-)compensation inserted by the \singlespacing command for the change in the spacing;

• \glue(\parskip) 0.0 plus 1.0 (vertical space inserted between paragraphs);

• \glue(\baselineskip) 3.86668 (see below);

• \hbox(7.60416+2.12917)x375.2545..., which is the beginning of the box that contains the first typeset line of the quotation; note that its height is 7.60416 (points).

If we add to this height the depth of the previous line and the interline glue, we can check that the latter has been computed to attain a leading of 7.60416 + 2.12917 + 3.86668 = 13.60001 (always points), that is, within rounding errors, the “normal” (for an 11-point font) leading of 13.6 points. The overall distance between the baseline of the last line of the preceding paragraph and that of the first line of the quotation is 13.60001 + 13.6 + 12.0 ≈ 39.2 points (omitting stretch and shrink components); but it had better been 22.0048 + 12.0 ≈ 34.0 points, that is [“double-spacing” leading] + [space above quotation]. Note that the difference amounts to about 1.83mm, that is, enough to be clearly perceived.

To confirm that the distance should have been as much as just claimed, consider the transcript of what happens at the end of the quotation environment:

\hbox(7.60416+2.12917)x375.2545, glue set - 0.66791, shifted 27.37506
.\OT1/cmr/m/n/10.95 h
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 b
.\OT1/cmr/m/n/10.95 i


…85 lines omitted…

.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 s
.\OT1/cmr/m/n/10.95 .
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
\penalty -51
\glue 12.0 plus 4.0 minus 6.0
\glue(\parskip) 0.0
\glue(\baselineskip) 12.27142
\hbox(7.60416+2.12917)x430.00462, glue set - 0.10161
.\OT1/cmr/m/n/10.95 N
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 m
.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 d
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 i
.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 l
.\OT1/cmr/m/n/10.95 i
.\OT1/cmr/m/n/10.95 g
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 l
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 ,


Once again, the transcript starts with the beginning of the last line of the quotation (“h-a-b-i-…”), so that you can see that its depth is (once again) 2.12917 points, and finishes reporting the beginning of the first line of the paragraph that follows the quotation (“N-a-m [space] d-u-i [space] l-i-g-u-l-a [comma]…”, whose height is (this too) 7.60416 points. Analyzing this transcript along the lines given above, we can check that the \glue(\baselineskip) 12.27142 has been calculated for a leading of 2.12917 + 12.27142 + 7.60416 = 22,00475 points, exactly as between any two lines of a paragraph typeset while \doublespacing is in force (see above). Thus, the total distance between the baseline of the last line of the quotation and that of the first line of the ensuing paragraph is 22.00475 + 12.0 ≈ 34.0 points (instead of the 39.2 points that we found above the quotation).

You can similarly check that there is the same amount of excess space (overcompensation) before the last paragraph, where just a switch from \doublespacing to \singlespacing occurs, without the complication of a quotation environment being entered. The interline glue inserted before the first line of the last paragraph gives rise to a leading of 13.00001 points, and there is, an addition, the usual (buggy) vertical space of 13.6 points; once again, the total is (approximately) 27.2 points, instead of 22.0048, as it should be to replicate the leading between the two last lines of the preceding paragraph. Anyway, this excess space is clearly visible in the printout.

## Proposed correction

The correction we propose is a patch to the \singlespacing command; after that, the usual quote and quotation environment can be employed, giving the correct result. In the following code, this patch to \singlespacing is exactly the segment delimited by \makeatletter and \makeatother.

\documentclass[11pt,oneside]{book}
\usepackage[letterpaper]{geometry}
\usepackage{setspace}
\usepackage{lipsum}

\makeatletter

\renewcommand*\singlespacing{%
\par    % ensure vertical mode
\nobreak
\vskip -\baselineskip   % compensate for the fake line we added, but with
% above correction
}

\makeatother

% patch up the standard environments.
\newenvironment*{JoeMquote}{%
\singlespacing
\quote
}{\endquote}
\newenvironment*{JoeMquotation}{%
\singlespacing
\quotation
}{\endquotation}

\doublespacing
\setlength{\parskip}{0pt}

\begin{document}
\lipsum[1]
\begin{JoeMquotation}
Curabitur dictum gravida mauris.  Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.  Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames
ac turpis egestas.
\end{JoeMquotation}
\lipsum[2]

\singlespacing

\lipsum[3]

\showboxdepth = 10
\showlists

\end{document}


Note that we prefer to define two new environments, rather than changing the default ones. Indeed, this answer is about finding the exact compensation that yields the same vertical space above and below the quotation, not about how to incorporate this correction into the standard environments: the other answers have already taken care of explaining this.

The printout that this code produces is shown next: you can immediately check, at first sight, that this time the spacing looks correct.

The tracing written to the transcript file confirms that the spacing is indeed correct to the scaled point. This is the beginning of the quotation environment, including the last line above it:

\hbox(7.60416+2.12917)x430.00462, glue set 115.40472fil
.\OT1/cmr/m/n/10.95 s
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 g
.\OT1/cmr/m/n/10.95 i
.\OT1/cmr/m/n/10.95 t


…60 lines omitted…

.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 r
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 r
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 m
.\OT1/cmr/m/n/10.95 .
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
\glue(\baselineskip) 19.87558
\hbox(0.0+0.0)x0.0
\penalty 10000
\glue -13.6
\glue 0.0
\penalty -51
\glue 12.0 plus 4.0 minus 6.0
\glue(\parskip) 0.0 plus 1.0
\glue(\baselineskip) 5.99585
\hbox(7.60416+2.12917)x375.2545, glue set 0.4625, shifted 27.37506


The distance between the baseline of the last line of the preceding paragraph and the baseline of the first line of the quotation is 2.12917 + 19.87558 - 13.6 + 12.0 + 5.99585 + 7.60416 = 34.00476, which corresponds exactly, within rounding errors, to the expected value of [“double-spacing” leading] + [space above quotation] = 22.00475 + 12.0 = 34.00475. On the other hand, at the end of the quotation we find

\hbox(7.60416+2.12917)x375.2545, glue set - 0.66791, shifted 27.37506
.\OT1/cmr/m/n/10.95 h
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 b
.\OT1/cmr/m/n/10.95 i


…85 lines omitted…

.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 s
.\OT1/cmr/m/n/10.95 .
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
\penalty -51
\glue 12.0 plus 4.0 minus 6.0
\glue(\parskip) 0.0
\glue(\baselineskip) 12.27142
\hbox(7.60416+2.12917)x430.00462, glue set - 0.10161


(as usual, the beginning of the first line of the following paragraph is shown too). Here the distance between the two baselines is 2.12917 + 12.0 + 7.60416 + 12.27142 = 34.00475, exactly the same (as always, within rounding errors to the scaled point) as above the quotation.

The same (but without the \glue 12.0 plus 4.0 minus 6.0) happens at the \singlespacing change before the last paragraph, as you can check by yourself:

\hbox(7.31305+0.0)x430.00462, glue set 394.62999fil
.\OT1/cmr/m/n/10.95 m
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 r
.\OT1/cmr/m/n/10.95 i
.\OT1/cmr/m/n/10.95 s
.\OT1/cmr/m/n/10.95 .
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
\glue(\baselineskip) 22.00475
\hbox(0.0+0.0)x0.0
\penalty 10000
\glue -13.6
\glue 0.0
\glue(\parskip) 0.0
\glue(\baselineskip) 5.99585
\hbox(7.60416+2.12917)x430.00462, glue set 0.28633
.\hbox(0.0+0.0)x17.0
.\OT1/cmr/m/n/10.95 N
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 l
.\OT1/cmr/m/n/10.95 l
.\OT1/cmr/m/n/10.95 a
.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 m
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 l
.\OT1/cmr/m/n/10.95 e
.\OT1/cmr/m/n/10.95 s
.\OT1/cmr/m/n/10.95 u
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 d
.\OT1/cmr/m/n/10.95 a
.\glue 3.65 plus 1.825 minus 1.21666


A final remark: the correction should, and can, be implemented at a more general level, encompassing all possible cases of change of spacing. Rather that appending stray boxes and glue to the vertical list, a general algorithm should simply compute the difference between the old leading and the new one (the old minus the new) and, if this difference is positive, add a vertical space of exactly that amount.

• This answer is a tour de force of TeXnical prowess, and I believe is the real answer. Bravo! – A Feldman Apr 28 '16 at 20:10

It would be easier to use the patching commands provided by etoolbox, in particular \AtBeginEnvironment and \AfterEndEnvironment. For example as follows:

\documentclass[11pt,oneside]{book}

\usepackage[letterpaper]{geometry}

\usepackage{setspace,etoolbox}

\doublespacing
\parskip=0pt

\usepackage{lipsum}

\begin{document}

\lipsum[1]
\begin{quotation}Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.  \end{quotation}
\lipsum[1]
\end{document}


The definitions of quote and quotation are provided by the documentclass, in this case book.cls. Try texdoc book on your system which will lead you to their documentation. The details are the definitions are also discussed in What's the difference between the environments quote and quotation? . As you will see there are several parameters involved. Also the definition of \singlespacing from setspace.sty contains an explicit \vskip\baselineskip

If you want negative spaces in the above then use \vspace{-myamount}, rather than \addvspace. I suggest using quantities that are either multiples of \baselineskip or a certain number of ex's. That way the dimensions are computed from the document characteristics, rather than being absolute.

• Well, that certainly looks much more intuitive than all this \expandafter. I'll play around with it. Thanks! – Joe M. Apr 25 '16 at 14:07
• This looks like a good answer. It allows one to stay in the quotation environment yet manipulate the spacing. I assume this allows negative skip? – A Feldman Apr 25 '16 at 14:17
• Yes you can used negative skips, but use \vspace instead of \addvspace. – Andrew Swann Apr 25 '16 at 14:34

I think that you will just have to adjust your \vskip throughout your document. So to do that you can define a macro that does a quotation that includes the correct amount of vertical skip.

\documentclass[11pt,oneside]{book}
\usepackage[letterpaper]{geometry}

\usepackage{setspace}

\doublespacing
\parskip=0pt

\usepackage{lipsum}

%%To change the space after the quote adjust the \vskip below%%
%%Adjust the \hsize to change the width of the quote%%
\def\Quote#1{\hfil\vtop{\hsize=4.5in \singlespacing #1}%
\hfil\vskip.4in\par\doublespacing}

\begin{document}

\lipsum[1]

\Quote{Painting the roses red;We're painting the roses red;%
We dare not stop;Or waste a drop;So let the paint be spread;%
We're painting the roses red;We're painting the roses red;%
Oh, painting the roses red;And many a tear we shed; Because we know;%
They'll cease to grow;In fact, they'll soon be dead;And yet we go ahead;%
Painting the roses red;Painting the roses red;We're painting the roses
red; Oh, pardon me;But Mister Three; Why must you paint them red?}

\lipsum[1]

\end{document}


Thanks for the suggestions, guys. I've got it as close as I can with the following code:

\expandafter\def\expandafter\quote\expandafter{\quote\vskip-1.8mm\singlespacing}


After I figured out how to add the negative vskip it was just a question of tinkering with the value until it produced as close as I could figure to an even spacing. I'd prefer a less-hackish solution that produced the same vertical spacing, but I'm not LaTeX-savvy enough to make defining a whole new quote environment work for me without a lot of extra work. So this'll do.

One remaining question: the adjustment to the vskip applies to before the blockquote, but I coudn't figure out how to make it apply after (so I was constrained to shrinking the larger space before rather than expanding the smaller space after; don't know which I'd prefer, but this was my only option). Any suggestion on how to do that? I really don't know what I'm doing with \expandafter, so I'm just blundering about amateurishly.

• See my above answer, it sets your quote to single space, sets the margin on both sides, applies the \vskip after the paragraph and afterward reverts you to double spaced text. By adjusting the \vskip and \hsize numbers you can use it to adjust any quoted material within brackets of the the \Quote{} command. – A Feldman Apr 25 '16 at 13:55
• It's a great suggestion! It won't work for me for a few reasons, however, that are specific to my situation (not a problem with what you've suggested). E.g., (1) I'm doing final formatting on a 50,000 word dissertation and I really would rather not go through and replace every \begin{quotation}, \end{quotation}, \begin{quote}, \end{quote} with a redefined \Quote{...}; (2) I'm not confident I could get the definition to look precisely the way I want it too, at least not without considerable tinkering. So right now I'm going for the lowest-time-cost solution. :-) – Joe M. Apr 25 '16 at 13:57
• I get your drift... Didn't know that you were in the final formatting stage. I guess that means in order to deal with your problem you have to re-define your quotation environment. Are you using the package csquotes? – A Feldman Apr 25 '16 at 14:01