Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have used setspace with \spacing{1.9} to meet publisher specifications of "3 lines per inch or 12 lines per 10 cm", but it does not affect tables, although the publisher has requested that the spacing be applied to tables.

How can I apply this spacing to tables?

Here is an example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{setspace}
\begin{document}
\begin{spacing}{1.9}
\lipsum[1]
\begin{table}[ht]
\begin{tabular}{rlll}
  \hline
 & col1 & col2 & col3 \\ 
  \hline
  50 & 19 & 7 & 26 \\ 
  100 & 10 & 20 & 29 \\ 
  150 & 1 & 7 & 2 \\ 
  200 & 0 & 0 & 10 \\ 
\hline
\end{tabular}
\end{table}
\end{spacing}
\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The setspace package restores the normal \baselinestretch inside floats (and footnotes); you can override this decision by redefining \@xfloat:

\documentclass{article}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{lipsum}

\newcommand\Factor{1.9}

\makeatletter
\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
      \@parmoderr\@floatpenalty\z@
    \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
       \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
       \@tfor \@tempa :=#2\do
                        {\if\@tempa h\advance\@tempcnta \@ne\fi
                         \if\@tempa t\advance\@tempcnta \tw@\fi
                         \if\@tempa b\advance\@tempcnta 4\relax\fi
                         \if\@tempa p\advance\@tempcnta 8\relax\fi
         }\global\count\@currbox\@tempcnta}\@fltovf\fi
    \global\setbox\@currbox\vbox\bgroup
    \def\baselinestretch{\Factor}\@normalsize
    \boxmaxdepth\z@
    \hsize\columnwidth \@parboxrestore}
\makeatother

\begin{document}
\begin{spacing}{\Factor}
\lipsum[1]
\begin{table}[ht]
\begin{tabular}{rlll}
  \hline
 & col1 & col2 & col3 \\ 
  \hline
  50 & 19 & 7 & 26 \\ 
  100 & 10 & 20 & 29 \\ 
  150 & 1 & 7 & 2 \\ 
  200 & 0 & 0 & 10 \\ 
\hline
\end{tabular}
\end{table}
\end{spacing}
\end{document}

enter image description here

A shorter (and safer) possibility is to use the etoolbox package and its \AtBeginEnvironment command to add \doublespacing to the tabular environment:

\documentclass{article}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{etoolbox}
\usepackage{lipsum}

\AtBeginEnvironment{tabular}{\doublespacing}

\begin{document}
\begin{spacing}{1.9}
\lipsum[1]
\begin{table}[ht]
\begin{tabular}{rlll}
  \hline
 & col1 & col2 & col3 \\ 
  \hline
  50 & 19 & 7 & 26 \\ 
  100 & 10 & 20 & 29 \\ 
  150 & 1 & 7 & 2 \\ 
  200 & 0 & 0 & 10 \\ 
\hline
\end{tabular}
\end{table}
\end{spacing}
\end{document}
share|improve this answer
    
This doesn't seem to work with sidewaystable from the "rotating" package. I get ! Extra }, or forgotten \endgroup. \color@endbox ->\egroup. An example is here Any thoughts? –  David Aug 6 '12 at 14:35
    
@David I suggest you to open a follow-up question. –  Gonzalo Medina Aug 6 '12 at 14:36
    
Thanks, the followup, with the linked example from my previous comment, is here: tex.stackexchange.com/q/66070/1783 –  David Aug 6 '12 at 14:40
    
@David I've updated my answer; this new approach (with etoolbox) prevents the issue with sidewaystable. –  Gonzalo Medina Aug 6 '12 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.