0

Requirements: A longtable List A for n lists (List B) (longtable to get one design alignments). Generic term is List A, which appears as title on every new page as generic term

Longtable rows represent independent little n lists (List B). Their structure is always the same 1) Business row 2) Column description 3) n row entries. The length of those little lists differs. Such a list should never be broken (by pagebreak). Consequence: The start of such a little list ( 1)+2)+3) ) appears always on top of a new page.

List A page 1

List B

Header (2 rows)
1 - n rows

List B

Header (2 rows)
1 - n rows
.
.

List A page 2

List B

Header (2 rows)                         every time at first after pagebreak
1 - n rows                      must follow the header NEVER pagebreak (except of last row of this list B)

List B

Header (2 rows)
1 - n rows

.

What I have reached is the correct placement of the "generic term" s.a. and the unique appearance. Has anyone a solution for the controlled pagebreak not to separate a List B as shown in the output?

    %\documentclass[a4paper,14pt]{scrartcl} % KOMA not recommended with usage of fancyhdr
    \documentclass[a4paper]{article}
    \usepackage[top=1.0cm,right=1cm,left=1cm,bottom=1cm,headheight=50pt,includeheadfoot,headsep=20pt,]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage{longtable}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{} % clears all fields
\fancyfoot[C]{\thepage\ of \pageref{LastPage}}

\definecolor{ctaggreen}{HTML}{330066}
\setlength\headheight{57pt} % to prevent warning of fancyhdr

\cfoot{\colorbox{ctaggreen}{\parbox[b][0.20cm][c]{1.0cm}{\centering\textcolor{white}{\sffamily\bfseries \thepage\ of \pageref{LastPage}}}}}

\lhead{\raisebox{-2mm}{\makebox[0pt]{\hspace*{6.005cm}\includegraphics[height=2cm]{testlogo.png}}}}
\rhead{\raisebox{-2mm}{\makebox[0pt]{\hspace*{-6.005cm}\includegraphics[height=2cm]{testlogo.png}}}}
\chead{\raisebox{3mm}{\colorbox{ctaggreen}{\parbox[b][1.00cm][c]{6.0cm}{\large\centering\textcolor{black}{\sffamily \bfseries{Phone list} \\ [-0.20cm] \footnotesize{voor Medewerkers}%
}%end parbox
}%raisebox
}%endcolorbox
}% end chead
}% end of ???. without: error paragraph ended before ychead...

\usepackage{marvosym}
\begin{document}
\Large %quick and dirty
\sffamily

