[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] ox-latex.el --- CUSTOM_ID-as-section-label-in-latex-export
From: |
Eric Schulte |
Subject: |
[O] [PATCH] ox-latex.el --- CUSTOM_ID-as-section-label-in-latex-export |
Date: |
Mon, 24 Jun 2013 10:26:15 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
>From c087e84a8fd80b277bf064eb31f1b893c25f1b4a Mon Sep 17 00:00:00 2001
From: Eric Schulte <address@hidden>
Date: Mon, 24 Jun 2013 10:25:03 -0600
Subject: [PATCH] CUSTOM_ID as section label in latex export
When exporting to HTML, custom ids of headlines become references to
the resulting section in the exported document. This is both more
stable and more readable than using section numbers. This commit adds
this option to the latex exporter.
* lisp/ox-latex.el (org-latex-headline): If headlines have the CUSTOM_ID
property set, then this value is used as the label instead of the
section number.
---
lisp/ox-latex.el | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index f2c6261..68b43e1 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1399,10 +1399,15 @@ holding contextual information."
todo todo-type priority text tags))
;; Associate \label to the headline for internal links.
(headline-label
- (format "\\label{sec-%s}\n"
- (mapconcat 'number-to-string
- (org-export-get-headline-number headline info)
- "-")))
+ ;; Optionally use the custom-id instead of section number
+ (if (org-element-property :CUSTOM_ID headline)
+ (format "\\label{%s}\n"
+ (org-element-property :CUSTOM_ID headline))
+ (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))
--
1.8.3.1
--
Eric Schulte
http://cs.unm.edu/~eschulte
- [O] [PATCH] ox-latex.el --- CUSTOM_ID-as-section-label-in-latex-export,
Eric Schulte <=