- I strongly assume that I miss the obvious.
- I have a
longtableand want to prevent a page break after specific rows. - After looking at the manual and looking at this question, I assumed that
\\*or\nopagebreakwill do the job. - However, somehow I do not get the following MWE to work as expected: Some Header C should not be "alone" at the end of a page.
- What am I missing?
\documentclass{article}
% "margin = 52mm" is used to control the page break for the MWE.
\usepackage[a4paper, margin = 52mm, landscape]{geometry}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
\begin{longtable}{p{0.25\linewidth}p{0.40\linewidth}p{0.25\linewidth}}
% Inspired by % https://tex.stackexchange.com/questions/194150
% --- First Head ---
\caption{Caption.}\\toprule
\textbf{A} & \textbf{B} & \textbf{C}\\toprule
\endfirsthead
% --- Other Head ---
\caption*{\textit{Continued from previous page.}}\\toprule
\textbf{A} & \textbf{B} & \textbf{C}\\toprule
\endhead
% --- Other Foots ---
\multicolumn{3}{r}{\textit{Continued on next page.}} \
\endfoot
% --- Last Foot ---
\bottomrule
\endlastfoot
% --- Actual Contents ---
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
\multicolumn{3}{l}{\textbf{Some Header A}}\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
\multicolumn{3}{l}{\textbf{Some Header B}}\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
\multicolumn{3}{l}{\textbf{Some Header C (Should not be before a page break.)}}\*\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
\multicolumn{3}{l}{\textbf{Some Header D}}\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\\midrule
a & b & c\
\end{longtable}
\end{document}
Screenshot from the actual table:



