6.4 Material tabular de varias páginas
With Leslie Lamport’s original implementation, a tabular environment must always fit on one page. If it becomes too large, the text overwrites the page’s bottom margin, and you get an Overfull message.
Two major packages are available to construct tables longer than one page, supertabular and longtable. They share a similar functionality but use rather different syntax and also produce noticeably different results. The longtable package uses a more complicated mechanism, working with TEX’s output routine to obtain optimal page breaks and to preserve the width of columns across all pages of a table. However, this mechanism may require the document to be processed several times before the correct cell widths are calculated. It also means that the package is incompatible with other packages manipulating the output routine.
The supertabular package essentially breaks the table into a sequence of page-sized tabular environments, and each page is then typeset separately. This approach does not require multiple passes and works in a larger range of circumstances, e.g., two-column or multi-column mode.
Neither supertabular nor longtable supports the X-notation of tabularx for automatically adjusting the column width to fit a given table width. This is provided by the xltabular package, which combines the features of longtable and tabularx.
6.4.1 supertabular - Hacer tablas de varias páginas
The package supertabular (originally created by Theo Jurriens and revised by Johannes Braams) defines the environment supertabular.
The package supertabular (originally created by Theo Jurriens and revised by Johannes Braams) defines the environment supertabular.
As pointed out at the beginning of this section, for more complex long tables, where you want to control the width of the table across page boundaries, the package longtable (by David Carlisle, with contributions from David Kastrup) should be considered. Like the supertabular environment, it shares some features with the table environment. In particular it uses the same counter, table, and has a similar
ommand. The
command lists tables produced by either the table or longtable environment.
The main difference between the supertabular and longtable environments is that the latter saves the information about the width of each longtable environ ment in the auxiliary .aux file. It then uses this information on a subsequent run to identify the widest column widths needed for the table in question. The use of the .aux file means that care should be taken when using the longtable in conjunction with the command. One effect of is to suppress the writing of the .aux file, so this command should not be used until after the final edits of that table have been made and the package has recorded the optimal column widths in the auxiliary file.
To compare the two packages, Example 6-4-1 on page 457 is repeated here, but now uses longtable rather than supertabular. You can see that the width of the table is identical on both pages (the left and right parts of the picture). Note that in longtable, most of the table specification is within the longtable environment; in supertabular the specification of the table headings occurs via commands executed before the supertabular environment.