The following compiles well in Kile but when imported into Lyx the title is duplicated and the "continued on next page" incorrectly appears at the end of the table.
%% LyX 1.6.7 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{longtable}
\usepackage{float}
\usepackage{supertabular}
\usepackage{longtable}
\usepackage{caption}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\special{papersize=\the\paperwidth,\the\paperheight}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\makeatother
\usepackage{babel}
\begin{document}
\begin{longtable}{|l|l|}
\caption{A long table}
\endfirsthead
\hline
\multicolumn{1}{|c|}{Gene ID } & \multicolumn{1}{|c|}{Description}\tabularnewline
\hline
\endhead
\multicolumn{2}{r}{{Continued on next page}}
\tabularnewline
\endfoot
\endlastfoot
\hline
\multicolumn{1}{|c|}{Gene ID } & \multicolumn{1}{c|}{Description}\tabularnewline
\hline
KIAA1539 & KIAA1539\tabularnewline
\hline
TMEM98 & transmembrane protein 98\tabularnewline
\hline
RHBDF1 & rhomboid 5 homolog 1\tabularnewline
\hline
DCN & decorin\tabularnewline
\hline
HAGH & hydroxyacylglutathione hydrolase\tabularnewline
\hline
DGKA & diacylglycerol kinase, alpha 80kDa\tabularnewline
\hline
P4HA2 & prolyl 4-hydroxylase, alpha polypeptide II\tabularnewline
\hline
GPR137B & G protein-coupled receptor 137B\tabularnewline
\hline
SLC22A17 & solute carrier family 22, member 17\tabularnewline
\hline
TBC1D2 & TBC1 domain family, member 2\tabularnewline
\hline
HSD3B7 & \tabularnewline
\hline
TIMP3 & TIMP metallopeptidase inhibitor 3\tabularnewline
\hline
ARSA & arylsulfatase A\tabularnewline
\hline
ENG & endoglin\tabularnewline
\hline
HPS1 & Hermansky-Pudlak syndrome 1\tabularnewline
\hline
WSB1 & WD repeat and SOCS box-containing 1\tabularnewline
\hline
H2AFJ & H2A histone family, member J\tabularnewline
\hline
PCTK3 & cyclin-dependent kinase 18\tabularnewline
\hline
PLAGL1 & pleiomorphic adenoma gene-like 1\tabularnewline
\hline
CPXM2 & carboxypeptidase X , member 2\tabularnewline
\hline
XG & Xg blood group\tabularnewline
\hline
PSG2 & pregnancy specific beta-1-glycoprotein 2\tabularnewline
\hline
TUBA1 & tubulin, alpha 4a\tabularnewline
\hline
ISLR & immunoglobulin superfamily containing leucine-rich repeat\tabularnewline
\hline
CD68 & CD68 molecule\tabularnewline
\hline
SLC44A2 & solute carrier family 44, member 2\tabularnewline
\hline
DLG4 & discs, large homolog 4\tabularnewline
\hline
REEP2 & receptor accessory protein 2\tabularnewline
\hline
NES & nestin\tabularnewline
\hline
STARD13 & StAR-related lipid transfer domain containing 13\tabularnewline
\hline
MYH11 & myosin, heavy chain 11, smooth muscle\tabularnewline
\hline
NT5E & 5'-nucleotidase, ecto\tabularnewline
\hline
ITGA7 & integrin, alpha 7\tabularnewline
\hline
ITM2B & integral membrane protein 2B\tabularnewline
\hline
NAAA & N-acylethanolamine acid amidase\tabularnewline
\hline
SLC16A3 & solute carrier family 16, member 3\tabularnewline
\hline
IFITM3 & interferon induced transmembrane protein 3\tabularnewline
\hline
CRABP2 & cellular retinoic acid binding protein 2\tabularnewline
\hline
LHX9 & LIM homeobox 9\tabularnewline
\hline
ECM1 & extracellular matrix protein 1\tabularnewline
\hline
COL8A1 & collagen, type VIII, alpha 1\tabularnewline
\hline
NMRAL1 & NmrA-like family domain containing 1\tabularnewline
\hline
NCSTN & nicastrin\tabularnewline
\hline
PBXIP1 & pre-B-cell leukemia homeobox interacting protein 1\tabularnewline
\hline
ESM1 & endothelial cell-specific molecule 1\tabularnewline
\hline
CITED2 & \tabularnewline
\hline
MAP1A & microtubule-associated protein 1A\tabularnewline
\hline
ANGPTL4 & angiopoietin-like 4\tabularnewline
\hline
GDNF & glial cell derived neurotrophic factor\tabularnewline
\hline
IL7R & interleukin 7 receptor\tabularnewline
\hline
TMEM129 & transmembrane protein 129\tabularnewline
\hline
GAA & glucosidase, alpha; acid\tabularnewline
\hline
MRGPRF & MAS-related GPR, member F\tabularnewline
\hline
SEZ6L2 & seizure related 6 homolog -like 2\tabularnewline
\hline
IRX3 & iroquois homeobox 3\tabularnewline
\hline
ADAMTSL1 & ADAMTS-like 1\tabularnewline
\hline
C15ORF52 & Uncharacterized protein C15orf52\tabularnewline
\hline
PDCD1LG2-001 & Programmed cell death 1 ligand 2 Precursor\tabularnewline
\hline
HOXC6 & homeobox C6\tabularnewline
\hline
PSG4 & pregnancy specific beta-1-glycoprotein 4\tabularnewline
\hline
FER1L4 & fer-1-like 4\tabularnewline
\hline
\end{longtable}
\end{document}
I've even tried using a longtable module which didn't work for me:
http://www.oak-tree.us/stuff/LyX/longtablepage.module
Using this custom inset seemed to compile like a regular table, flowing past the end of the page rather than having proper pagebreaks inserted.
The one here: http://wiki.lyx.org/LyX/Tables#longtab-cap doesn't include the header at the top of every page or say continued on the next page at the bottom.
Can someone provided an example of a longtable that would compile in Lyx similar to the way my example compiles in Kile?
Best Answer
The problem is, as is shown in the LyX Wiki, that longtables do not work inside floats, and there is no possibility to give a caption inside the table. But the hack given in the mentioned LyX Wiki section does not help as soon as you define a table head, because then the line with the caption in ERT is moved below the \endhead command. Thus, you have to define the first line with the caption command as a table head. The following worked for me (created with LyX 1.6.7 on Windows). I had to shorten the table, because the example would have been too long otherwise.
This is too long for a comment, so I’ll put it in the answer:
I just realized that the caption is also shown on the second page, which it shouldn't. To change this, you can go to the table preferences in LyX and change the status in the longtable tab to “First head” instead of “Head” (the exact terms might be different, I use a German LyX). If you would like to have the caption also on subsequent pages, but with a different text, you can have two lines with the caption, one defined as “First head” and one as “Head”. For the continued caption, you have to insert a caption command with an empty optional argument, because otherwise there would be two entries in the list of tables. Thus, the ERT for the continued caption should look like this: