# booktabs: What is the difference between \toprule and \hline

The horizontal lines in tabular environment can be constructed. What is the difference between \toprule, \midrule, \bottomrule and specifying horizontal line using \hline?

\toprule, \midrule and \bottomrule are improved versions of \hline; the standard \hline behaves (roughly) the same whether it is placed at the top, at the bottom or in the middle of a table. The improved versions \toprule and \bottomrule are thicker (in fact, \midrule is also slightly thicker) and they handle vertical spaces around them in a better way. As the documentation of booktabs states:

The routines described below are to enable the easy production of tables such as should appear in published scientific books and journals. What distinguishes these from plain LaTeX tables is the default use of additional space above and below rules, and rules of varying ‘thickness’.

Lines produced with \hline have a default width controlled by \arrayrulewidth which is set (by the standard classes) to 0.4pt. If you want to change the thickness, you need to set a different value for \arrayrulewidth.

On the other side, \toprule and \bottomrule have a default thicknes controlled by \heavyrulewidth which is set to 0.08em by default; the default thicknes for \midrule is given by the length \lightrulewidth, with an initial value of 0.05em. So, by default, \toprule and \bottomrule are approximately twice as thick as a line drawn with \hline and \midrule is slightly thicker than a line produced with \hline.

Additionally, \toprule, \midrule and \bottomrule have an optional argument

\toprule[<length>]
\bottomrule[<length>]
\middlerule[<length>]


allowing to easily modify their thickness.

The lines defined by booktabs also have a special management of the space below and above them; this space is controlled by the following lengths:

1. For \toprule: the space above is given by \abovetopsep (set to 0pt by default); the space below is given by \belowrulesep (default 0.65ex).

2. For \bottomrule: the space above is given by \aboverulesep (set to 0.4ex by default) and the space below is given by \belowbottomsep (default 0pt).

3. For \midrule, the space above is controlled by \aboverulesep and the space below is given by \belowrulesep.

The fact that the length parameters \heavyrulewidth, \lightrulewidth, and \cmidrulewidth are specified in fractions of em, and the spaces above and below the rules are given in fracions of ex, is very nice, typographically speaking, because the rule widths and their spacing increase automatically if the default font size is changed from 10pt to 11pt or 12pt. E.g., \heavyrulewidth is .8pt, .876pt, and .94pt, respectively, for default font sizes of 10pt, 11pt, and 12pt. This is a major difference to \hline, which equals 0.4pt by default regardless of the default font size.

The booktabs package also offers \cmidrule which is an improved version of the standard LaTeX \cline command designed to draw a sub-rule to extend over only some of the columns.

One of the disadvantages of the standard \cline command is that it draws a rule that extends to the full width of the columns specified in the argument, so two consecutive \clines will crash into each other (unless, for example, extra precaution is taken with \extracolsep). To easily prevent this crash, the improved \cmidrule offers optional trimming specifications; these specifications go in parentheses with no spaces separating them. The possible specifications are r, r{<length>}, l and l{<length>} (or any combination of these), where r and l indicate whether the right and/or left ends of the rule should be trimmed. The forms without explicit argument are equivalent to r{\cmidrulekern} and l{\cmidrulekern}, where \cmidrulekern defaults to 0.5em.For example,

\cmidrule(lr{.75em}){1-3}


gives a rule extending from column one to column three with a default left trim of 0.5em and 0.75em right trim.

\cmidrule has also an optional argument to change the thickness; the complete syntax is

\cmidrule[<length>](<trimming>){a–b}


The default value for <length> is \cmidrulewidth (0.03em); the last argument gives the column numbers to be spanned.

Even with simple tables you can see the difference between the results obtained using the default LaTeX \hline and the rules produced with the help of booktabs:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\noindent\begin{tabular}{*{3}{c}}
\hline
\hline
Column1a & Column2a & Column3a \\
Column1b & Column2b & Column3b \\
Column1c & Column2c & Column3c \\
Column1d & Column2d & Column3d \\
\hline
\begin{tabular}{*{3}{c}}
\toprule
\midrule
Column1a & Column2a & Column3a \\
Column1b & Column2b & Column3b \\
Column1c & Column2c & Column3c \\
Column1d & Column2d & Column3d \\
\bottomrule
\end{tabular}

\end{document}


• One can also trim them from either left or right with \cmidrule.
– user11232
Jan 27, 2014 at 4:59
• I would move the picture from the end nearer to the top in the "short answer". I actually think the picture is the shortest answer there is! Jan 29, 2014 at 9:17
• Is it also possible to specify the length of the rules? I need a midrule of length 7.34 cm, say. Jul 30, 2015 at 9:12