# Extra blank line when using setspace, wrapfig, and pgfplotstable

New to LaTex here. I'm sorry if my example text isn't the most minimum it can be.

I need to be able to write documents that are doublespaced, have tables that are single spaced which are inputted from .csv files, and wrap text around the tables.

To that end, I'm using the setspace, wrapfig, and pgfplotstable packages, but when I switch from single space for the tabular back to double space for the text, I get a line break that is triple spaced. How can I fix this?

Thank you.

\documentclass[12pt]{article}%

\usepackage[doublespacing]{setspace}
\usepackage{wrapfig}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{colortbl}
\usepackage{epstopdf}
\usepackage{caption}

\geometry{left=1in,right=1in,top=1.00in,bottom=1.0in}

\begin{document}

\noindent I have things to say. Important things. Very very very very very very very very very imporant things. My repec score is a billion gagillion trillion. I have things to say. Important things. Very very very very very very very very very imporant things. My repec score is a billion2

\singlespacing

\begin{wraptable}{o}{4.25in}
\captionsetup{singlelinecheck = false, justification=justified, format=hang}
\caption{Statistic, Variable}
\label{tab:1}
\scriptsize
\pgfplotstabletypeset[
col sep=semicolon,
string type,
%   column type=c,
before row={\toprule}, after row=\midrule,},
every row no 0/.style={before row={\multicolumn{8}{l}{\textit{All}} \\ },
after row={\multicolumn{8}{l}{} \\ },},
every row no 1/.style={before row={\multicolumn{8}{l}{\textit{Sub group 1}} \\ }, },
every row no 2/.style={after row={\multicolumn{8}{l}{\textit{}} \\ }, },
every row no 3/.style={before row={\multicolumn{8}{l}{\textit{Sub group 2}} \\}, },
every row no 6/.style={after row={\multicolumn{8}{l}{\textit{}} \\ }, },
every row no 7/.style={before row={\multicolumn{8}{l}{\textit{Sub group 3}} \\}, },
every row no 8/.style={after row={\multicolumn{8}{l}{\textit{}} \\ }, },
every row no 9/.style={before row={\multicolumn{8}{l}{\textit{Included Covariates:}} \\ }, },
every last row/.style={
after row={
\bottomrule
\multicolumn{8}{p{3.6in}}{Note:} },
},
columns/r0/.style={column name=, column type=l},
columns/r1/.style={column name=(73), column type=c},
columns/r2/.style={column name=\textbf{(74)}, column type=c},
columns/r3/.style={column name=(75), column type=c},
columns/r4/.style={column name=(76), column type=c},
columns/r5/.style={column name=\textbf{(77)}, column type=c},
columns/r6/.style={column name=\textbf{(78)}, column type=c},
columns/r7/.style={column name=(79), column type=c},
]{example.csv}
\end{wraptable}

\doublespacing

\noindent gagillion trillion. I have things to say. Important things. Very very very very very very very very very imporant things. My repec score is a billion3. I have things to say. Important things. Very very very very very very very very very imporant things. My repec score is a billion4. I have things to say. Important things. Very very very very very very very very very imporant things. My repec score is a billion5.

\end{document}


• Welcome to tex.sx. When you switch back to \doublespacing, you follow that by a blank line. Try omitting that blank line. (don't have the ability at the moment to test, so this is a guess.) – barbara beeton Oct 18 '19 at 0:25
• Unfortunately that blank line has no effect. – Kramer Oct 18 '19 at 0:39
• Have you tried moving the \singlespacing command inside the wraptable environment? – barbara beeton Oct 18 '19 at 1:36
• OMG. That works. Thank you so much. – Kramer Oct 18 '19 at 2:46

Most LaTeX environments are identified (and input) with \begin{<envname>} ... \end{<envname>}, and are defined as "local groups". When a group is entered, the attributes of the surrounding environment are saved, and restored when the local group is exited/ended. So it is almost always safe to enclose a "shape" change in a closed environment with the expectation that this change will disappear when the \end is processed.
In the present case, entering \singlespacing immediately after \begin{wraptable}` should have the desired result.