Professional-looking tables in LaTeX with booktabs

Help centre › LaTeX › Tables · Packages: booktabs

Load \usepackage{booktabs} and use \toprule at the top, \midrule under the header and \bottomrule at the end, with \cmidrule(lr){2-3} under grouped headings, and no vertical lines. booktabs gives the rules the right weights and space above and below them, which \hline lacks.

A complete example

A whole document: paste it into an empty project and compile it.

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
  \centering
  \caption{Mean response time (ms) by condition.}\label{tab:rt}
  \begin{tabular}{lrrrr}
    \toprule
    & \multicolumn{2}{c}{Session 1} & \multicolumn{2}{c}{Session 2} \\
    \cmidrule(lr){2-3} \cmidrule(lr){4-5}
    Condition & Mean & SD & Mean & SD \\
    \midrule
    Congruent   & 512 & 48 & 498 & 45 \\
    Incongruent & 587 & 61 & 560 & 57 \\
    \addlinespace
    Neutral     & 530 & 52 & 515 & 50 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

The commands

  • \toprule, \midrule, \bottomrule: the top rule (heavier), the rule under the header (lighter), the bottom rule (heavier). Each takes an optional thickness, such as \toprule[1pt].
  • \cmidrule(lr){2-3}: a rule under columns 2 to 3 only, under a grouped heading. (lr) trims both ends slightly so neighboring partial rules do not join; (l) or (r) trims one end.
  • \addlinespace: a little vertical space between groups of rows, instead of another rule.
  • \specialrule{1pt}{2pt}{2pt}: a rule of any thickness with any space above and below.

The rules of a good table

  • No vertical lines. The columns' alignment separates them; vertical lines also break booktabs rules into pieces.
  • Three horizontal rules are usually enough. Separate groups of rows with \addlinespace, or a \midrule when the groups are truly different.
  • Units in the header ("Time (ms)"), not repeated in every cell.
  • Numbers right-aligned or aligned on the decimal point, with the same number of decimals in a column.
  • The caption above the table, which is the convention for tables in most styles.

Aligning numbers on the decimal point

The siunitx package's S column aligns numbers on their decimal point and can round them. Put text cells, such as headings, in braces so they are not read as numbers.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{l S[table-format=2.3] S[table-format=1.2]}
  \toprule
  Parameter & {Estimate} & {SE} \\
  \midrule
  Intercept & 12.405 & 0.81 \\
  Age       & 0.32   & 0.04 \\
  Dose      & -1.7   & 0.33 \\
  \bottomrule
\end{tabular}
\end{document}

Common mistakes

In journal templates

Errors you may meet

In Manulyx

Insert → Table puts a table environment in place, and pasting a range copied from a spreadsheet (two or more rows and columns) goes in as a LaTeX table, with booktabs rules when the paper loads booktabs and \hline otherwise; a notice offers the plain text back.

Write in Manulyx for free · Journal templates

Related

The examples on this page were compiled with pdfLaTeX to check that they work as shown. LaTeX quick reference · LaTeX errors explained