\setlength{\tabcolsep}{10pt}
\begin{longtable}[h]{ll@{}lr@{ - }l}% 
\endfirsthead
\endhead
\multicolumn{5}{c}{\textit{next page continues}} \\
\endfoot
\hline\hline % two horiz. lines at the end of table
\endlastfoot
%%%%%%%%%%%%%%%%%%%%
%first tab row
%
% Headline
\multicolumn{5}{@{}l}{\textbf{Business Herbert}}  Operating times (00:00)07:00 - 16:30\\ \hline
% Column desc
Contact & {Phone} & & Break from&to \\* \hline
% Rows
B\"uro & 71073 & 707 62 & 12:30 & 13:00  \\* 
Dimitri & 20573 & 070 37 10 &   & \\*  
Dimitri & 2060 & 00 57 71 71 &   & \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Alma & 20516 & 655 12 30 & 12:30 & 13:00  \\*  
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Georg & 2060 & 706 10 60 &    & \\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Gottfried \& Shirin}}  Operating times (00:00)07:00 - 16:30\\ \hline% Column desc
Contact & {Phone} & & Break from&to \\* \hline
Shirin & 20523 & 370 70 00 & 00:00 & 00:20  \\* 
Jessy & 2077 & 076 55 22 & 12:00  & 12:30 \\*  
Leo & 2077 & 525 03 71 & 15:00  & 15:30\\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Jorge}}  Operating times 07:30 - 16:30\\ \hline
Contact & {Phone} &    & Break from&to \\* \hline
Jorge     & 2072  & 263 30 26 & 12:00  & 13:00  \\* 
Gabi  & 20525 & 733 76 75 & 12:00  & 13:00 \\*  
Quintus & 2070  & 013 07 23 & 12:00  & 13:00 \\*  
Sokrates   & 20522 & 730 50 30 & 12:00  & 13:00 \\* [1cm] 
\multicolumn{3}{@{}l}{\textbf{Pascal} \Smiley}   Operating times& & \\ \hline
Contact & {Phone} & & Break from&to \\* \hline
Pascal & 2072 & 730 05 75 &  &   \\* 
Pascal & 2072 & 730 05 75 &  &   \\*  [1cm] %
\multicolumn{5}{@{}l}{\textbf{Business Herbert}}  Operating times (00:00)07:00 - 16:30\\ \hline
Contact & {Phone} & & Break from&to \\* \hline
B\"uro & 71073 & 707 62 & 12:30 & 13:00  \\* 
Dimitri & 20573 & 070 37 10 &   & \\*  
Dimitri & 2060 & 00 57 71 71 &   & \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Alma & 20516 & 655 12 30 & 12:30 & 13:00  \\*  
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Georg & 2060 & 706 10 60 &    & \\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Gottfried \& Shirin}}  Operating times (00:00)07:00 - 16:30\\ \hline
Contact & {Phone} & & Break from&to \\* \hline
Shirin & 20523 & 370 70 00 & 00:00 & 00:20  \\* 
Jessy & 2077 & 076 55 22 & 12:00  & 12:30 \\*  
Leo & 2077 & 525 03 71 & 15:00  & 15:30\\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Jorge}}  Operating times 07:30 - 16:30\\ \hline
Contact & {Phone} &    & Break from&to \\* \hline
Jorge     & 2072  & 263 30 26 & 12:00  & 13:00  \\* 
Gabi  & 20525 & 733 76 75 & 12:00  & 13:00 \\*  
Quintus & 2070  & 013 07 23 & 12:00  & 13:00 \\*  
Sokrates   & 20522 & 730 50 30 & 12:00  & 13:00 \\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Herbert}}  Operating times (00:00)07:00 - 16:30\\ \hline
Contact & {Phone} & & Break from&to \\* \hline
B\"uro & 71073 & 707 62 & 12:30 & 13:00  \\* 
Dimitri & 20573 & 070 37 10 &   & \\*  
Dimitri & 2060 & 00 57 71 71 &   & \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Alma & 20516 & 655 12 30 & 12:30 & 13:00  \\*  
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Georg & 2060 & 706 10 60 &    & \\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Gottfried \& Shirin}}  Operating times (00:00)07:00 - 16:30\\ \hline
Contact & {Phone} & & Break from&to \\* \hline
Shirin & 20523 & 370 70 00 & 00:00 & 00:20  \\* 
Jessy & 2077 & 076 55 22 & 12:00  & 12:30 \\*  
Leo & 2077 & 525 03 71 & 15:00  & 15:30\\* [1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Jorge}}  Operating times 07:30 - 16:30\\ \hline
Contact & {Phone} &    & Break from&to \\* \hline
Jorge     & 2072  & 263 30 26 & 12:00  & 13:00  \\* 
Gabi  & 20525 & 733 76 75 & 12:00  & 13:00 \\*  
Quintus & 2070  & 013 07 23 & 12:00  & 13:00 \\*  
Sokrates   & 20522 & 730 50 30 & 12:00  & 13:00 \\* [1cm] 
\multicolumn{3}{@{}l}{\textbf{Pascal} \Smiley}   Operating times& & \\ \hline
Contact & {Phone} & & Break from&to \\* \hline
Pascal & 2072 & 730 05 75 &  &   \\*  [1cm] 
\multicolumn{3}{@{}l}{\textbf{Pascal} \Smiley}   Operating times& & \\ \hline
Contact & {Phone} & & Break from&to \\* \hline
Pascal & 2072 & 730 05 75 &  &   \\*  [1cm] 
\end{longtable}
\end{document}

Output: [p. 1][1] p. 2

p. 3

gizeh
  • 491
  • 2
    unrelated to the question but [h] longtable does not have an h option. – David Carlisle Aug 08 '20 at 13:39
  • 2
    longtable allows pagebreaks at a \hline which is why your panel is split between pages although you used \\* prior the the \hline. See also: How to disable pagebreak on \hline in longtable? – leandriis Aug 08 '20 at 13:42
  • @David Carlisle; I have removed the "h", reaction remains equal. – gizeh Aug 08 '20 at 13:57
  • @leandris: all rows now " \*", except the ones with "business" (the headline of the List B, where pagebreak is ok). All "\hline" removed. No success. – gizeh Aug 08 '20 at 14:02
  • 2
    Regarding "except the ones with "business" (the headline of the List B, where pagebreak is ok).": I think, you want to use \\* after this specific line as well and use \\ on the line right before "Business..." in order to keep "Business" and the following rows on the same page, while allowing a page break right before "Business...". – leandriis Aug 08 '20 at 14:28

