Tables that run across pages: longtable and xltabular
longtable is a standard LaTeX package for tables that do not fit on one page. Put the header in \endfirsthead and \endhead so it repeats on every page, run LaTeX twice so column widths settle, and use longtable instead of a table float, not inside one. For text-heavy cells that should wrap, xltabular adds tabularx-style X columns.
Convert a table from a PDF or screenshot →By TableToLatex · · Examples tested with pdfLaTeX (two passes), TeX Live 2023, longtable, xltabular
How longtable works
A tabular cannot break across pages, and a table float cannot either: if the table is taller than the page, LaTeX warns "Float too large for page" and the extra rows run off the bottom. The longtable package provides an environment that breaks like ordinary text. You define its head and foot blocks once: \endfirsthead closes the header for the first page, \endhead the header repeated on later pages, \endfoot the footer on every page but the last, and \endlastfoot the footer at the very end.
% preamble: \usepackage{booktabs} \usepackage{longtable}
\begin{longtable}{lcc}
\caption{Per-class results.}\label{tab:perclass}\\
\toprule
Class & Precision & Recall \\
\midrule
\endfirsthead
\caption[]{Per-class results (continued).}\\
\toprule
Class & Precision & Recall \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{\emph{Continued on next page}} \\
\endfoot
\bottomrule
\endlastfoot
Class 01 & 0.91 & 0.88 \\
Class 02 & 0.90 & 0.89 \\
% ... more rows ...
\end{longtable}Two rules follow. Do not wrap longtable in a table environment; the caption goes inside it and ends with \\. And expect to compile twice. The package measures column widths from the first block of rows, and if a later row is wider it asks for another run. A single row never splits across pages.
For cells that hold sentences, xltabular is longtable plus tabularx: an X column wraps its text to fill the width, and the same head and foot blocks apply.
% preamble: \usepackage{booktabs} \usepackage{xltabular}
\begin{xltabular}{\linewidth}{lXr}
\caption{Hyperparameter notes.}\label{tab:hp}\\
\toprule
ID & Description & Count \\
\midrule
\endfirsthead
\caption[]{Hyperparameter notes (continued).}\\
\toprule
ID & Description & Count \\
\midrule
\endhead
\bottomrule
\endlastfoot
01 & A long description that wraps inside the X column. & 12 \\
% ... more rows ...
\end{xltabular}Turn a tabular into a longtable in seven steps
- 1
Load the packages
Add \usepackage{booktabs} and \usepackage{longtable} (or xltabular when cells hold sentences) to the preamble.
- 2
Remove the float
Delete \begin{table}, \end{table} and \centering around the tabular. longtable centres itself and is not a float.
- 3
Rename the environment
Replace tabular with longtable. The column specification stays the same.
- 4
Write the first head
Put the caption and label first and end the caption line with \\. Then the rules, the header row and \midrule, closed by \endfirsthead.
- 5
Write the continuation head
Repeat the header, with \caption[]{... (continued)}\\ above it, closed by \endhead. The empty [] keeps the list of tables clean.
- 6
Write the feet
\endfoot closes the footer shown on every page except the last, for example a "Continued on next page" row. \endlastfoot closes the footer for the final page, usually \bottomrule.
- 7
Paste the rows and compile twice
Compile at least twice so that widths and cross-references settle, and again if LaTeX asks you to rerun.
Which table environment to use
| Environment | Breaks across pages | Wraps text in X columns | Inside a table float | Two-column documents |
|---|---|---|---|---|
| tabular | No | No (use p{} columns) | Yes | Yes |
| tabularx | No | Yes | Yes | Yes |
| longtable | Yes | No (use p{} columns) | No | No: package error |
| xltabular | Yes | Yes | No | No (built on longtable) |
What goes wrong
- The header does not repeat. There is no
\endheadblock. This compiles without any error, so check page two. - The header appears twice on page one. It is in the head blocks and also typed again as the first body row. Remove the body copy.
- Float too large for page. longtable sits inside
\begin{table}. Remove the float; the caption belongs inside the longtable. - Table widths have changed. Not an error. Compile again.
- longtable not in 1-column mode. The document class is two-column. See the guide to two-column tables for the alternatives.
- Notes under the table. threeparttable is built for tabular. For a longtable, its companion threeparttablex provides the ThreePartTable and TableNotes environments, and a test with it compiled. Shorter tables are covered in table footnotes.
How TableToLatex helps
A table that continues across two PDF pages comes out of TableToLatex as two tables, one per page, each with its own header row. Delete the repeated header block, then paste the rows into the longtable shape above; the row syntax is identical. The tool does not emit longtable itself yet. If the table is too wide as well as too long, see fixing a table that is too wide. Upload the pages with PDF to LaTeX tables. The table tool is free and runs in your browser. Paste a tab-separated range from a spreadsheet. See pricing.
Questions about longtable
How do I repeat the header row on every page of a LaTeX table?+
Use longtable and put the header row before \endhead. Everything up to \endfirsthead is printed on the first page, and everything between \endfirsthead and \endhead is repeated at the top of each later page. If you forget \endhead, the table still compiles but the header appears only once.
Can I put longtable inside a table environment?+
No. A float cannot break across pages, so LaTeX reports "Float too large for page" and the rows run off the bottom. Remove \begin{table} and put the caption inside the longtable.
Why does longtable need two compilations?+
longtable measures column widths from the first block of rows and may find later rows wider. It then prints "Table widths have changed. Rerun LaTeX." and uses the saved widths on the next run. References to the table also need a second pass.
What is the difference between longtable and xltabular?+
xltabular combines longtable with tabularx. You get the same \endhead and \endfoot blocks, plus X columns that expand to fill the width and wrap their text, which longtable alone can only do with fixed p{} widths.
How do I stop a page break after a particular row?+
End that row with \\* instead of \\. The star forbids a break after the row, so it stays on the same page as the row that follows it.
Can I use longtable in a two-column IEEE or ACM paper?+
Not in a two-column layout: the package stops with "longtable not in 1-column mode". Use a table* that spans both columns, split the table in two, or ask whether the venue accepts the long table as supplementary material.
How do I add a continued-on-next-page note?+
Put a row such as \multicolumn{3}{r}{\emph{Continued on next page}} between \midrule and \endfoot. It prints at the bottom of every page except the last.
Keep reading
- Table too wide
resizebox, adjustbox, landscape and sidewaystable, and when each is right.
- Two-column tables
table*, [!t] placement, widths and float order in IEEEtran-style templates.
- Table footnotes
tablenotes, tnote marks, symbols, and why plain footnotes disappear.
Have a table in a spreadsheet? Paste it into the table tool, or see all LaTeX table guides.