emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Brett Presnell <presnell@member.fsf.org>
To: emacs-orgmode@gnu.org
Subject: Multi-line headers with longtable
Date: Fri, 13 May 2022 18:29:34 -0400	[thread overview]
Message-ID: <87mtfloyj9.fsf@ufl.edu> (raw)


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

\begin{longtable}{lr}
First & Second\\
Column & Column\\
\hline
\endfirsthead
\multicolumn{2}{l}{Continued from previous page} \\

Column & Column \\

\hline
\endhead
\hline\multicolumn{2}{r}{Continued on next page} \\
\endfoot
\endlastfoot
\hline
a & 1\\
b & 2\\
\pagebreak c & 3\\
d & 4\\
\end{longtable}
\end{document}

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
missing.


	;; 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
\\endfirsthead
\\multicolumn{%d}{l}{%s} \\\\
%s
%s \\\\\n
%s
\\endhead
%s\\multicolumn{%d}{r}{%s} \\\\
\\endfoot
\\endlastfoot"
		   (if booktabsp "\\midrule" "\\hline")
		   columns
		   (org-latex--translate "Continued from previous page" info)
		   (cond
		    ((not (org-export-table-row-starts-header-p table-row info))
		     "")
		    (booktabsp "\\toprule\n")
		    (t "\\hline\n"))
		   contents
		   (if booktabsp "\\midrule" "\\hline")
		   (if booktabsp "\\midrule" "\\hline")
		   columns
		   (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)))
	 "\\bottomrule"))))))


             reply	other threads:[~2022-05-13 22:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 22:29 Brett Presnell [this message]
2022-10-14  2:25 ` Multi-line headers with longtable Ihor Radchenko
2023-12-23 11:06   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtfloyj9.fsf@ufl.edu \
    --to=presnell@member.fsf.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).