From 81115d0884c165778520aa1b4d4fa83580417e1c Mon Sep 17 00:00:00 2001 From: Richard Lawrence Date: Sat, 15 Feb 2014 11:59:44 -0800 Subject: [PATCH] LaTeX export: support CUSTOM_ID property in section labels and link refs * lisp/ox-latex.el (org-latex-headline): when exporting a headline, if it has a CUSTOM_ID property, use that value as the associated label for a section (or whatever) (org-latex-link): when exporting a link, if the destination is a headline with a CUSTOM_ID property, use that value in the referencing command Fixes an issue raised at: http://thread.gmane.org/gmane.emacs.orgmode/54039 TINYCHANGE --- lisp/ox-latex.el | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 5815874..cbca0a5 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1372,11 +1372,14 @@ holding contextual information." (full-text (funcall org-latex-format-headline-function todo todo-type priority text tags)) ;; Associate \label to the headline for internal links. + ;; Use the value of :CUSTOM_ID: property as label if it is defined. (headline-label - (format "\\label{sec-%s}\n" - (mapconcat 'number-to-string - (org-export-get-headline-number headline info) - "-"))) + (let ((custom-label (org-element-property :CUSTOM_ID headline))) + (if custom-label (format "\\label{%s}\n" custom-label) + (format "\\label{sec-%s}\n" + (mapconcat 'number-to-string + (org-export-get-headline-number headline info) + "-"))))) (pre-blanks (make-string (org-element-property :pre-blank headline) 10))) (if (or (not section-fmt) (org-export-low-level-p headline info)) @@ -1846,11 +1849,15 @@ INFO is a plist holding contextual information. See ;; title. (headline (let ((label - (format "sec-%s" - (mapconcat - 'number-to-string - (org-export-get-headline-number destination info) - "-")))) + (or + ;; Case 1: headline has a CUSTOM_ID property; use that as label + (org-element-property :CUSTOM_ID destination) + ;; Case 2: headline has no CUSTOM_ID; use default numbering + (format "sec-%s" + (mapconcat + 'number-to-string + (org-export-get-headline-number destination info) + "-"))))) (if (and (plist-get info :section-numbers) (not desc)) (format "\\ref{%s}" label) (format "\\hyperref[%s]{%s}" label -- 1.7.10.4