Skip to main content

Section 4.14 (*) Tables and Tabulars

This section needs much more work, and we are slowly adding material as we work on features.

Note that tables may be constructed using the Complex Table Editor tool online at latex-tables.comand then exported in PreTeXt syntax.

Subsection 4.14.1 Placeholder

Best Practice 4.14.1. Tables are Difficult.

Width is always at a premium, and then when a <tabular> has more than a few columns, the width becomes even more dear. When a <cell> has text that looks like a phrase or a sentence, rather than numerical data or symbols, it can be even harder to pack it all in. A common example is a schedule of talks at a small professional conference where each time slot (rows) might have two or three talks simultaneously in parallel sessions (columns).

We offer paragraph cells which automatically break lines, but you need to specify a @width on the <col> as a percentage to indicate where line-breaking happens. For manual line-breaking, a <cell> can be structured entirely by <line> elements.

The next complication is that the used for PDF output tends to make columns as wide as necessary and will not break lines without the devices mentioned in the previous paragraph. The HTML output can sometimes be a bit more forgiving and flexible. So we suggest building the output first and getting that right, and then the HTML is likely to follow along and not need much futher refinement.

In contrast to most of PreTeXt, you may need to experiment, refine your approach, iterate, and maybe do things contrary to usual best practices elsewhere. For example, the clickables for URLs and knowls might need to be short and less-informative in order to save some width. Abbreviations, initialisms, and acronyms can also save some width.

Subsection 4.14.2 Table Headers

To achieve column headings, you indicate that a row contains headings. Typically, the contents of every cell in this row will then be rendered in bold, or some other style. The <row> element accepts a @header attribute with possible values of no (the default), yes, or vertical. The latter is useful if space is at a premium (which always seems to be the case with tables), and the cells of a column are narrow and the heading is long. The one restriction is that rows identified as having headers must be the initial (top) rows of the table and must be contiguous.