[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 539728840f: ox-latex: Fix exporting longtable with
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 539728840f: ox-latex: Fix exporting longtable with multiline header |
Date: |
Sat, 23 Dec 2023 06:58:25 -0500 (EST) |
branch: externals/org
commit 539728840f7acae3d8e4853af580b6d43baad1e3
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
ox-latex: Fix exporting longtable with multiline header
* lisp/ox-latex.el (org-latex-table-row): Use all the rows when
constructing header definition.
* testing/lisp/test-ox-latex.el (test-ox-latex/longtable): Add new
test.
Reported-by: Brett Presnell <presnell@member.fsf.org>
Link: https://orgmode.org/list/87mt9zywco.fsf@localhost
---
lisp/ox-latex.el | 14 +++++++++++++-
testing/lisp/test-ox-latex.el | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 41c2d39940..1458ded021 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -4046,6 +4046,18 @@ a communication channel."
(org-export-get-previous-element table-row info) info))
"")
(t "\\midrule"))
+ ;; Memorize table header in case it is multiline. We need this
+ ;; information to define contents before "\\endhead" in longtable
environments.
+ (when (org-export-table-row-in-header-p table-row info)
+ (let ((table-head-cache (plist-get info :org-latex-table-head-cache)))
+ (unless (hash-table-p table-head-cache)
+ (setq table-head-cache (make-hash-table :test #'eq))
+ (plist-put info :org-latex-table-head-cache table-head-cache))
+ (if-let ((head-contents (gethash (org-element-parent table-row)
table-head-cache)))
+ (puthash (org-element-parent table-row) (concat head-contents
org-latex-line-break-safe "\n" contents)
+ table-head-cache)
+ (puthash (org-element-parent table-row) contents
table-head-cache))))
+ ;; Return LaTeX string as the transcoder.
(concat
;; When BOOKTABS are activated enforce top-rule even when no
;; hline was specifically marked.
@@ -4075,7 +4087,7 @@ a communication channel."
"")
(booktabsp "\\toprule\n")
(t "\\hline\n"))
- contents
+ (gethash (org-element-parent table-row) (plist-get info
:org-latex-table-head-cache))
(if booktabsp "\\midrule" "\\hline")
(if booktabsp "\\midrule" "\\hline")
columns
diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el
index 5c58cce68e..35e37e46ad 100644
--- a/testing/lisp/test-ox-latex.el
+++ b/testing/lisp/test-ox-latex.el
@@ -58,5 +58,40 @@ lorem ipsum dolor\\\\[0pt]
lorem ipsum dolor\\\\[0pt]
\\end{verse}"))))
+(ert-deftest test-ox-latex/longtable ()
+ "Test table export with longtable environment."
+ (org-test-with-exported-text
+ 'latex
+ "#+attr_latex: :environment longtable
+| First | Second |
+| Column | Column |
+|--------------+--------|
+| a | 1 |
+| b | 2 |
+| \\pagebreak c | 3 |
+| d | 4 |
+"
+ (goto-char (point-min))
+ (should
+ (search-forward
+ "\\begin{longtable}{lr}
+First & Second\\\\[0pt]
+Column & Column\\\\[0pt]
+\\hline
+\\endfirsthead"))
+ (goto-char (point-min))
+ (should
+ (search-forward
+ "First & Second\\\\[0pt]
+Column & Column \\\\[0pt]
+
+\\hline
+\\endhead"))
+ (goto-char (point-min))
+ (should
+ (search-forward
+ "\\hline\\multicolumn{2}{r}{Continued on next page} \\\\
+\\endfoot"))))
+
(provide 'test-ox-latex)
;;; test-ox-latex.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org 539728840f: ox-latex: Fix exporting longtable with multiline header,
ELPA Syncer <=