1 Answers1

0

Based on your comments I have built in the macro \nobreakhline. Additionaly corrected the setting of \\, \\*, \\* \nobreakhline. And it works! Many thanks to everyone who shared their knowledge here.

The code:

    \documentclass[a4paper]{article}
    \usepackage[top=1.0cm,right=1cm,left=1cm,bottom=1cm,headheight=50pt,includeheadfoot,headsep=20pt,]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage{longtable}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{} % clears all fields
\fancyfoot[C]{\thepage\ of \pageref{LastPage}}

\definecolor{ctaggreen}{HTML}{330066}
\setlength\headheight{57pt} % to prevent warning of fancyhdr

\cfoot{\colorbox{ctaggreen}{\parbox[b][0.20cm][c]{1.0cm}{\centering\textcolor{white}{\sffamily\bfseries \thepage\ of \pageref{LastPage}}}}}

\lhead{\raisebox{-2mm}{\makebox[0pt]{\hspace*{6.005cm}\includegraphics[height=2cm]{testlogo.png}}}}
\rhead{\raisebox{-2mm}{\makebox[0pt]{\hspace*{-6.005cm}\includegraphics[height=2cm]{testlogo.png}}}}
\chead{\raisebox{3mm}{\colorbox{ctaggreen}{\parbox[b][1.00cm][c]{6.0cm}{\large\centering\textcolor{black}{\sffamily \bfseries{Phone list} \\ [-0.20cm] \footnotesize{voor Medewerkers}%
}%end parbox
}%raisebox
}%endcolorbox
}% end chead
}% end of ???. without: error paragraph ended before ychead...

\usepackage{marvosym}

%%%
\makeatletter
\def\nobreakhline{%
  \noalign{\ifnum0=`}\fi
    \penalty\@M
    \futurelet\@let@token\LT@@nobreakhline}
\def\LT@@nobreakhline{%
  \ifx\@let@token\hline
    \global\let\@gtempa\@gobble
    \gdef\LT@sep{\penalty\@M\vskip\doublerulesep}% <-- change here
  \else
    \global\let\@gtempa\@empty
    \gdef\LT@sep{\penalty\@M\vskip-\arrayrulewidth}% <-- change here
  \fi
  \ifnum0=`{\fi}%
  \multispan\LT@cols
     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
  \noalign{\LT@sep}%
  \multispan\LT@cols
     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
  \noalign{\penalty\@M}%
  \@gtempa}
\makeatother
%%%
\begin{document}
\Large %quick and dirty
\sffamily

\setlength{\tabcolsep}{10pt}
\begin{longtable}[]{ll@{}lr@{ - }l}% 
\endfirsthead
\endhead
\multicolumn{5}{c}{\textit{next page continues}} \\
\endfoot
\hline\hline % two horiz. lines at the end of table
\endlastfoot
%%%%%%%%%%%%%%%%%%%%
%first tab row
%
% Headline
\multicolumn{5}{@{}l}{\textbf{Business Herbert}}  Operating times (00:00)07:00 - 16:30\\* \nobreakhline
% Column desc
Contact & {Phone} & & Break from&to \\* \nobreakhline
% Rows
B\"uro & 71073 & 707 62 & 12:30 & 13:00  \\* 
Dimitri & 20573 & 070 37 10 &   & \\*  
Dimitri & 2060 & 00 57 71 71 &   & \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Alma & 20516 & 655 12 30 & 12:30 & 13:00  \\*  
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Georg & 2060 & 706 10 60 &    & \\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Gottfried \& Shirin}}  Operating times (00:00)07:00 - 16:30\\* \nobreakhline% Column desc
Contact & {Phone} & & Break from&to \\* \nobreakhline
Shirin & 20523 & 370 70 00 & 00:00 & 00:20  \\* 
Jessy & 2077 & 076 55 22 & 12:00  & 12:30 \\*  
Leo & 2077 & 525 03 71 & 15:00  & 15:30\\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Jorge}}  Operating times 07:30 - 16:30\\* \nobreakhline
Contact & {Phone} &    & Break from&to \\* \nobreakhline
Jorge     & 2072  & 263 30 26 & 12:00  & 13:00  \\* 
Gabi  & 20525 & 733 76 75 & 12:00  & 13:00 \\*  
Quintus & 2070  & 013 07 23 & 12:00  & 13:00 \\*  
Sokrates   & 20522 & 730 50 30 & 12:00  & 13:00 \\[1cm] 
\multicolumn{3}{@{}l}{\textbf{Pascal} \Smiley}   Operating times& & \\* \nobreakhline
Contact & {Phone} & & Break from&to \\* \nobreakhline
Pascal & 2072 & 730 05 75 &  &   \\* 
Pascal & 2072 & 730 05 75 &  &   \\  [1cm] %
\multicolumn{5}{@{}l}{\textbf{Business Herbert}}  Operating times (00:00)07:00 - 16:30\\* \nobreakhline
Contact & {Phone} & & Break from&to \\* \nobreakhline
B\"uro & 71073 & 707 62 & 12:30 & 13:00  \\* 
Dimitri & 20573 & 070 37 10 &   & \\*  
Dimitri & 2060 & 00 57 71 71 &   & \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Alma & 20516 & 655 12 30 & 12:30 & 13:00  \\*  
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Georg & 2060 & 706 10 60 &    & \\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Gottfried \& Shirin}}  Operating times (00:00)07:00 - 16:30\\* \nobreakhline
Contact & {Phone} & & Break from&to \\*\nobreakhline
Shirin & 20523 & 370 70 00 & 00:00 & 00:20  \\* 
Jessy & 2077 & 076 55 22 & 12:00  & 12:30 \\*  
Leo & 2077 & 525 03 71 & 15:00  & 15:30\\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Jorge}}  Operating times 07:30 - 16:30\\* \nobreakhline
Contact & {Phone} &    & Break from&to \\* \nobreakhline
Jorge     & 2072  & 263 30 26 & 12:00  & 13:00  \\* 
Gabi  & 20525 & 733 76 75 & 12:00  & 13:00 \\*  
Quintus & 2070  & 013 07 23 & 12:00  & 13:00 \\*  
Sokrates   & 20522 & 730 50 30 & 12:00  & 13:00 \\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Herbert}}  Operating times (00:00)07:00 - 16:30\\*  \nobreakhline
Contact & {Phone} & & Break from&to \\* \nobreakhline
B\"uro & 71073 & 707 62 & 12:30 & 13:00  \\* 
Dimitri & 20573 & 070 37 10 &   & \\*  
Dimitri & 2060 & 00 57 71 71 &   & \\*  
Herbert & 2073 & 272 25 75 & 00:00 & 00:30  \\*  
Alma & 20516 & 655 12 30 & 12:30 & 13:00  \\*  
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Johannes & 20520 & 700 37 00 & 15:00 & 15:10  \\*
Georg & 2060 & 706 10 60 &    & \\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Gottfried \& Shirin}}  Operating times (00:00)07:00 - 16:30\\*  \nobreakhline
Contact & {Phone} & & Break from&to \\* \nobreakhline
Shirin & 20523 & 370 70 00 & 00:00 & 00:20  \\* 
Jessy & 2077 & 076 55 22 & 12:00  & 12:30 \\*  
Leo & 2077 & 525 03 71 & 15:00  & 15:30\\[1cm] 
\multicolumn{5}{@{}l}{\textbf{Business Jorge}}  Operating times 07:30 - 16:30\\*  \nobreakhline
Contact & {Phone} &    & Break from&to \\* \nobreakhline
Jorge     & 2072  & 263 30 26 & 12:00  & 13:00  \\* 
Gabi  & 20525 & 733 76 75 & 12:00  & 13:00 \\*  
Quintus & 2070  & 013 07 23 & 12:00  & 13:00 \\*  
Sokrates   & 20522 & 730 50 30 & 12:00  & 13:00 \\[1cm] 
\multicolumn{3}{@{}l}{\textbf{Pascal} \Smiley}   Operating times& & \\*  \nobreakhline
Contact & {Phone} & & Break from&to \\* \nobreakhline
Pascal & 2072 & 730 05 75 &  &   \\[1cm] 
\multicolumn{3}{@{}l}{\textbf{Pascal} \Smiley}   Operating times& & \\*  \nobreakhline
Contact & {Phone} & & Break from&to \\* \nobreakhline
Pascal & 2072 & 730 05 75 &  &   \\[1cm] 
\end{longtable}
\end{document}

Output with pdflatex:

p.1 p.2 p.3

gizeh
  • 491