emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Multi-line headers with longtable
@ 2022-05-13 22:29 Brett Presnell
  2022-10-14  2:25 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Brett Presnell @ 2022-05-13 22:29 UTC (permalink / raw)
  To: emacs-orgmode


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"))))))


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-23 11:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 22:29 Multi-line headers with longtable Brett Presnell
2022-10-14  2:25 ` Ihor Radchenko
2023-12-23 11:06   ` Ihor Radchenko

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