4

I know there are similar questions, but using \\* did not work for me.

What I want to achieve is that the last two rows of my table will be on the same page (and therefore no page break between them).

Please see the following example

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{lipsum}
\usepackage{geometry}
\geometry{left=1.8cm,right=1.8cm,top=7.3cm,bottom=2.5cm}

\begin{document}
    \begin{longtable}{@{}|p{1.7cm}|p{9.9cm}|p{2.6cm}|p{1.2cm}|}
        \hline
        a & \lipsum[1] & c & d\\\hline
        a & \lipsum[1] & c & d\\\hline
        a & \lipsum[1] & c & d\\\hline

        \multicolumn{1}{|l}{\textbf{Total}} & \multicolumn{3}{r|}{\bf 0} \\* \hline
        \multicolumn{4}{l}{\small I need to be just below Total}        
    \end{longtable}
\end{document}

which results in a page break between the last two rows.

Do you know why \\* isn't working? Am I using it in a wrong way?

3

\hline introduces an allowed breakpoint. It is possible to drop into internals and stop that but the easiest thing to do is put the last two rows in the last foot, ie put them at the start, marked with \endlastfoot

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.