3

I have some strange problem with my longtables. In some tables there is a pagebreak after the last row and on the second page there is the table header printed again without following content. I use the patched longtable from How to make longtable respect \nopagebreak in the beginning?.

Here is a not really minimal example, which shows the problem in the second table:

\documentclass[open=any, a5paper, fontsize=9pt, DIV12]{scrbook}
%\usepackage[utf8x]{inputenc} only for pdflatex

\usepackage{etoolbox}
\usepackage{array}
\usepackage{longtable}
\usepackage{libertine}
\setcounter{secnumdepth}{-1}

\newcommand{\br}{\hfill\break}

\newif\ifnormalLT
\normalLTtrue

\makeatletter
\patchcmd {\LT@start}
      {\vfil\break}
      {\ifnormalLT\vfil\break\fi}
      {\typeout{Patching longtable succeeded!}}
      {\typeout{Patching longtable failed!}\ERROR}
\patchcmd {\LT@start}
      {\penalty\z@}
      {\ifnormalLT\penalty\z@\fi}
      {\typeout{Patching longtable succeeded!}}
      {\typeout{Patching longtable failed!}\ERROR}

\makeatother


\newenvironment{deklination}
{
\setlength{\extrarowheight}{.75ex}%
\normalLTfalse
\longtable{lp{3cm}p{3cm}p{3cm}}
&\textbf{Sg.}&\textbf{Du.}&\textbf{Pl.}\\
\endhead
}
{\endlongtable}

\usepackage{hyperref}

\begin{document}

\chapter{Lektion IX}

\section{Grammatik}

\subsection{Pronomen der zweiten Person svad, yuṣmad}

\begin{deklination}
\textbf{Nom.}&{svam}&{yuvām}&{yūvam}\\
\textbf{Akk.}&{svām},\br {svā}&{yuvām},\br {vām}&{yuṣmān},\br {vaḥ}\\
\textbf{Inst.}&{svayā}&{yuvābhyām}&{yuṣmābhiḥ}\\
\textbf{Dat.}&{tuhyam},\br {te} &{yuvābhyām},\br {vām}&{yuṣmabhyam},\br {vaḥ}\\
\textbf{Abl.}&{svat}&{yuvābhyām}&{yuṣmat}\\
\textbf{Gen.}&{tava},\br {te}&{yuvayoḥ},\br {vām}&{yuṣmākam},\br {vaḥ}\\
\textbf{Lok.}&{svayi}&{yuvayoḥ}&{yuṣmāsu}\\
\end{deklination}

\subsection{Pronomen der dritten Person tad – er, sie, es; jener, jene, jenes}
\subsubsection{Masculinum}

\begin{deklination}
\textbf{Nom.}&{saḥ}&{tau}&{te}\\
\textbf{Akk.}&{tam}&{tau}&{tān}\\
\textbf{Inst.}&{tena}&{tābhyām}&{taiḥ}\\
\textbf{Dat.}&{tasmai}&{tābhyām}&{tebhyaḥ}\\
\textbf{Abl.}&{tasmāt}&{tābhyām}&{tebhyaḥ}\\
\textbf{Gen.}&{tasya}&{tayoḥ}&{teṣām}\\
\textbf{Lok.}&{tasmin}&{tayoḥ}&{teṣu}\\%
\end{deklination}

\subsubsection{Femininum}
\begin{deklination}
\textbf{Nom.}&{sā}&{te}&{tāḥ}\\
\textbf{Akk.}&{tām}&{te}&{tāḥ}\\
\textbf{Inst.}&{tayā}&{tābhyām}&{tabhiḥ}\\
\textbf{Dat.}&{tasyai}&{tābhyām}&{tābhyaḥ}\\
\textbf{Abl.}&{tasyāḥ}&{tābhyām}&{tābhyaḥ}\\
\textbf{Gen.}&{tasyāḥ}&{tayoḥ}&{tāsām}\\
\textbf{Lok.}&{tasyām}&{tayoḥ}&{tasu}\\%
\end{deklination}

\subsubsection{Neutrum}
\begin{deklination}
\textbf{Nom.}&{tat} (d)&{te}&{tāni}\\
\textbf{Akk.}&{tat} (d)&{te}&{tāni}\\
\textbf{Inst.}&{tena}&{tābhyām}&{taiḥ}\\
\textbf{Dat.}&{tasmai}&{tābhyām}&{tebhyaḥ}\\
\textbf{Abl.}&{tasmāt}&{tābhyām}&{tebhyaḥ}\\
\textbf{Gen.}&{tasya}&{tayoḥ}&{teṣām}\\
\textbf{Lok.}&{tasmin}&{tayoḥ}&{teṣu}\\
\end{deklination}

\end{document}
  • I am also having this exact problem. I used this patch to avoid the problem of page breaks being inserted between a section header and a longtable, and I am seeing spurious table headers in the "next page", after all rows have been already processed. Did you manage to find a solution? – Grodriguez Jan 26 '17 at 12:54
2

Hmm I thought it might be

longtabu and floats: wrong table breaks on pages with floats

but it isn't.

