Goals:
- Add a space above and below the text line containing the Table 1's column headers.
- Add a space below the second hline.
- Add a space above the third hline.
The code below contains the original table (#1) along with several failed attempts (#2,#3,#4)to accomplish the above mentioned goals.
Additional details:
-
I am using
pdflatex
to render the.tex
file -
I am using the
tabularx
package. -
I am using
xtable()
in R to build the.tex
for these tables, but it's not necessary to answer the question withxtable
options since I can edit the.tex
after using R.
Any help would be greatly appreciated. Suggestions?
%%%%%%%%%%
\documentclass{article}
\usepackage{graphicx}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage[labelfont=sf,hypcap=false,format=hang,width=1\columnwidth]{caption}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=3cm,rmargin=3cm}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{array}
\begin{document}
%%%%%%%%%%
\title{Understanding Tables: Vertical Spacing}
\author{Brian}
\maketitle
This report is designed to be a quick resource for editing the vertical spacing in 'tabularx' tables. \\
\begin{table}[ht]
\captionof{table}{Original}
\centering
\begin{tabular}{lrrrrrr}
\hline
Type & Total & Mean & Median & Stdev & Min & Max \\
\hline
Test1 & 490 & 15 & 8 & 24 & 1 & 115 \\
Test2 & 52610 & 1697 & 1620 & 430 & 920 & 2850 \\
\hline
\end{tabular}
\end{table}
{\renewcommand{\arraystretch}{2}%
\begin{table}[ht]
\captionof{table}{Spaceing stretched above and below ALL cells}
\centering
\begin{tabular}{lrrrrrr}
\hline
Type & Total & Mean & Median & Stdev & Min & Max \\
\hline
Test1 & 490 & 15 & 8 & 24 & 1 & 115 \\
Test2 & 52610 & 1697 & 1620 & 430 & 920 & 2850 \\
\hline
\end{tabular}
\end{table}}
\begin{table}[ht]
\captionof{table}{Spacing streched ABOVE header}
\centering
\begin{tabular}{lrrrrrr}
\hline
\rule{0pt}{4ex}Type & Total & Mean & Median & Stdev & Min & Max \\
\hline
Test1 & 490 & 15 & 8 & 24 & 1 & 115 \\
Test2 & 52610 & 1697 & 1620 & 430 & 920 & 2850 \\
\hline
\end{tabular}
\end{table}
\begin{table}[ht]
\captionof{table}{Spacing streched ABOVE ALL cells}
\centering
\setlength\extrarowheight{14pt}
\begin{tabular}{lrrrrrr}
\hline
Type & Total & Mean & Median & Stdev & Min & Max \\
\hline
Test1 & 490 & 15 & 8 & 24 & 1 & 115 \\
Test2 & 52610 & 1697 & 1620 & 430 & 920 & 2850 \\
\hline
\end{tabular}
\end{table}
\end{document}
Best Answer
Your approach here (in terms of horizontal rules) matches that of what is suggested by
booktabs
. Here's what I would use:booktabs
'\toprule
,\midrule
and\bottomrule
inserts additional (white) rules to separate the text around these rules a little. This, together with the use of an increased\arraystretch
seems sufficient to obtain a breathable result.