ox-latex: Improve handling of footnotes within verse blocks

* lisp/ox-latex.el (org-latex-footnote-reference): Use the footmark +
footnotetext combination for footnotes in verse environments.
(org-latex-verse-block): Use `org-latex--delayed-footnotes-definitions'.

Reported-by: Juan Manuel Macías <maciaschain@posteo.net>
<http://lists.gnu.org/r/emacs-orgmode/2020-12/msg00006.html>
This commit is contained in:
Nicolas Goaziou 2020-12-05 10:05:46 +01:00
parent b0a3079970
commit 7c8dce72bd

View file

@ -1888,10 +1888,11 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(org-export-get-footnote-definition footnote-reference info)
info t)))
;; Use \footnotemark if reference is within another footnote
;; reference, footnote definition, table cell or item's tag.
;; reference, footnote definition, table cell, verse block, or
;; item's tag.
((or (org-element-lineage footnote-reference
'(footnote-reference footnote-definition
table-cell))
table-cell verse-block))
(eq 'item (org-element-type
(org-export-get-parent-element footnote-reference))))
"\\footnotemark")
@ -1903,7 +1904,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;; Only insert a \label if there exist another
;; reference to def.
(cond ((not label) "")
((org-element-map (plist-get info :parse-tree) 'footnote-reference
((org-element-map (plist-get info :parse-tree)
'footnote-reference
(lambda (f)
(and (not (eq f footnote-reference))
(equal (org-element-property :label f) label)
@ -3504,21 +3506,25 @@ channel."
"Transcode a VERSE-BLOCK element from Org to LaTeX.
CONTENTS is verse block contents. INFO is a plist holding
contextual information."
(org-latex--wrap-label
verse-block
;; In a verse environment, add a line break to each newline
;; character and change each white space at beginning of a line
;; into a space of 1 em. Also change each blank line with
;; a vertical space of 1 em.
(format "\\begin{verse}\n%s\\end{verse}"
(replace-regexp-in-string
"^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m)))
(concat
(org-latex--wrap-label
verse-block
;; In a verse environment, add a line break to each newline
;; character and change each white space at beginning of a line
;; into a space of 1 em. Also change each blank line with
;; a vertical space of 1 em.
(format "\\begin{verse}\n%s\\end{verse}"
(replace-regexp-in-string
"^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
"^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m)))
(replace-regexp-in-string
"\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n"
contents nil t) nil t) nil t))
info))
"^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
(replace-regexp-in-string
"\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n"
contents nil t) nil t) nil t))
info)
;; Insert footnote definitions, if any, after the environment, so
;; the special formatting above is not applied to them.
(org-latex--delayed-footnotes-definitions verse-block info)))