1

I'm using longtable (via online TablesGenerator) but notice the continuation headings are styled slightly differently:

annotated grab of output

Here is the continuation:

<code>longtable</code> continuation page caption

I've already (in the second grab) removed a \bfseries macro that was bolding the whole continuation caption (also not in my MWE. I tried using a \caption{} wrapper but that broke the table (as it's actually within a row-wide table cell).

The issues I'd like to fix are noted in the MWE below. Note the MWE cell padding/spacing is slightly tighter than in the screen grabs above (my uni sty doc?) but the closer vertical spacing of the continuation vs. main heading is consistent in both cases and I assume internal to longtable. Here is the MWE:

\documentclass{report}
\usepackage{longtable}

%from my uni thisis sty file
\usepackage[centerlast,small,sc]{caption}

\begin{document}

This is a specimen table, note the \texttt{caption} macro sets the table caption in smaller than the body font size. Also the main caption sets `Table` in all caps with the non-initial letters in small caps.
\\

I'd ideally like the same styling in the continuation header, \textit{and} with the same slightly larger vertical space as below the main caption---though I don't know if that comes from the \texttt{caption} macro.

% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
% Please add the following required packages to your document preamble:
% \usepackage{longtable}
% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
\begin{longtable}[c]{l|rr}
    \caption{This is a main caption}
    \label{tab:my-tablex}\\
    Category & \multicolumn{1}{c|}{Count} & \multicolumn{1}{c}{\%} \\ \hline
    \endfirsthead
    %
    \multicolumn{3}{c}%
    {{Table \thetable\ (continued from previous page)}} \\
    Category & \multicolumn{1}{c|}{Count} & \multicolumn{1}{c}{\%} \\ \hline
    \endhead
    %
    AA & \multicolumn{1}{r|}{100} & 0.011 \\
    AB & \multicolumn{1}{r|}{104} & 0.012 \\
    AA & \multicolumn{1}{r|}{108} & 0.012 \\
    AB & \multicolumn{1}{r|}{112} & 0.012 \\
    AA & \multicolumn{1}{r|}{116} & 0.013 \\
    AB & \multicolumn{1}{r|}{120} & 0.013 \\
    AA & \multicolumn{1}{r|}{124} & 0.014 \\
    AB & \multicolumn{1}{r|}{128} & 0.014 \\
    AA & \multicolumn{1}{r|}{132} & 0.015 \\
    AB & \multicolumn{1}{r|}{136} & 0.015 \\
    AA & \multicolumn{1}{r|}{140} & 0.016 \\
    AB & \multicolumn{1}{r|}{144} & 0.016 \\
    AA & \multicolumn{1}{r|}{148} & 0.016 \\
    AB & \multicolumn{1}{r|}{152} & 0.017 \\
    AA & \multicolumn{1}{r|}{156} & 0.017 \\
    AB & \multicolumn{1}{r|}{160} & 0.018 \\
    AA & \multicolumn{1}{r|}{164} & 0.018 \\
    AB & \multicolumn{1}{r|}{168} & 0.019 \\
    AA & \multicolumn{1}{r|}{172} & 0.019 \\
    AB & \multicolumn{1}{r|}{176} & 0.020 \\
    AA & \multicolumn{1}{r|}{180} & 0.020 \\
    AB & \multicolumn{1}{r|}{184} & 0.020 \\
    AA & \multicolumn{1}{r|}{188} & 0.021 \\
    AB & \multicolumn{1}{r|}{192} & 0.021 \\
    AA & \multicolumn{1}{r|}{196} & 0.022 \\
    AB & \multicolumn{1}{r|}{200} & 0.022 \\
    AA & \multicolumn{1}{r|}{204} & 0.023 \\
    AB & \multicolumn{1}{r|}{208} & 0.023 \\
    AA & \multicolumn{1}{r|}{212} & 0.023 \\
    AB & \multicolumn{1}{r|}{216} & 0.024 \\
    AA & \multicolumn{1}{r|}{220} & 0.024 \\
    AB & \multicolumn{1}{r|}{224} & 0.025 \\
    AA & \multicolumn{1}{r|}{228} & 0.025 \\
    AB & \multicolumn{1}{r|}{232} & 0.026 \\
    AA & \multicolumn{1}{r|}{236} & 0.026 \\
    AB & \multicolumn{1}{r|}{240} & 0.027 \\
    AA & \multicolumn{1}{r|}{244} & 0.027 \\
    AB & \multicolumn{1}{r|}{248} & 0.027 \\
    AA & \multicolumn{1}{r|}{252} & 0.028 \\
    AB & \multicolumn{1}{r|}{256} & 0.028 \\
    AA & \multicolumn{1}{r|}{260} & 0.029 \\
    AB & \multicolumn{1}{r|}{264} & 0.029 \\
    AA & \multicolumn{1}{r|}{268} & 0.030 \\
    AB & \multicolumn{1}{r|}{272} & 0.030 \\
    AA & \multicolumn{1}{r|}{276} & 0.031 \\
    AB & \multicolumn{1}{r|}{280} & 0.031 \\
    AA & \multicolumn{1}{r|}{284} & 0.031 \\ \hline
    Totals & \multicolumn{1}{r}{ 9,024} & \\
\end{longtable}

\end{document}
4
  • 1
    use \caption[]{(continued from previous page)} for the continuation. Aug 5, 2019 at 11:50
  • @UlrikeFischer did you try that? If I do that thin the MWE, e.g. {{\caption{Table \thetable\ (continued from previous page)}}} \\ it errors immediately with a message "Misplaced \noalign. ...hetable\ (continued from previous page)}}}". I aslo tried putting the continuation caption inside the [ ] of the \caption[]{} but to the same result. So, I don't think the suggestion is viable. Could I ask you to post the MWE version that works for you as an answer? Many thanks!
    – mwra
    Aug 5, 2019 at 12:25
  • 1
    yes, I did try it ... Aug 5, 2019 at 12:58
  • Sorry my last probably seemed a bit abrupt. It wasn't meant that way :O, I simply lacked the smarts to figure it out form your description. I see from your answer (accepted below) that the caption is now not in a table row.
    – mwra
    Aug 5, 2019 at 14:53