Actually I'd use a simpler way to keep headers with the table than the patch suggested, which does the right thing in your case:

\documentclass[open=any, a5paper, fontsize=9pt, DIV12]{scrbook}
\usepackage[utf8x]{inputenc}% only for pdflatex

\usepackage{etoolbox}
\usepackage{array}
\usepackage{longtable}
\usepackage{libertine}
\setcounter{secnumdepth}{-1}

\newcommand{\br}{\hfill\break}


\newenvironment{deklination}[1]
{\setlength{\extrarowheight}{.75ex}%
%\normalLTfalse
\longtable{lp{3cm}p{3cm}p{3cm}}
\noalign{\subsection{#1}}
&\textbf{Sg.}&\textbf{Du.}&\textbf{Pl.}\\
\endhead
}
{\endlongtable}

\usepackage{hyperref}

\begin{document}

\chapter{Lektion IX}

\section{Grammatik}



\begin{deklination}{Pronomen der zweiten Person svad, yuṣmad}
\textbf{Nom.}&{svam}&{yuvām}&{yūvam}\\
\textbf{Akk.}&{svām},\br {svā}&{yuvām},\br {vām}&{yuṣmān},\br {vaḥ}\\
\textbf{Inst.}&{svayā}&{yuvābhyām}&{yuṣmābhiḥ}\\
\textbf{Dat.}&{tuhyam},\br {te} &{yuvābhyām},\br {vām}&{yuṣmabhyam},\br {vaḥ}\\
\textbf{Abl.}&{svat}&{yuvābhyām}&{yuṣmat}\\
\textbf{Gen.}&{tava},\br {te}&{yuvayoḥ},\br {vām}&{yuṣmākam},\br {vaḥ}\\
\textbf{Lok.}&{svayi}&{yuvayoḥ}&{yuṣmāsu}\\
\end{deklination}

\subsection{Pronomen der dritten Person tad – er, sie, es; jener, jene, jenes}

\begin{deklination}{Masculinum}
\textbf{Nom.}&{saḥ}&{tau}&{te}\\
\textbf{Akk.}&{tam}&{tau}&{tān}\\
\textbf{Inst.}&{tena}&{tābhyām}&{taiḥ}\\
\textbf{Dat.}&{tasmai}&{tābhyām}&{tebhyaḥ}\\
\textbf{Abl.}&{tasmāt}&{tābhyām}&{tebhyaḥ}\\
\textbf{Gen.}&{tasya}&{tayoḥ}&{teṣām}\\
\textbf{Lok.}&{tasmin}&{tayoḥ}&{teṣu}\\%
\end{deklination}

\begin{deklination}{Femininum}
\textbf{Nom.}&{sā}&{te}&{tāḥ}\\
\textbf{Akk.}&{tām}&{te}&{tāḥ}\\
\textbf{Inst.}&{tayā}&{tābhyām}&{tabhiḥ}\\
\textbf{Dat.}&{tasyai}&{tābhyām}&{tābhyaḥ}\\
\textbf{Abl.}&{tasyāḥ}&{tābhyām}&{tābhyaḥ}\\
\textbf{Gen.}&{tasyāḥ}&{tayoḥ}&{tāsām}\\
\textbf{Lok.}&{tasyām}&{tayoḥ}&{tasu}
\end{deklination}

\begin{deklination}{Neutrum}
\textbf{Nom.}&{tat} (d)&{te}&{tāni}\\
\textbf{Akk.}&{tat} (d)&{te}&{tāni}\\
\textbf{Inst.}&{tena}&{tābhyām}&{taiḥ}\\
\textbf{Dat.}&{tasmai}&{tābhyām}&{tebhyaḥ}\\
\textbf{Abl.}&{tasmāt}&{tābhyām}&{tebhyaḥ}\\
\textbf{Gen.}&{tasya}&{tayoḥ}&{teṣām}\\
\textbf{Lok.}&{tasmin}&{tayoḥ}&{teṣu}\\
\end{deklination}

\end{document}
  • This is not really the solution I'm looking for. It ist not really comfortable to use the argument. Additionally the spacing in the \noalign needs to be fixed but this is not the problem. Do you think that the problem in longatble itself can be fixed? – sanskrit_learner Feb 6 '14 at 17:22
  • @sanskrit_learner can the problem be demonstrated in an unpatched longtable? – David Carlisle Feb 6 '14 at 17:36
  • I can't reproduce the problem without the patches. It seems to me that the by the patch removed \break is the source of the problem. I would have thought, that it never would be used in this place since there is enought space on the page and even the next section heading fits on it. – sanskrit_learner Feb 6 '14 at 18:46
  • @sanskrit_learner well on the face of it a problem that only occurs on patched code is a problem with the patch, not with the original code. – David Carlisle Feb 6 '14 at 21:56
  • I understand that it is not really a problem in your code. But I hoped you could help me to understand why the patched version is not working. Unfortunately your given solution has a problem which makes it useless: when there is a pagebreak in the table, the content of the \noalign is repeated since it is put in the header. Nevertheless thank you for your help! – sanskrit_learner Feb 7 '14 at 12:47

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.