The booktabs package

Draws the horizontal rules of a table with correct thickness and spacing: \toprule, \midrule and \bottomrule.

Loading the package

\usepackage{booktabs}

\hline draws every line with the same thickness and puts it close to the text. booktabs replaces it with three rules: a thick one above the table, a thin one below the header and a thick one at the end.

The package is written for tables without vertical lines. Its rules leave a gap where a | in the column specification would cross them, so drop the |.

Main commands

\topruleThick rule above the table.
\midruleThin rule between header and body.
\bottomruleThick rule below the table.
\cmidrule(lr){2-3}Thin rule under columns 2 to 3, trimmed on the left and right.
\addlinespaceExtra vertical space between two rows.

Complete example

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{lrr}
\toprule
Material & Density & Price \\
\midrule
Steel    & 7.85 & 0.80 \\
Aluminum & 2.70 & 2.10 \\
\bottomrule
\end{tabular}
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages