From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: [PATCH] ox-latex.el --- CUSTOM_ID-as-section-label-in-latex-export Date: Mon, 24 Jun 2013 10:26:15 -0600 Message-ID: <87wqpjxyoo.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur9bx-000449-6n for emacs-orgmode@gnu.org; Mon, 24 Jun 2013 12:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur9bv-0001Qj-Sd for emacs-orgmode@gnu.org; Mon, 24 Jun 2013 12:27:25 -0400 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]:64972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur9bv-0001QJ-Mi for emacs-orgmode@gnu.org; Mon, 24 Jun 2013 12:27:23 -0400 Received: by mail-pb0-f52.google.com with SMTP id xa12so11234548pbc.11 for ; Mon, 24 Jun 2013 09:27:22 -0700 (PDT) Received: from bagel (c-174-56-50-60.hsd1.nm.comcast.net. [174.56.50.60]) by mx.google.com with ESMTPSA id i16sm20591544pag.18.2013.06.24.09.27.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 24 Jun 2013 09:27:21 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode Mailing List --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-CUSTOM_ID-as-section-label-in-latex-export.patch >From c087e84a8fd80b277bf064eb31f1b893c25f1b4a Mon Sep 17 00:00:00 2001 From: Eric Schulte 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 --=-=-= Content-Type: text/plain -- Eric Schulte http://cs.unm.edu/~eschulte --=-=-=--