Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass[letterpaper]{article}
\usepackage{longtable}              % Longtable package
\usepackage[margin=1in]{geometry}   % Margins
\usepackage{booktabs}               % Nicer horizontal lines

\begin{document}
\begin{longtable}{ l l }
\caption{Heading} \\ \toprule       % toprule, midrule, and bottomrule are the horizontal lines
Left Heading & Right Heading \\ \midrule
\endhead
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\ \bottomrule
\end{longtable}
\end{document}

The above code produces the following: First page. Second page.

But this is what I want on the second page (this is obviously a product of MS Paint, but please bear with me): This is what I want!

So, how would I do this?

share|improve this question
1  
You have to define a first head. Just have a look into the documentation please. –  Kurt Jul 16 '13 at 21:23
1  
@Kurt To be fair, I also found it quite counterintuitive that the normal header command suddenly determines the modified header while the normal header needs a new command in this particular case. Of course it follows its own logic but I can't say I would have looked for something like \endfirsthead. –  Christian Jul 16 '13 at 21:27
    
@Christian I didn't recognize that it could be counterintuitive, because if I have to learn the usage of a new package I always look first into the documentation. There you can found the solution very easy with example ... –  Kurt Jul 16 '13 at 21:44
1  
@Christian blame the twisted logic of the package author. –  David Carlisle Jul 16 '13 at 21:54
    
@Kurt I didn't want to say it couldn't be found. Obviously I did find this. I just say that I can understand when somebody doesn't find this without reading through nine pages of docs, that – no offence, David – the this-table-shows-it-all example is not the most clearly arranged example possible and that consequently it should be easy to find more worthy victims of RTFMing on the Internet. –  Christian Jul 16 '13 at 21:55
show 1 more comment

1 Answer

up vote 4 down vote accepted

Use \endfirsthead for the first heading and \endhead for all the other pages.

\documentclass[letterpaper]{article}
\usepackage{longtable}              % Longtable package
\usepackage[margin=1in]{geometry}   % Margins
\usepackage{booktabs}               % Nicer horizontal lines

\begin{document}
\begin{longtable}{ l l }
\caption{Heading} \\ \toprule       % toprule, midrule, and bottomrule are the horizontal lines
Left Heading & Right Heading \\ \midrule
\endfirsthead
\caption{Heading (cont.)} \\ \toprule       % toprule, midrule, and bottomrule are the horizontal lines
Left Heading & Right Heading \\ \midrule
\endhead
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\ \bottomrule
\end{longtable}
\end{document}

result

share|improve this answer
    
Thanks, that worked perfectly! –  Donkey Jul 16 '13 at 21:28
2  
+1 for having read my extensive and lucid documentation:-) –  David Carlisle Jul 16 '13 at 21:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.