1

I'm trying to make a longtable and use some R tools for generating them. The problem is that when a long table has more than one columns, it creates double headers, as shown here: https://stackoverflow.com/questions/20552459/excessive-elements-in-latex-longtable-output-when-more-than-one-row-is-used-in-h. I use LyX to generate the output.

This is one-column code:

\begin{document}

\setlongtables


\begin{longtable}{r}\caption{Title} \tabularnewline
\hline\hline
\multicolumn{1}{c}{X1.10}\tabularnewline
\hline
\endfirsthead\caption[]{\em (continued)} \tabularnewline
\hline
\multicolumn{1}{c}{X1.10}\tabularnewline
\hline
\endhead
\hline
\endfoot
\label{data.frame}
$ 1$\tabularnewline
$ 2$\tabularnewline
$ 3$\tabularnewline
$ 4$\tabularnewline
$ 5$\tabularnewline
$ 6$\tabularnewline
$ 7$\tabularnewline
$ 8$\tabularnewline
$ 9$\tabularnewline
$10$\tabularnewline
\hline
\end{longtable}

\end{document}

And this is a two-column table:

\begin{document}

\setlongtables


\begin{longtable}{rr}\caption{Title} \tabularnewline
\hline\hline
\multicolumn{1}{c}{X1.10}&\multicolumn{1}{c}{X10.1}\tabularnewline
\hline
\endfirsthead\caption[]{\em (continued)} \tabularnewline
\hline
\multicolumn{1}{c}{X1.10}&\multicolumn{1}{c}{X10.1}\tabularnewline
\hline
\endhead
\hline
\endfoot
\label{data.frame}
$ 1$&$10$\tabularnewline
$ 2$&$ 9$\tabularnewline
$ 3$&$ 8$\tabularnewline
$ 4$&$ 7$\tabularnewline
$ 5$&$ 6$\tabularnewline
$ 6$&$ 5$\tabularnewline
$ 7$&$ 4$\tabularnewline
$ 8$&$ 3$\tabularnewline
$ 9$&$ 2$\tabularnewline
$10$&$ 1$\tabularnewline
\hline
\end{longtable}

\end{document}

What's wrong with the latter one? Judging from the code, they are identical.

UPDATE

That was LyX: when my .tex file was imported in LyX, it created additional code (the header), so that further processing went wrong.

  • Should the two posts be merged? – azetina Dec 14 '13 at 20:36
3

Please always post complete documents that show the problem. I had to guess to complete your fragment but I only get one heading, so presumably the problem is in the code you didn't show.

enter image description here

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

\setlongtables


\begin{longtable}{rr}\caption{Title} \tabularnewline
\hline\hline
\multicolumn{1}{c}{X1.10}&\multicolumn{1}{c}{X10.1}\tabularnewline
\hline
\endfirsthead\caption[]{\em (continued)} \tabularnewline
\hline
\multicolumn{1}{c}{X1.10}&\multicolumn{1}{c}{X10.1}\tabularnewline
\hline
\endhead
\hline
\endfoot
\label{data.frame}
$ 1$&$10$\tabularnewline
$ 2$&$ 9$\tabularnewline
$ 3$&$ 8$\tabularnewline
$ 4$&$ 7$\tabularnewline
$ 5$&$ 6$\tabularnewline
$ 6$&$ 5$\tabularnewline
$ 7$&$ 4$\tabularnewline
$ 8$&$ 3$\tabularnewline
$ 9$&$ 2$\tabularnewline
$10$&$ 1$\tabularnewline
\hline
\end{longtable}

\end{document}
  • Thank you, David. I actually found the mistake. It was my file processing via LyX that added another row. Thanks to you I've checked it properly. – Anton Tarasenko Dec 14 '13 at 21:58
  • @Anton do you want to close the question if it was a simple error , or if there is some general advice worth giving you could give a self answer (better an answer than adding it to the question) – David Carlisle Dec 14 '13 at 22:06
0

The problem occurred because I did conversion from .tex to .lyx before rendering a PDF file. At this stage, LyX tried to convert longtable (not a part of its native capacities) into a double simple table and added the double header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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