Rules

There are three approaches to ruling a table. LaTeX’s built-in **\hline / \cline with the | column specifier; the booktabs** package (\toprule, \midrule, \bottomrule) for professional tables; and **hhline** for fine control over double rules and how they cross vertical lines. The standard rules are easy to reach for, but over-ruling makes a table hard to read. This page works through the three layers in turn and shows why booktabs is the recommended default.

Standard rules — \hline, \cline, |

The horizontal rule plain LaTeX gives you is **\hline**. Placed after a row’s \\ (or at the very top or bottom of the table), it draws a single line across the full width of the table. Two in a row, **\hline\hline, give a double horizontal rule** separated by \doublerulesep. The \\ after the last row may normally be omitted, but to draw an \hline below the last row you first close it with \\.

To rule only some columns partway through the table, use **\cline{i-j}**: the line spans columns i through j only, so \cline{2-3} rules just below columns 2 and 3. For several disjoint spans at once, list them, as in \cline{1-1}\cline{3-4}. Vertical rules are made not in the body but in the column specification: inserting | (a vertical bar) into the spec, as in {|l|c|r|}, puts a full-height vertical line at that point, and || gives a double vertical rule. The thickness of these |, \hline, and \vline lines is the length **\arrayrulewidth** (default 0.4pt), and the gap between paired rules is \doublerulesep.

latex
\begin{tabular}{|l|c|r|}
  \hline
  項目 & 個数 & 価格 \\
  \hline\hline
  りんご & 3 & 380 \\
  \cline{2-3}
  みかん & 12 & 120 \\
  \hline
\end{tabular}

This boxes every column with |, double-rules below the header with \hline\hline, and partially rules the middle with \cline{2-3} (columns 2 and 3 only). It exercises the full range of standard rules — and is, precisely, a specimen of the over-ruling you should avoid.

The reason is that heavy ruling hurts readability. In the typographic tradition, a rule is not a cage around the data but a restrained device that marks a logical division of information. Vertical rules in particular build visual walls between columns that impede the eye, and double rules look needlessly heavy for no gain. Simon Fear, author of the booktabs package discussed next, writes that this style of layout “has been established over centuries of experience and should only be altered in extraordinary circumstances,” and recommends spare, horizontal-only tables with neither vertical nor double rules.

booktabs — publication-quality tables

booktabs**, by Simon Fear, is a package for easily setting tables “as should appear in published scientific books and journals.” You load it with \usepackage{booktabs} in the preamble. What sets it apart from plain \hline is that it distinguishes rules by thickness and automatically inserts proper space above and below each rule. The result is a refined table whose structure reads clearly without any boxing.

Three commands are central: **\toprule at the very top of the table, \midrule where the heading meets the body, and \bottomrule** at the very bottom. \toprule and \bottomrule are set heavier (default \heavyrulewidth = 0.08em) and \midrule lighter (\lightrulewidth = 0.05em); this difference in thickness makes the outer edges and the internal division easy to tell apart at a glance. Each takes an optional width in brackets (e.g. \toprule[1pt]), and like \hline they go after a row’s \\ — except \toprule, which comes right after \begin{tabular}{…}.

latex
\begin{tabular}{@{}llr@{}}
  \toprule
  \multicolumn{2}{c}{品目} \\
  \cmidrule(lr){1-2}
  種類 & 状態 & 価格 \\
  \midrule
  りんご & 蜜入り & 380 \\
  みかん & 訳あり & 120 \\
  \addlinespace
  合計 & & 500 \\
  \bottomrule
\end{tabular}

This example gathers the booktabs elements. A rule over only some columns is **\cmidrule{a-b}**, the booktabs counterpart of \cline. But because a \cmidrule reaches the full column width and tends to crash into adjacent rules, you normally add a trim. In parentheses, (l), (r), or (lr) trims the left, right, or both ends by \cmidrulekern (default 0.5em), so (lr){1-2} rules columns 1–2 with both ends trimmed. The trim amount can be set explicitly, as in (r{.75em}). The full syntax is \cmidrule[width](trim){a-b}.

To put a little space between rows — before a totals row, say — place **\addlinespace** after the \\. By default it inserts \defaultaddspace (0.5em), and you can give an amount with \addlinespace[1ex]. It states intent more clearly than stretching one row with \\[…], and placed around a rule it controls the gap exactly. When you truly need to set the thickness and the space above and below all by hand, use **\specialrule{width}{above}{below}** (all three arguments mandatory) — a command for unusual situations; the three \toprule / \midrule / \bottomrule rules normally suffice.

The philosophy of booktabs is stated up front as two simple guidelines: “Never, ever use vertical rules” and “Never use double rules.” Fear writes that they “may seem extreme but I have never found a good argument in favour of breaking them.” If two halves of a table differ enough to want a dividing line, the answer is to use two tables rather than a vertical rule; above a totals row, a single \midrule is enough. By design the booktabs rules are built **not to connect with the | of the column spec** — that is a feature, meant to discourage vertical rules.

One more rule: **do not mix \hline with the booktabs rules**. Fear states plainly that they “are not guaranteed to work with \hline or \cline… I cannot foresee any reason to want to mix them.” Only in the exceptional case of stacking two \cmidrules at the same height for a double partial rule do you insert **\morecmidrules** between them (\cmidrule{1-2}\morecmidrules\cmidrule{1-2}). Since double rules are themselves discouraged, this too is not for everyday use.

CommandRoleDefault thickness / space
\topruleRule at the top of the tableWidth \heavyrulewidth = 0.08em
\midruleDivides heading from bodyWidth \lightrulewidth = 0.05em
\bottomruleRule at the bottom of the tableWidth \heavyrulewidth = 0.08em
\cmidrule(lr){a-b}Partial rule over columns a–bWidth \cmidrulewidth = 0.03em, trim \cmidrulekern = 0.5em
\addlinespaceExtra space between rows\defaultaddspace = 0.5em
\specialruleFully specified ruleAll three arguments mandatory

hhline — controlling how rules cross

hhline** (by David Carlisle, in LaTeX’s tools bundle) draws the same single and double horizontal rules as \hline but lets you control how they cross vertical rules. Load it with \usepackage{hhline}. With a plain \hline\hline double rule you cannot choose whether a vertical rule breaks at the crossing or runs through it; \hhline lets you specify this character by character. It earns its place when you genuinely must combine double or partial rules with vertical lines — situations the built-in commands handle poorly.

The argument to \hhline{…} is a list of tokens resembling a tabular column spec. The characters mean: **= a double horizontal rule the width of a column, - a single horizontal rule, ~ (tilde) a column with no rule. For verticals: | is a vertical line that cuts through the double (or single) rule, : is a vertical line broken by the double rule, and # is one segment of double rule between two vertical lines. There are also t (the top half of a double-rule segment) and b** (the bottom half) for building the corners of a double rule, used between two vertical rules (|t: is the top-left corner, :b| the bottom-right). The same ***{n}{…}** repeat form as in column specs is available.

Note that if you specify a double vertical rule (|| or ::), the \hhline horizontal rules break there. To run a horizontal rule through without breaking, use #, or omit the vertical-line specifiers altogether. Here is the example from the official documentation, exercising most of the features.

latex
\begin{tabular}{||cc||c|c||}
  \hhline{|t:==:t:==:t|}
  a & b & c & d \\
  \hhline{|:==:|~|~||}
  1 & 2 & 3 & 4 \\
  \hhline{#==#~|=#}
  i & j & k & l \\
  \hhline{||--||--||}
  w & x & y & z \\
  \hhline{|b:==:b:==:b|}
\end{tabular}

Here the top line |t:==:t:==:t| builds the top halves of the double rules and the vertical-line corners, and the bottom line |b:==:b:==:b| builds the bottom halves, so the double-rule frame joins cleanly with the vertical rules. The middle rows mix ~ (no rule) and # (a double-rule segment between verticals), varying row by row where the horizontal rules break and where they run through the verticals. Reproducing crossings this intricate with plain \hline / \cline is all but impossible, and hhline is exactly for this — detailing where double and vertical rules meet.

One technical note. An \hline is a single TeX \hrule, but an \hhline line is built from many small segments. They are placed accurately in the DVI, yet some viewers or drivers may not line the segments up exactly. If this bothers you, the documentation suggests trying a different driver, or slightly increasing \arrayrulewidth to reduce the effect.

Which to use

The conclusion is largely singular: **make booktabs your default for normal tables**. Just the three \toprule / \midrule / \bottomrule rules, plus a \cmidrule where needed, give the spare, readable tables you see in journals. Follow the “no vertical rules, no double rules” guidance and ruling stops being something you agonize over at all.

  • booktabs** — the first choice for nearly every table: horizontal rules only, tuned thickness and spacing, publication quality.
  • **Standard \hline / \cline / |** — handy because they need no package; good for grid-style tables or quick drafts. Beware over-ruling.
  • hhline** — only for the special case where you must finely control how double and vertical rules cross. Not for everyday use.

Before the rules themselves, how you align and separate columns sets the skeleton of a table. For the basics of the column spec see “The tabular environment,” and for \multicolumn, width specifiers, and other refinements see “Column specifiers in depth.”