[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multi-line headers with longtable

From: Brett Presnell
Subject: Multi-line headers with longtable
Date: Fri, 13 May 2022 18:29:34 -0400
User-agent: mu4e 1.6.10; emacs 29.0.50

Sorry I sent this twice.  Forgot that I was subscribed from my
member.fsf.org email address.

I have come upon a problem with export of multi-line table headers in
long (multi-page) tables.  I can't imagine that this hasn't come up
before, but I wasn't able to google up any other reports, so ...

As a simple example (using \pagebreak to reduce the number of rows
required to illustrate the problem), exporting the org table

#+attr_latex: :environment longtable
| First        | Second |
| Column       | Column |
| a            |      1 |
| b            |      2 |
| \pagebreak c |      3 |
| d            |      4 |

to LaTeX yields

First & Second\\
Column & Column\\
\multicolumn{2}{l}{Continued from previous page} \\

Column & Column \\

\hline\multicolumn{2}{r}{Continued on next page} \\
a & 1\\
b & 2\\
\pagebreak c & 3\\
d & 4\\

Notice that only the "firsthead" has the multi-line table header; on the
2nd page the columns will both have the one-line header "Column" when
I/we want the full column headers on every page.

This is using org version 9.5.3 and GNU Emacs 29.0.50 (snapshot).

I think that the problem occurs in the handling of the header in
org-latex-table-row.  The 2nd row ends the header, so in the excerpted
code below it is output as =contents=, i.e., it gets inserted for the
4th %s.  Of course this means that the previous lines of the header are

        ;; Special case for long tables.  Define header and footers.
        ((and longtablep (org-export-table-row-ends-header-p table-row info))
         (let ((columns (cdr (org-export-table-dimensions
                              (org-export-get-parent-table table-row) info))))
           (format "%s
\\multicolumn{%d}{l}{%s} \\\\
%s \\\\\n
%s\\multicolumn{%d}{r}{%s} \\\\
                   (if booktabsp "\\midrule" "\\hline")
                   (org-latex--translate "Continued from previous page" info)
                    ((not (org-export-table-row-starts-header-p table-row info))
                    (booktabsp "\\toprule\n")
                    (t "\\hline\n"))
                   (if booktabsp "\\midrule" "\\hline")
                   (if booktabsp "\\midrule" "\\hline")
                   (org-latex--translate "Continued on next page" info))))
        ;; When BOOKTABS are activated enforce bottom rule even when
        ;; no hline was specifically marked.
        ((and booktabsp (not (org-export-get-next-element table-row info)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]