Ceci est une ancienne révision du document !
Last time the column was about tabs and tables. One of the big drawbacks with default tables is they cannot extend over the end of a page. An author is limited to tables that are one page or less in size. If a tabular environment extends beyond the limits of one page the extra content overwrites the page’s bottom margin and gives an Overfull \vbox message when compiled. Two packages have been built to overcome this difficulty: supertabular and longtable. They have different features and have their own strengths and weaknesses (as is true of all packages).
Supertabular evaluates the amount of used space every time it encounters a
command (remember
tells Latex – Tex to insert a line break and carriage return). When the amount of used space equals the allowed text height, then supertabular closes the tabular environment, starts a new page with the appropriate header and then re-opens the tabular environment. This method implies that column widths (and the corresponding table width) can vary from page to page. Because supertabular uses an estimate of the content-free space available on a page, this estimate can sometimes be wrong. There are ways to control both row-height and column-width to prevent situations in which the table width varies from page to page, or to prevent the last row of a table from being placed on a page by itself.
Note: Because page breaks occur only after a
command, page breaks in a table must occur between rows and cannot occur inside a row.
Supertabular is an environment that first requires the package to be loaded, and then requires the environment to be started. It also requires the environment to be closed. There are four somewhat different commands which can be used to begin the environment depending on the needs of the author.
\begin{supertabular}{colspec}
\begin{supertabular*}{width}{colspec}
\begin{mpsupertabular}{colspec}
\begin{mpsupertabular*}{width}{colspec}
colspec is set up the same way as the tabular environment. It indicates how many columns, what the alignment of the contents will be, and often the character used to separate columns from each other.
Width is a required attribute. As you would expect it sets a fixed width for the table.
The mpsupertabular environments wrap each supertabular environment into a minipage environment. This allows the footnote command to be used inside the table and the footnote is printed at the end of the relevant page.
The command shrinkheight{height} may be used to shrink (or increase if a negative length is used) the height of a row. This is useful in situations when the last row of a table appears at the top of a page. It is put at the start of the affected row. For example, in the sample table, it is possible to shrink the row originally at the bottom of the first page so the row at the top of the second page moves up.
For more options read the documentation for supertabular. Although it is 24 pages long, most of the content is an explanation of the inner workings of the supertabular macro. There are also a few example long tables which reward the reader who invests a little time to understand them.
Longtable: Like supertabular, this is also an environment which aids the writer to use tables that require more than one page. Like supertabular, the 27-page documentation is mostly details of the macro coding. Like supertabular, the documentation has some valuable examples.
The longtable environment saves information about the width of each table in an aux file. It then uses this information in a second compile to calculate and set the width of each column to the widest required by the contents. This implies any file that uses longtable should be compiled several times before accepting the final pdf output. The major difference between supertabular and longtable is most parameters in longtable are set inside the code for the longtable environment, most for supertabular are set before or outside the environment. There are a few parameters set in the sample code shown right.
Notice the [c] instruction in the begin command. With longtable, the position of the table can be set either l(eft), c(enter) or r(ight) in the begin command. With supertabular the table position is set outside the supertabular environment. (See the begin{center} command in the supertabular code fragment.
There is a third environment which can be used for multi-page tables called xltabular. I leave it to you to investigate if this is of interest.
As noted above, page breaks in multi-page tables occur only at breaks between rows ( or at hline commands). Usually this default behaviour is preferable. This can cause design problems in some instances. Occasionally it is necessary to break the contents of one row over two pages. There is a manual “fix” for this situation which involves adding some line breaks and empty cells to force the cell contents to arrange in a particular way along with the parfillskip command so text aligns properly. If you have a situation like this, read over the guidance on pp. 464-466 in volume 1 of The Latex Companion (3rd edition).
Erik and I have presented coding about tables three times now, so enough about tables. Next time another adventure with Latex.