emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jacob Gerlach <jacobgerlach@gmail.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Internal Links with Spaces
Date: Wed, 11 Mar 2015 09:34:55 -0400	[thread overview]
Message-ID: <CAA6UvuG8LVZ0AGh8BpNKXBo=ePViPkguUXqVHyrPDwR5dq8KaA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 771 bytes --]

On Tue, Mar 10, 2015 at 3:47 PM, Jacob Gerlach <jacobgerlach@gmail.com> wrote:
> After finally getting this function to work, I discovered that I had
> the same problem as when I used org-id: the link description causes
> exported latex references to use the headline text instead of the
> \label{}.
> This works for me, but I'd love to find a more elegant approach:

I had been waffling on whether to switch to the git version of org.
This was motivation to make the switch, so I decided to give a shot at
patching this.

Attached patch introduces `org-latex-prefer-section-references'. If
non-nil, links will use the generated \label even if the link has a

I believe I did everything right - commit message, no failures on make test...


[-- Attachment #2: 0001-ox-latex.el-Customize-link-export-behavior.patch --]
[-- Type: text/x-patch, Size: 1984 bytes --]

From 50829ce7891bd9cd5c654da346ae1981fe6339f7 Mon Sep 17 00:00:00 2001
From: Jacob Gerlach <jacobgerlach@gmail.com>
Date: Wed, 11 Mar 2015 09:15:46 -0400
Subject: [PATCH] ox-latex.el: Customize link export behavior

* lisp/ox-latex.el (org-latex-prefer-section-references): Add new
  (org-latex-link): Use customization when resolving links to

 lisp/ox-latex.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 6cec8a1..e1b2647 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -510,6 +510,17 @@ and resolve links into section references."
   :version "25.1"
   :package-version '(Org . "8.3"))
+(defcustom org-latex-prefer-section-references nil
+   "Toggle use of link descriptions for generating section labels.
+When this variable is non-nil, Org will resolve links into
+section references even when the link has a description."
+  :group 'org-export-latex
+  :version "25.1"
+  :package-version '(Org . "8.3")
+  :type 'boolean)
 ;;;; Footnotes
 (defcustom org-latex-footnote-separator "\\textsuperscript{,}\\,"
@@ -2075,14 +2086,15 @@ INFO is a plist holding contextual information.  See
 	  ;; LINK points to a headline.  If headlines are numbered
 	  ;; and the link has no description, display headline's
 	  ;; number.  Otherwise, display description or headline's
-	  ;; title.
+	  ;; title depending on the value of 
+	  ;; org-latex-prefer-section-references
 	   (let* ((custom-label
 		   (and (plist-get info :latex-custom-id-labels)
 			(org-element-property :CUSTOM_ID destination)))
 		  (label (or custom-label
 			     (org-export-get-headline-id destination info))))
-	     (if (and (not desc)
+	     (if (and (or (not desc) org-latex-prefer-section-references)
 		      (org-export-numbered-headline-p destination info))
 		 (format "\\ref{%s}" label)
 	       (format "\\hyperref[%s]{%s}" label

             reply	other threads:[~2015-03-11 13:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 13:34 Jacob Gerlach [this message]
2015-03-11 13:41 ` [PATCH] Internal Links with Spaces Nicolas Goaziou
2015-03-11 13:58 Jacob Gerlach
2015-03-11 14:17 ` Nicolas Goaziou
2015-03-11 14:36   ` Jacob Gerlach
2015-03-11 14:52     ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA6UvuG8LVZ0AGh8BpNKXBo=ePViPkguUXqVHyrPDwR5dq8KaA@mail.gmail.com' \
    --to=jacobgerlach@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).