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
\toprule | Thick rule above the table. |
\midrule | Thin rule between header and body. |
\bottomrule | Thick rule below the table. |
\cmidrule(lr){2-3} | Thin rule under columns 2 to 3, trimmed on the left and right. |
\addlinespace | Extra 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}Compiled with pdfLaTeX from TeX Live 2023.
Pitfalls
- Do not mix
\hlineand thebooktabsrules in one table; the spacing differs.
Related pages
- How-to Table borders and lines in LaTeX
- How-to Create a table in LaTeX
- Package
tabularx - How-to Table caption and label in LaTeX
- How-to Table across multiple pages in LaTeX
- How-to Footnotes in a table in LaTeX
- How-to Rotate a table in LaTeX
- How-to Row height and cell padding in LaTeX tables
- How-to Align numbers at the decimal point in LaTeX tables
- How-to Fit a table that is too wide in LaTeX