The longtable package

Provides the longtable environment for tables that continue over several pages, with a head and foot that repeat on every page.

Loading the package

\usepackage{longtable}

A tabular is one box that cannot be split; one that is longer than the page runs off its lower edge. longtable has the same column argument and the same row syntax, but LaTeX may break the page between any two rows.

longtable replaces both table and tabular. It is not a float, so it starts where it stands in the source, and \caption and \label are written inside it as the first row. Four commands mark special rows: everything before \endfirsthead is the head on the first page, before \endhead the head on the following pages, before \endfoot the foot at each page break, and before \endlastfoot the foot at the end of the table.

Main commands

\begin{longtable}{lrr} ... \end{longtable}Table that may break across pages.
\caption{...}\label{tab:x} \\Caption as a table row; the \\ after it is required.
\endfirstheadEnds the head of the first page.
\endheadEnds the head that is repeated on every following page.
\endfootEnds the foot that is printed before every page break, for example "continued on the next page".
\endlastfootEnds the foot of the last page.
\caption[]{... (continued)} \\Caption for the repeated head; the empty brackets keep it out of the list of tables.

Complete example

\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
\begin{longtable}{lrr}
\caption{Monthly measurements}\label{tab:months} \\
\toprule
Month & Rain (mm) & Sun (h) \\
\midrule
\endfirsthead
\toprule
Month & Rain (mm) & Sun (h) \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{continued on the next page} \\
\endfoot
\bottomrule
\endlastfoot
January  & 62 & 48 \\
February & 45 & 75 \\
March    & 51 & 120 \\
\end{longtable}
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023. Tools run in this order: pdflatex → pdflatex.

Pitfalls

Related pages