1 Answer 1

1

Replace the continuation caption (everything including the \multicolumn)

\documentclass{report}
\usepackage{longtable}

%from my uni thisis sty file
\usepackage[centerlast,small,sc]{caption}

\begin{document}

This is a specimen table, note the \texttt{caption} macro sets the table caption in smaller than the body font size. Also the main caption sets `Table` in all caps with the non-initial letters in small caps.
\\

I'd ideally like the same styling in the continuation header, \textit{and} with the same slightly larger vertical space as below the main caption---though I don't know if that comes from the \texttt{caption} macro.

% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
% Please add the following required packages to your document preamble:
% \usepackage{longtable}
% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
\begin{longtable}[c]{l|rr}
    \caption{This is a main caption}
    \label{tab:my-tablex}\\
    Category & \multicolumn{1}{c|}{Count} & \multicolumn{1}{c}{\%} \\ \hline
    \endfirsthead
    %
   \caption[]{(continued from previous page)}\\
    Category & \multicolumn{1}{c|}{Count} & \multicolumn{1}{c}{\%} \\ \hline
    \endhead
    %
    AA & \multicolumn{1}{r|}{100} & 0.011 \\
    AB & \multicolumn{1}{r|}{104} & 0.012 \\
    AA & \multicolumn{1}{r|}{108} & 0.012 \\
    AB & \multicolumn{1}{r|}{112} & 0.012 \\
    AA & \multicolumn{1}{r|}{116} & 0.013 \\
    AB & \multicolumn{1}{r|}{120} & 0.013 \\
    AA & \multicolumn{1}{r|}{124} & 0.014 \\
    AB & \multicolumn{1}{r|}{128} & 0.014 \\
    AA & \multicolumn{1}{r|}{132} & 0.015 \\
    AB & \multicolumn{1}{r|}{136} & 0.015 \\
    AA & \multicolumn{1}{r|}{140} & 0.016 \\
    AB & \multicolumn{1}{r|}{144} & 0.016 \\
    AA & \multicolumn{1}{r|}{148} & 0.016 \\
    AB & \multicolumn{1}{r|}{152} & 0.017 \\
    AA & \multicolumn{1}{r|}{156} & 0.017 \\
    AB & \multicolumn{1}{r|}{160} & 0.018 \\
    AA & \multicolumn{1}{r|}{164} & 0.018 \\
    AB & \multicolumn{1}{r|}{168} & 0.019 \\
    AA & \multicolumn{1}{r|}{172} & 0.019 \\
    AB & \multicolumn{1}{r|}{176} & 0.020 \\
    AA & \multicolumn{1}{r|}{180} & 0.020 \\
    AB & \multicolumn{1}{r|}{184} & 0.020 \\
    AA & \multicolumn{1}{r|}{188} & 0.021 \\
    AB & \multicolumn{1}{r|}{192} & 0.021 \\
    AA & \multicolumn{1}{r|}{196} & 0.022 \\
    AB & \multicolumn{1}{r|}{200} & 0.022 \\
    AA & \multicolumn{1}{r|}{204} & 0.023 \\
    AB & \multicolumn{1}{r|}{208} & 0.023 \\
    AA & \multicolumn{1}{r|}{212} & 0.023 \\
    AB & \multicolumn{1}{r|}{216} & 0.024 \\
    AA & \multicolumn{1}{r|}{220} & 0.024 \\
    AB & \multicolumn{1}{r|}{224} & 0.025 \\
    AA & \multicolumn{1}{r|}{228} & 0.025 \\
    AB & \multicolumn{1}{r|}{232} & 0.026 \\
    AA & \multicolumn{1}{r|}{236} & 0.026 \\
    AB & \multicolumn{1}{r|}{240} & 0.027 \\
    AA & \multicolumn{1}{r|}{244} & 0.027 \\
    AB & \multicolumn{1}{r|}{248} & 0.027 \\
    AA & \multicolumn{1}{r|}{252} & 0.028 \\
    AB & \multicolumn{1}{r|}{256} & 0.028 \\
    AA & \multicolumn{1}{r|}{260} & 0.029 \\
    AB & \multicolumn{1}{r|}{264} & 0.029 \\
    AA & \multicolumn{1}{r|}{268} & 0.030 \\
    AB & \multicolumn{1}{r|}{272} & 0.030 \\
    AA & \multicolumn{1}{r|}{276} & 0.031 \\
    AB & \multicolumn{1}{r|}{280} & 0.031 \\
    AA & \multicolumn{1}{r|}{284} & 0.031 \\ \hline
    Totals & \multicolumn{1}{r}{ 9,024} & \\
\end{longtable}

\end{document}

enter image description here

2
  • Wonderful! Thank you!. This now works as an MWE here and, even better, when used in my actual thesis. Hurrah for the kindness of strangers. for latter readers who, like me are LaTeX novices, the secret of @UlrikeFischer's fix is the code lines within the table between the two lines with just a % character. I'm not sure I understand the mechanism, but I'm so pleased that it fixes my problem
    – mwra
    Aug 5, 2019 at 14:58
  • I meant to add that this solution also fixes an issue where my MWE version was causing the table's label to be declared once per page which logged a warning, e.g. Label `tab:my-tablex' multiply defined. and gave odd results in the list of tables.
    – mwra
    Aug 5, 2019 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .