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
This commit is contained in:
parent
872c1b99fb
commit
539728840f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue