# How to remove Double spacing in Table “Cell Wrap”?

Assume I have a text with double spacing. Now to visualize table cell wrap (automated table cell wrap is not possible in Latex as far as I know), I want to space this "cell wrap" with single spacing. "Real new lines" of the table still keep double spacing ("the default" eg defined in class).

How to do this? I tried setting \singlespacing within the table. However this does not work (complaining about missing endGroup).

I found out how to turn the whole table to singlespacing (bringing this singlespacing group outside the table), however I still want to use doublespacing for 'new table lines'.

PS: I do not want a line to visualize breaks in a table.

Screenshot and MWE attached:

MWE

\documentclass{article}
\usepackage{setspace}
\usepackage{booktabs}
\begin{document}
\doublespacing
\section{Text}
Test2\\
Test1
\section{Table}
\begin{tabular}{ll}
\toprule
\textbf{Key} & \textbf{Value} \\
\midrule
Category & Line1 \\
LongLabel:  & Line2 \\
Category2: & Line1 \\
& Line2 \\
\bottomrule
\end{tabular}
\end{document}

• Thanks, however a changed version from Steven below is simpler (\begin(singlespacing) <table with [1em] breaks> \end(singlespacing)) – robert Aug 4 '15 at 18:59

You can define command to be added before and after environment definitions so you can manually add \begin{singlespace} before your \begin{tabular} and \end{singlespace} after your \end{tabular}.

Alternatively, using the etoolbox package, you can add a couple of lines in your preamble that will do this for you every time you add a table. You can then specify the spacing by hand for the one you want to be bigger with the optional \\[height]:

\documentclass{article}
\usepackage{setspace}
\usepackage{booktabs}

\usepackage{etoolbox}
\BeforeBeginEnvironment{tabular}{\begin{singlespace}}
\AfterEndEnvironment{tabular}{\end{singlespace}}

\begin{document}
\doublespacing
\section{Text}
Test2\\
Test1
\section{Table}
\begin{tabular}{ll}
\toprule
\textbf{Key} & \textbf{Value} \\
\midrule
Category & Line1 \\
LongLabel:  & Line2 \\[1em]
Category2: & Line1 \\
& Line2 \\
\bottomrule
\end{tabular}
\end{document}


• Thanks I implemted this as (\begin(singlespacing) <table with [1em] breaks> \end(singlespacing)) – robert Aug 4 '15 at 18:59
• Unless you only have one table in your document, it might be easier to use the preamble version. Tables look a lot nicer in singlespace mode (although this may be a personal preference). Additionally, since you are using booktabs, the package defines the command \addlinespace which you can insert before (or after) any row in a table. The default spacing is a lot more appropriate that my random 1em so you might want to give that a try. – ArTourter Aug 4 '15 at 23:39

While the easiest modification to the OP's MWE would be to add [-10pt] to the end of the two Line1 \\ lines, here is an alternative...

One could use stacks.

Case 1: If the stacks are limited to two rows...

\documentclass{article}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{stackengine}
\renewcommand\stacktype{L}% LONG STACKS ARE THE DEFAULT
\renewcommand\stackalignment{l}% LEFT ALIGNED ARE THE DEFAULT
\setstackgap{L}{11pt}% THIS IS THE VERTICAL BASELINESKIP IN LONG STACKS
\begin{document}
\doublespacing
\section{Text}
Test2\\
Test1
\section{Table}
\begin{tabular}{ll}
\toprule
\textbf{Key} & \textbf{Value} \\
\midrule
\stackunder{Category}{Longlabel} & \stackunder{Line1}{Line2} \\
Category2: & \stackunder{Line1}{Line2} \\
\bottomrule
\end{tabular}
\end{document}


Case 2: If the entries were many-lined, then this alternate syntax would facilitate things:

\documentclass{article}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{stackengine}
\setstackEOL{\#}% LINE SEPARATOR IN STACK (\\ CONFLICTS WITH TABULAR USE)
\renewcommand\stacktype{L}% LONG STACKS ARE THE DEFAULT
\setstackgap{L}{11pt}% THIS IS THE VERTICAL BASELINESKIP IN LONG STACKS
\begin{document}
\doublespacing
\section{Text}
Test2\\
Test1
\section{Table}
\begin{tabular}{ll}
\toprule
\textbf{Key} & \textbf{Value} \\
\midrule
\Longunderstack[l]{Category\# Longlabel\# Longer Label} &
\Longunderstack[l]{Line1\# Line2} \\
Category2: & \Longunderstack[l]{Line 1\# Line 2\# ...\# Line 13} \\
\bottomrule
\end{tabular}
\end{document}