6 Material tabular

Data is often most efficiently presented in tabular form. TEX uses powerful primitives for arranging material in rows and columns. Because they implement only a low-level, formatting-oriented functionality, several macro packages have been developed that build on those primitives to provide a higher-level command language and a more user-friendly interface. In Standard LaTEX, two types of environments for constructing tables are provided. Most commonly the tabular environment or its math-mode equivalent, the array environment, is used. However, in some circumstances the tabbing environment might prove useful.

Tables typically form large units of the document that must be allowed to “float” so that the document may be paginated correctly. The environments described in this chapter are principally concerned with the table layout. To achieve correct pagination they are often used within the table environment described in Chapter 7. Exceptions are the environments for multipage tables described in Section 6.4, which should never be used in conjunction with the LaTEX float mechanism. Be careful, however, not to confuse the tabular environment with the table environment. The former allows material to be aligned in columns, while the latter is a logical document element identifying its contents as belonging together and allowing the material to be floated jointly. In particular, one table environment can contain several tabular environments.

After taking a quick look at the tabbing environment, this chapter describes the extensions to LaTEX’s basic tabular and array environments provided by the array package. This package offers increased functionality, especially in terms of a more flexible positioning of paragraph material, a better control of inter-column and inter-row spacing, and the possibility of defining new preamble specifiers. Several packages build on the primitives provided by the array package to provide specific extra functionality. By combining the features in these packages, you are able to construct complex tables in a simple way. For example, the tabularx and tabulary packages provide extra column types that allow table column widths to be calculated automatically.

Standard LaTEX tabular environments do not produce tables that may be broken over a page. We give several examples of multipage tables using the supertabular, longtable, and xltabular environments provided by the similarly named packages. We then briefly look at the use of color in tables and at several packages that give finer control over rules, and the spacing around rules, in tables. Next, we discuss table entries spanning multiple rows, created via the multirow package, and packages that provide new column specifiers for special occasions, such as dcolumn and fcolumn, which provide mechanisms for aligning columns of figures on a decimal point.

We also discuss the use of footnotes in tables. The threeparttable package provides a convenient mechanism to have table notes and captions combined with a tabular layout.

The final section discusses the very interesting keyvaltable package that offers a completely different approach to inputting table data. In many cases it is superior to the traditional methods. It makes use of the other packages, e.g., xltabular, as its backend and so understanding their concepts and mechanisms is nevertheless useful.

Mathematically oriented readers should consult the chapter on advanced mathematics, especially Section 11.2 on page →II 131, which discusses the alignment structures for equations.