# How to repeat top rows (column headings) on every page

I have a big table which contains hundreds of rows. I want to repeat the top two rows on every page of the table. How can I do it in TeX?

• @Alan: It's related, but it isn't a duplicate. More of a follow-up question. Feb 18, 2011 at 5:21

Both the longtable package and the supertabular package can do this. Here's an example using longtable:

\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{ccc}
\hline
Column 1 & Column 2 & Column 3\\
\hline
\endhead % all the lines above this will be repeated on every page
A & B & C\\
A & B & C\\
... many lines of table ...
\end{longtable}
\end{document}


The same basic idea works with supertabular but the commands for setting the repeated elements across pages is done before the supertabular environment itself:

\documentclass{article}
\usepackage{supertabular}
\begin{document}
\hline
Column 1 & Column 2 & Column 3\\
\hline}
\tabletail{\hline}
\begin{supertabular}{ccc}
A & B & C\\
A & B & C\\
\end{supertabular}
\end{document}

• I'd like to mention that I tried this solution with a longtabu table and it worked. Apr 11, 2013 at 10:23
• This also works with pgfplotstable and tabularx Jul 26, 2018 at 15:00
• How can I do this in supertabular? May 6, 2019 at 4:40
• @ChamilaWijayarathna I've added a supertabular example. May 6, 2019 at 14:29

A solution with continued headers and footers

\documentclass{article}
\usepackage{longtable}
\begin{document}

\begin{longtable}{ccc}
\caption{My caption for this table\label{foo}}\\\hline
Column 1 & Column 2 & Column 3\\\hline
\multicolumn{3}{@{}l}{\ldots continued}\\\hline
Column 1 & Column 2 & Column 3\\\hline
\endhead % all the lines above this will be repeated on every page
\hline
\multicolumn{3}{r@{}}{continued \ldots}\\
\endfoot
\hline
\endlastfoot
A & B & C\\     A & B & C\\
A & B & C\\     A & B & C\\
A & B & C\\ \newpage
A & B & C\\     A & B & C\\
A & B & C\\     A & B & C\\
\end{longtable}
\end{document}


An alternative solution with tblr environment of tabularray package:

\documentclass{article}

\usepackage[a6paper,margin=1.5cm]{geometry}

\usepackage{tabularray}

\begin{document}

\begin{longtblr}[
caption = {Long Title},
label = {tblr:test},
]{
colspec = {lll},
hlines,
}
Column 1 & Column 2 & Column 3 \\
Column 1 & Column 2 & Column 3 \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
Alpha    & Beta     & Gamma    \\
Epsilon  & Zeta     & Eta      \\
Iota     & Kapp     & Lambdaa  \\
\end{longtblr}

\end{document}


Maybe the package tabularray can solve this problem in a more simple way. Just as (The code below is somehow copied from what written by user Alan Munn):

\documentclass{article}
\usepackage{tabularray} % A newest package for tables written in LaTeX 3
\begin{document}
\begin{longtblr}{
colspec = {ccc},
rowhead = 1 % indidate the program to repeat the 1st row in the beginning of every page.
}
\hline
Column 1 & Column 2 & Column 3\\
\hline
A & B & C\\
A & B & C\\
%... many lines of table ...%
\end{longtblr}
\end{document}


As for the header, it can also be set in the beginning code block \begin{longtblr}{...}, for more detailed information you can read the corresponding PDF file.

However there is one side effect that the time it takes for rendering may be longer because of the mechanism the package uses.

• Welcome to TeX.SE! Do you see @L.J.R: answer? In what differ your answer from his? Mar 27 at 8:04