A table with many rows soon outgrows a single page and needs to continue onto the next. But an ordinary tabular wrapped in the floating **table environment will never break across a page — a float assumes a block that fits on one page. The longtable package** breaks through that wall. The longtable environment is not a float: it sits directly in the text flow and can span several pages, broken by LaTeX’s normal page-breaking algorithm. This page covers why a tabular alone cannot break, how longtable’s repeating heads and feet work (\endfirsthead, \endhead, \endfoot, \endlastfoot), how captions are attached, and finally **xltabular**, which adds auto-width X columns that break across pages too.
Why a table inside a float cannot break
As covered in “tabular basics,” the tabular environment sets a table’s contents, while the floating **table environment** places it as “Table N.” Like figure, table is a float (a floating body): LaTeX treats it as a single block that fits on one page and is free to move the whole thing to the top or bottom of a page. Because it is one indivisible block, no page break can occur inside it. So however tall the inner tabular grows, it is never split — it is merely pushed to the top of the next page, and may overflow if it still does not fit.
In other words, a “table that spans pages” is fundamentally incompatible with the float mechanism itself. What you need is a way to place the table in the same text flow as the body and let it break across pages naturally, the way a paragraph does. That is exactly what longtable provides.
The longtable environment
longtable keeps almost all of tabular’s features while producing a table that can be split by TeX’s standard page-breaking algorithm. In the words of its author, David Carlisle, it “has most of the features of the tabular environment, but produces tables which may be broken” across pages. Usage closely mirrors tabular: \begin{longtable}{spec} takes a mandatory column specification, and in the body you separate columns with & and end rows with \\. The difference is that it is placed directly in the text, not as a float — so you must not wrap \begin{longtable}…\end{longtable} in a table environment.
Load it with \usepackage{longtable} in the preamble. Column specifiers like l, c, r, and p{width}, as well as \hline and \multicolumn, all work exactly as in tabular. Before the column spec, \begin{longtable} accepts an **optional argument [c], [r], or [l] that sets the horizontal alignment of the whole table** (centered by default). Page breaks happen only between rows or at \hline positions — never partway through a single row of a p column.
Repeating heads and feet
When a table splits across pages, you usually want the header rows to reappear on every continuation page. longtable provides four markers, declared at the top of the table, that say which rows repeat on which pages. Each marker is placed where the \\ would otherwise end its row.
\endfirsthead— rows up to here appear as the head only on the first page**.\endhead** — rows after\endfirstheadand up to here repeat at the head of every page except the first.\endfoot** — rows after\endheadand up to here appear at the foot of every page that continues (i.e. every page except the last).\endlastfoot** — rows after\endfootand up to here appear only at the very end of the table, on the last page.
All four are optional — if you only want the same header on every page, \endhead alone is enough. Writing a separate \endfirsthead lets the first page carry a different head (for example with a caption) while continuation pages get a terse one like “(continued).” The \endfoot block is the conventional place for a “Continued on next page” row that signals the table runs on.
Captions and numbering
Unlike tabular, longtable has its **own \caption{…}**. It numbers captions with the standard table counter, so \caption{…} is numbered automatically as “Table N,” just like a normal table, and is listed by \listoftables. Because the caption is part of the table’s layout, you write it **inside the head block (before \endfirsthead) and close it with \\**, as in \caption{…}\\.
A few practical conventions. To omit the number, use \caption*{…} (no number, and no entry in the list of tables). For a subsidiary caption like “(continued)” on later pages, write it with an **empty optional argument, \caption[]{…}**, so it is not listed twice in the list of tables. A cross-reference \label{…} **must not go in the repeating \endhead** (it would appear more than once); place it inside \endfirsthead or in the table body. The caption width defaults to 4 inches; change it with \setlength{\LTcapwidth}{…} in the preamble.
A complete skeleton
Here is a longtable skeleton using all four markers. Read it like this: first comes the first-page head (caption plus column headings), closed by \endfirsthead. Next comes the head for later pages (“(continued)” plus column headings), closed by \endhead. Then the “Continued on next page” row for continuing pages, closed by \endfoot, and the closing rule for the last page, closed by \endlastfoot. After all of that come the real data rows — everything below the markers is the actual content, flowed across the pages.
\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{l l r}
% --- 1 ページ目だけの見出し ---
\caption{年間の売上記録}\\
\hline
日付 & 品目 & 金額 \\
\hline
\endfirsthead
% --- 2 ページ目以降の見出し ---
\multicolumn{3}{l}{\small (表のつづき)}\\
\hline
日付 & 品目 & 金額 \\
\hline
\endhead
% --- 続くページの脚 ---
\hline
\multicolumn{3}{r}{\small 次ページに続く}\\
\endfoot
% --- 最終ページの脚 ---
\hline
\endlastfoot
% --- ここから本物のデータ行 ---
2026-01-05 & りんご & 380 \\
2026-01-06 & みかん & 120 \\
% …行が続き、自動で改ページされる…
\end{longtable}
\end{document}This puts the numbered caption “Table N: Annual sales log” on the first page, repeats “(continued)” and the column headings at the top each time the table crosses a page, and adds “Continued on next page” at the bottom of continuing pages. The last page closes quietly with just the foot rule. However many data rows you add, longtable keeps splitting the table at row boundaries automatically.
One caveat: longtable needs at least two LaTeX passes to settle column widths and page breaks. It exchanges the per-page width information through the .aux file, so the first run may not line the columns up — LaTeX even prints a warning that the column widths changed (the manual states the table “will not line up correctly until the document has been run through LaTeX several times”). Build tools such as latexmk rerun the document as many times as needed.
Auto-width wrapping columns: xltabular
longtable’s column spec is the same as tabular’s, so long prose goes in a fixed-width p{width} column that wraps. But when you want a column that stretches to fill the line width and sizes itself automatically to the content, tabularx’s X column is the tool. That X column — covered in “Advanced table environments (tabularx / tabularray)” — belongs to the tabularx environment and cannot break across pages.
The **xltabular package** (Rolf Niepraschk and Herbert Voß) unites the two strengths. As the authors put it, it “behaves like a tabularx as a longtable — in short, it is a longtable with the column specifier X.” It loads ltablex internally but leaves the existing tabularx environment unchanged. Its syntax resembles tabularx: an **optional position argument [c]/[r]/[l], then the total width of the whole table, then the column spec**. The longtable head/foot markers (\endfirsthead, etc.) work here too.
\documentclass{article}
\usepackage{xltabular}
\begin{document}
\begin{xltabular}{\linewidth}{l X r}
\caption{用語と説明}\\
\hline
用語 & 説明 & 頁 \\
\hline
\endfirsthead
\hline
用語 & 説明 & 頁 \\
\hline
\endhead
longtable & ページをまたいで分割できる表組み環境。フロートではなく本文の流れに直接置かれる。 & 12 \\
xltabular & longtable と tabularx を組み合わせ、自動幅の X 列を改ページ可能にした環境。 & 34 \\
\end{xltabular}
\end{document}Here the total width is \linewidth (the text width) and the middle description column is an X column. The X column expands automatically to fill the remaining width and wraps long prose, yet the whole table is a longtable and can span pages — with no fiddling over a fixed p{width}. One small difference: whereas longtable always advances the table counter, xltabular does not consume a number unless you write a \caption.