From 304f18cb72dbb3aeade41ed6c5e8dfefca7e1744 Mon Sep 17 00:00:00 2001 From: Hugo Heagren Date: Thu, 1 Dec 2022 23:24:10 +0000 Subject: [PATCH] lisp/ox-latex.el: put labels inside example blocks * lisp/ox-latex.el (org-latex-example-block): Instead of `org-latex--wrap-label', manually add label after \begin{}. This produces proper label resolution in LaTeX. Labels before the environment begins can be interpreted as referring to the surrounding section. --- lisp/ox-latex.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 5b29a284c..63070d0f9 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2131,13 +2131,13 @@ information." (let ((environment (or (org-export-read-attribute :attr_latex example-block :environment) "verbatim"))) - (org-latex--wrap-label - example-block - (format "\\begin{%s}\n%s\\end{%s}" - environment - (org-export-format-code-default example-block info) - environment) - info)))) + (format "\\begin{%s}%s\n%s\\end{%s}" + environment + (if (org-element-property :name example-block) + (org-latex--label example-block info nil 'full) + "") + (org-export-format-code-default example-block info) + environment)))) ;;;; Export Block