Skip to main content

The PreTeXt Guide

Subsection 4.18.6 Table Borders and Rules

You can view each cell of your table as having four borders. Or you can imagine rows and columns separated by horizontal or vertical rules. These additions to your table do not change the arrangement of information into rows and columns (a doubly-indexed data set), though you may think it makes the presentation clearer. But less is actually more.

Best Practice 4.18.6.1. Vertical Rules in Tables.

One of the goals of PreTeXt is to gently guide authors towards good choices in the design of their documents, even if we do not claim to know it all ourselves. Take a close look at Table 4.1.4.3. What’s missing? No vertical rules. Try living without them, you will not really miss them. If you think you need to divide a table into two halves, maybe you really need two tables (and then see the “side-by-side” capabilities, Section 4.22).
In the documentation for his excellent package, booktabs 2 , Simon Fear gives two rules for what he calls “formal tables”: (1) Never, ever use vertical rules, and (2) Never use double rules. We have resisted the temptation to enforce the former and have provided an alternative to the second (three thicknesses). He refers to using tables for layout as creating “tableau.” If you are finicky about the look of your work, the first three pages of the documentation is recommended reading.
A given <cell> can have a border on its bottom edge, and on its right edge. This is accomplished with the @bottom and @right attributes. The possible values are minor, medium, and major, which control thickness. (Not every conversion can produce three distinct thicknesses, so this should be considered a hint to the conversion.) A value of none is the default behavior when the attribute is not used, but can be given explicitly.
How to get a left border on the first cell of a row? The <row> element allows a @left attribute which will put a border on the left end of the row, which is also the left border of the first cell.
How to get a top border on a cell? Put a bottom border on the cell above it. But what if the cell is already in the top row and has no cell above it? The relevant <col> element allows a @top attribute which will place the necessary border on the top-row cell.
Borders and rules verge on presentation, so we are not concerned about which cell a border (or rule) belongs to. So, generally @bottom and @right can be used in many places, and the exceptional @top and @bottom maybe used to get the missing border \(n+1\) for a vertical or horizontal sequence of \(n\) cells.
The attributes described for cells may also be used on <row>, <col>, and <tabular>. For example a thick horizontal rule after two rows of headers could be accomplished with
<row header="yes">...</row>
<row header="yes" bottom="major">...</row>
We will not detail all the combinations that are possible, so experiment and you should be able to create any rational look (and some irrational ones).
www.ctan.org/pkg/booktabs