[Tex/LaTex] How to repeat top rows (column headings) on every page

longtabletables

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?

Best Answer

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}
\tablehead{%
\hline
Column 1 & Column 2 & Column 3\\
\hline}
\tabletail{\hline}
\begin{supertabular}{ccc}
A & B & C\\
A & B & C\\
\end{supertabular}
\end{document}