在 supertabular 中使用 \nopagebreak (或类似)

在 supertabular 中使用 \nopagebreak (或类似)

我正在尝试在表格尾部添加带有计数器的多页表格。我首先尝试长桌但由于它在表格内容之前生成了头部和尾部,所以我不能使用计数器。所以我用了超表他们处理得很好。但我还想控制这个表的拆分,因为行是按不可拆分的组工作的(尽可能)。我试过了\无分页符\\*但似乎都没有用超表格式环境。

下面是一个示例,我希望我的两行组不会被破坏:

\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}

所以我的问题是,我如何无法在多页表上获得计数器和分页符控制?

谢谢。

编辑:我的真实文档以简化支持。\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}

答案1

您可以在有问题的行之前更改表格的目标高度。这将强制更早的分页符:

\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}

相关内容