[Tex/LaTex] Keeping two rows on one page using longtable

line-breakinglongtablepage-breakingthreeparttable

I am creating a longtable which spreads over multiple pages. The problem is that the coefficients and standard errors which are in two consequential rows sometimes get separated. How to I hold those two rows together (i.e. on one page)?

So for example image that you want the AAAAA and CC row to be always to be packed together (AAAA always followed by CC). Now the last row in this table (on the first page) is AAAA but I want it to be together with the first row on the next page. One solution would be to put a pagebreak before the last AAAA (on the first page) but I need a general solution because I am producing lots of tables like this (automatically).

\documentclass{article}

\usepackage[referable]{threeparttablex}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

\begin{ThreePartTable}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{TableNotes}[flushleft]
\item[a] \label{tn:a} \footnotesize test test test test test test test test
\item[b] \label{tn:b} test2
\item Test
\source Made up by daleif
\end{TableNotes}
\begin{longtable}{@{\extracolsep{4pt}}l*{2}{c}@{}}
\caption{A long table that goes on and on and ....}\\
\toprule
Column 1 & Column 2 & Column 3 \\
\midrule
\endfirsthead
\multicolumn{3}{l}{\emph{... table \thetable{} continued}} \\
\toprule
Column 1 & Column 2 & Column 3 \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{\emph{Continued on next page...}}\\
\endfoot
\bottomrule
\insertTableNotes\\
\endlastfoot
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\          
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\        
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\         
  CC   &          & DD  \\
AAAA & XXXXXXXX & BBBB \\
AAAA\tnotex{tn:a} & XXXXXXXX & BBBB \\
  CC   &          & DD\tnotex{tn:b}   \\
\end{longtable}
\end{ThreePartTable}

\end{document}

Best Answer

You can prohibit a page break between two rows by ending the first with

\\*

Thus

AAAA & XXXXXXXX & BBBB \\*
  CC   &          & DD  \\

should be what you're looking for.

Related Question