## Friday, October 2, 2009

### Getting publication quality tables is easy

One of the problems with reading about various aspects of typography is I start to see the short comings in other's work, and far more importantly, in my own. Creating tables is one area where this is certainly true. In my experience, nearly every document prepared with LaTeX that contains a table, contains an ugly table. I'm not sure what the reason for this is, but everybody seems to want to make tables that look like the following.
\begin{tabular}{|c|c|c|}
\hline
A & B & C\\
\hline\hline
foo & bar & baz\\
\hline
zab & rab & oof\\
\hline
\end{tabular}
(As usual, try this out here.) There's no reason at all for each cell to be boxed that way. I rather suspect this comes from looking at too many ugly HTML tables one gets by default. Fortunately, the solution is very simple. Use the booktabs package. I strongly encourage anyone writing a table to read the documentation (pdf). The use is very simple.
\begin{tabular}{ccc}
\toprule
A & B & C\\
\midrule
foo & bar & baz\\
zab & rab & oof\\
\bottomrule
\end{tabular}
(You'll need to select the booktabs package in the previewer above to try this out.) Notice that in addition to looking better, this actually requires less work to produce! There is a \cmidrule that works similar to \cline, but is more flexible and can actually be used in adjacent columns; however, I don't often find a use for any rules but the three above. Finally, the author of booktabs gives 2 guidelines for making publication quality tables. 1) Do not use vertical rules; and 2) Do not use double rules. These are excellent guidelines. Follow them.