[Tex/LaTex] Use of \midrule in booktabs table

best practicesbooktabsrulestables

Are there any formal guidelines/suggestions on the use of \midrule inside a booktabs table with just rows of identically formatted data? The booktabs manual is very specific about vertical rules, stating that you should

[n]ever, ever use vertical rules.

But what about horizontal rules between data items of the same type?

This question occurred when deciding if a LaTeX table generator should insert \midrules between each line. The picture below (shamelessly stolen from there) shows the difference for the same data (but with slightly different formatting of the figures):

Different ways to format the same data

Best Answer

The \midrule instruction generates a horizontal line that's (i) a bit thinner than either \toprule or \bottomrule and (ii) provides some extra vertical spacing both above and below the rule. As such, a \midrule is best used to separate a table's header row(s) from the body of the table, and a table's body from the footer material (if present, of course).

If the table contains rows and rows of identically formatted data but no header or footer components, I would not use a \midrule at all. Inserting a \midrule between each and every row constitutes, to me at least, a violation of the spirit of the booktabs package that's nearly as egregious as using vertical rules. :-)

If it's absolutely necessary to provide some separation between the rows, I'd either adjust the amount of default vertical space or add a bit of extra vertical space -- via an instruction such as \\[0.5ex] -- after every fifth row or so. The amount of extra space will depend on the table's width: the wider the table, the more whitespace should be inserted after a group of rows.


Addendum: Here's a comparison of the look of the table you've linked to in your posting, first with all midrules present, and second with a midrule used only to separate the header material from the table's body. (I've also applied a few additional tweaks, such as inserting a touch of extra vertical space after the third row). I believe most readers will find the second table to be more readable -- and certainly much less cluttered -- than is the first.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\setlength\parindent{0pt} % just for this example
\begin{document}
\emph{Before: Lots of midrules}

\smallskip
\begin{tabular}{lrrrrrrrrrrr}
\toprule
  & mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb\\
\midrule
Mazda RX4 & 21.0 & 6 & 160 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4\\
\midrule
Mazda RX4 Wag & 21.0 & 6 & 160 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4\\
\midrule
Datsun 710 & 22.8 & 4 & 108 &  93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1\\
\midrule
Hornet 4 Drive & 21.4 & 6 & 258 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1\\
\midrule
Hornet Sportabout & 18.7 & 8 & 360 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2\\
\midrule
Valiant & 18.1 & 6 & 225 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1\\
\bottomrule
\end{tabular}

\bigskip
\emph{After: Only one midrule, and some additional tweaks}

\smallskip
\begin{tabular}{ @{} l *{7}{r} *{4}{c} @{} } 
\toprule
  & mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb\\
\midrule
Mazda RX4 & 21.0 & 6 & 160 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4\\
Mazda RX4 Wag & 21.0 & 6 & 160 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4\\
Datsun 710 & 22.8 & 4 & 108 &  93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1\\[0.6ex]
Hornet 4 Drive & 21.4 & 6 & 258 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1\\
Hornet Sportabout & 18.7 & 8 & 360 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2\\
Valiant & 18.1 & 6 & 225 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1\\
\bottomrule
\end{tabular}
\end{document}
Related Question