[Tex/LaTex] LyX: Problem with longtable in landscape

landscapelongtablelyx

I am trying to embed a longtable in landscape mode. What I have always done is put \usepackage{longtable} and \usepackage{pdflscape} in the preamble, then put the table between \begin{landscape} and \end{landscape}. But this is simply not working on the file I have posted at this link. When I export to pdf, the first page comes out empty, and the second page clips the bottom rows.
Sorry for this trivial question, but I simply can't figure it out.

Best Answer

Simply adding \usepackage{longtable} to the preamble does not mean that all tables automatically are allowed to break across pages. The standard LaTeX environment for tables, which is used by LyX as default, is called tabular, and does not break across pages. The longtable package defines a new table environment by the same name which can break across pages (between table rows). Small LaTeX code example:

\documentclass{article}
\usepackage{longtable}
\begin{document}
Default \texttt{tabular}, can not break across pages:

\begin{tabular}{c}
...
\end{tabular}

\texttt{longtable}, can break across pages:

\begin{longtable}{c}
...
\end{longtable}
\end{document}

You have to tell LyX to use the latter construct. This is done in the tabular settings, which is found by right clicking inside the table, and choosing More --> Settings. The third tab is called Longtable, and there is a check box Use long table at the top that must be checked, see screenshot below. This will also add \usepackage{longtable} to the preamble, so it is not necessary to do that manually.

enter image description here