pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

caption for table with header is not repeated on pagebreak in latex output

Open MrApe opened this issue 7 years ago • 9 comments

Hey there,

I noticed, that a long table is broken into pages, but the caption is not repeated if the table has a header. If not the caption is repeated. Two questions:

  1. Is this intended behavior?
  2. How do I force repetition of the caption for tables with headers?

min_example.zip attached. The template is the latest default from 7f97b04862ffbe2bb9efaa648eee284f7949d20d.

This markdown creates tables.pdf.

Best, Jonas

MrApe avatar Apr 17 '18 08:04 MrApe

I didn't intend this. I assume this is just something longtable does. Maybe there's a longtable option that affects this? If so, we could consider including it. (And we should also consider which behavior is best.)

jgm avatar Apr 17 '18 17:04 jgm

This will require Haskell code change. We need to repeat the caption text twice, once for first page and once for each later pages. Here is a diff against test case:

--- tables.orig.tex     2018-05-02 13:23:52.772533100 +0200
+++ tables.tex  2018-05-02 13:49:59.043398200 +0200
@@ -73,6 +73,8 @@ header\strut
 \end{minipage}\tabularnewline
 \midrule
 \endfirsthead
+\caption[]{Very long table with caption and header. This one breaks
+without repeating the caption.}\tabularnewline
 \toprule
 \begin{minipage}[b]{0.21\columnwidth}\raggedright
 table\strut
@@ -411,6 +413,10 @@ laborum.\strut
 \caption{Very long table with caption but without header. This one
 breaks with repeating the caption.}\tabularnewline
 \toprule
+\endfirsthead
+\caption[]{Very long table with caption but without header. This one
+breaks with repeating the caption.}\tabularnewline
+\toprule
 \endhead
 \begin{minipage}[t]{0.21\columnwidth}\raggedright
 Lorem\strut
@@ -735,4 +741,7 @@ laborum.\strut
 \bottomrule
 \end{longtable}

+\newpage
+\listoftables
+
 \end{document}

There is also a secondary issue that tables show up multiple times in list of tables if the caption is not repeated like above with the [].

wilx avatar May 02 '18 11:05 wilx

Here is an updated tables.md and rendered PDF created by patched Pandoc, for reference.

tables.md.txt tables.pdf

wilx avatar May 03 '18 20:05 wilx

We agree, I think, that this should not depend on whether the table has a header. But which behavior do we want? Do we want the caption to repeat when the table is continued, or not? Is there some standard for this?

jgm avatar May 08 '18 16:05 jgm

I assume that different publishers will have different guidelines regarding this. I believe APA does suggest the use of "continued . . ." captions for multi-page tables. For what it's worth, the thesis and dissertation syle guide at my university (The University of Texas at Austin) requires the table caption on each page (hence why I'm interested in seeing where this conversation goes).

juandpinto avatar May 08 '18 16:05 juandpinto

@jgm commented on May 8, 2018, 6:39 PM GMT+2:

We agree, I think, that this should not depend on whether the table has a header. But which behavior do we want? Do we want the caption to repeat when the table is continued, or not? Is there some standard for this?

Can't we make the repetition optional then?

wilx avatar May 08 '18 22:05 wilx

If it's optional, what determines it? We don't have attributes on tables.

jgm avatar May 10 '18 04:05 jgm

Are there updates on this issue?

aperium avatar Jan 04 '19 18:01 aperium

Using the etoolbox package, we can modify the output with the following in header-includes:

    - \usepackage{etoolbox}
    #
    # add bottom rule to every page on long tables:
    # --------------------------------------------------------------------------
    - \appto{\endhead}{\specialrule{0pt}{0pt}{0pt}\bottomrule\endfoot}
    #
    # continue table caption on next page:
    # --------------------------------------------------------------------------
    - \appto{\endfirsthead}{\specialrule{0pt}{0pt}{0pt}\caption[]{(continued)} \\}

note: \bottomrule counts as table row, as do caption and header, therefore we may add \specialrule to keep odd and even rows numbering (important if you use the \rowcolors for "striped" tables).

I also added bottom rule on every page.

Using the markdown submitted by @MrApe - this is the result: newtables.pdf

priiduonu avatar Jun 02 '25 22:06 priiduonu