1

I'm trying to add multipages tabulars with counters in tabular tail. I first tried longtable but as it generates head and tail before the table content I can't use counters. So I used supertable who handle this very well. But I also want to control the breaking of this table as lines works by groups which are not breakable (as much as possible). I tried \nopagebreak, \\* but none seems to work in supertabular environnement.

Here an example where I want that my 2-lines groups not to be breakable :

\documentclass[a4paper,12pt]{book}

\usepackage{helvet}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{supertabular}
\usepackage{lipsum}

\begin{document}
    \newcounter{MyCounter}

    \lipsum[1]

    \tablehead{
        \hline
        \normalsize\textbf{\uppercase{Name}} & \normalsize\textbf{\uppercase{Qty}} \\
    }

    \tabletail{
        \hline
        \textbf{\uppercase{Total}} & \arabic{MyCounter} \\
        \hline
    }

    \begin{supertabular}{|l|c|}
        %% This part is repeated X times and is not breakable
        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\
    \end{supertabular}
\end{document}

So my question how can't I get counters and page break control on multipage tables?

Thanks.

EDIT : My real document to ease support. \documentclass[a4paper,10pt]{book}

    \usepackage{helvet}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[francais]{babel}
    \usepackage[margin=0.5cm,headheight=7.7cm,headsep=0.5cm,includehead,includefoot]{geometry} %pas par defaut
    \usepackage{fancyhdr} %pas par defaut
    \usepackage{lastpage} %pas par defaut
    \usepackage{array} %pas par defaut?
    \usepackage{multirow} %pas par defaut
    \usepackage[draft]{graphicx} %pas par defaut
    \usepackage{eurosym} %pas par defaut
    \usepackage[breakwords]{truncate} %pas par d?aut
    \usepackage[table]{xcolor} %pas par defaut
    \usepackage{supertabular} %pas par defaut

    \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
    \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

    \renewcommand{\familydefault}{\sfdefault}
    \renewcommand{\headrulewidth}{0pt}

    \pagestyle{fancy}

    \fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
    \fancyhead[C]{
    \begin{tabular*}{20cm}{p{3.2cm}p{3.2cm}p{4.2cm}p{3.2cm}p{3.2cm}}
    \multicolumn{1}{l} {
    \begin{tabular}{l}
    \large\textbf{Client name} \\
    \footnotesize{Client addr}\\
    \footnotesize{ZIPCode City}\\
    \end{tabular}
    } & \multicolumn{2}{l}{\multirow{3}[2]{*}{
    \includegraphics[width=4.8cm,height=3cm,keepaspectratio]{path/img.ext}
    }} & \multicolumn{2}{r}{
    \begin{tabular}{r}
    \uppercase{FACTURE : invoiceNumber} \\
    \uppercase{DU : date}
    \end{tabular}
    } \\
    & & & & \\
    \multicolumn{1}{l}{
    \begin{tabular}{l}
    \footnotesize{somedata de value\euro} \\
    \footnotesize{TVA INTRA : administrationdata}\\
    \footnotesize{Code APE : administrationdata}
    \end{tabular}
    } & & \multicolumn{2}{l}{\multirow{4}[20]{*}{
    \begin{tabular}{c}
    \includegraphics[width=6.4cm,height=3cm,keepaspectratio]{\detokenize{path/img.ext}}
    \end{tabular}
    }} & \\
    & & & & \\
    \multicolumn{1}{l}{
    \begin{tabular}{l}
    \large\textbf{Facturé à:}
    \end{tabular}
    } & & & & \\
    & & & & \\
    \multicolumn{2}{l}{
    \begin{tabular}{l}
    \textbf{\uppercase{company name}} \\
    \small\uppercase{company addr} \\
    \small{ZIPCode City}
    \end{tabular}
    } & \multicolumn{3}{l}{
    \begin{tabular}{l}
    \small{\textbf{Pour tout courrier : }}\\
    \small{Company name addr} \\
    \small{ZIPCode City}
    \end{tabular}
    } \\
    & & & & \\
    \multicolumn{2}{l}
    {
    \begin{tabular}{l}
    \textbf{CIP :} uniqID \\
    \\
    \textbf{Compte débiteur :} bank account data
    \end{tabular}
    } & \multicolumn{3}{l}
    {
    \begin{tabular}{l}
    \small{\textbf{En cas de retour de marchandise : }}\\
    \small{Company name addr} \\
    \small{ZIPCode city}
    \end{tabular}
    }
    \end{tabular*}
    }

    \fancyfoot[CE,CO,LE,LO,RE,RO]{} %% clear out all footers
    \fancyfoot[C]{
    \textbf{Page \thepage /\pageref{LastPage}}
    }

    \begin{document}
    \tablehead{
    \hline
    \cellcolor{black} & \cellcolor{black} & \cellcolor{black} & \cellcolor{black} & \cellcolor{black} & \cellcolor{black} & \cellcolor{black} \\
    \cellcolor{black} & \cellcolor{black}\normalsize\color{white}\textbf{P.U.} & \cellcolor{black} & \cellcolor{black} & \cellcolor{black}\normalsize\color{white}\textbf{P.U. net} &
    \cellcolor{black}\normalsize\color{white}\textbf{Montant} & \cellcolor{black}\normalsize\color{white}\textbf{TVA} \\
    \multirow{-2}{*}{
    \cellcolor{black}\normalsize\color{white}\textbf{Désignation}
    } & \cellcolor{black}\normalsize\color{white}\textbf{Catalogue} & \multirow{-2}{*}{
    \cellcolor{black}\normalsize\color{white}\textbf{Remise}
    } & \normalsize\multirow{-2}{*}{
    \cellcolor{black}\normalsize\color{white}\textbf{Qté}
    } & \cellcolor{black}\normalsize\color{white}\textbf{H.T. (\euro)} & \cellcolor{black}\normalsize\color{white}\textbf{H.T. (\euro)} & \cellcolor{black}\color{white}\normalsize\textbf{(\%)} \\
    }

    \tabletail{
    \hline
    }

    \scriptsize{
    \noindent\begin{supertabular}{|p{9.7cm}|c|c|c|c|c|c|}
    \hline
     & & & & & & \\
    % Non-breakable repeated part
    \small\textbf{Bon de commande : deliveryOrderNumber} & & & & & & \\
    % Random times repeated sub-part
    \truncate{10cm}{
        \small{~~~~someText. long description}} & \small{price} & \small{discount} & \small{qty} & \small{price dis.} & \small{total} & \small{VAT} \\
    % End subpart
     & & & & & & \\
    % End part
    \end{supertabular}
    }

    \footnotesize{Some long and boring legal notices.}

    \noindent\normalsize\begin{tabular}{p{10cm}r}
    \begin{tabular}{l}
    \small{Facture n\degre{}invoiceNUmber établie par le mandataire CompanyName}\\
    \small{au nom et pour le compte de CompanyName}\\
    \\
    \small{échéance : date~~~~~montant total TTC : full price} \\
    \\
    \small{\textbf{Modalité de paiement :}} \\
    \small{Réglement par LCR directe au date}\\
    \small{\textbf{Nom du compte :} AccountName}\\
    \small{\textbf{Numéro : } AccountNumpber}
    \end{tabular}
    &
    \setlength{\extrarowheight}{6pt}
    \begin{tabular}{|c|c|c|c|}
    \hline
    montant HT & TVA & montant TVA & NET A PAYER \\
    \hline
    Tot(ex. VAT)\euro & VAT\% & VAT total\euro & Tot (incl. VAT)\euro \\
    \hline
    \multicolumn{3}{|r|}{Total NET à payer} & Tot. (incl. VAT)\euro \\
    \hline
    \end{tabular}
    \end{tabular}
    \end{document}
2

You can change the goal height of the tabular before the problematic line. This will force an earlier page break:

\documentclass[a4paper,12pt]{book}

\usepackage{helvet}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{supertabular}
\usepackage{lipsum}

\begin{document}
    \newcounter{MyCounter}

    \lipsum[1]

    \tablehead{
        \hline
        \normalsize\textbf{\uppercase{Name}} & \normalsize\textbf{\uppercase{Qty}} \\
    }

    \tabletail{
        \hline
        \textbf{\uppercase{Total}} & \arabic{MyCounter} \\
        \hline
    }

    \begin{supertabular}{|l|c|}
        %% This part is repeated X times and is not breakable
        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\
        \hline\shrinkheight{-\normalbaselineskip} 
        \addtocounter{MyCounter}{4} MyLabel & 4 \\\shrinkheight{\normalbaselineskip} 
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\

        \hline
        \addtocounter{MyCounter}{4} MyLabel & 4 \\
        SubLabel & \\
    \end{supertabular}
\end{document}
  • Thanks for reply, I forgot to say that I don't know on which line it will break because the repeated content has various number of lines and the content before the supertabular is also dynamic. – Thomas T. Jun 24 '16 at 15:21
  • Well then add the two \shrinkheight everywhere. – Ulrike Fischer Jun 24 '16 at 15:41
  • It works well on my MWE but not in my real document. It breaks the page too early and even on line that I don't want it to break. I will edit my original question to post my template for better support. – Thomas T. Jun 27 '16 at 8:20

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.