emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org f092cb3: ox-latex: Allow reference command to be cu


From: ELPA Syncer
Subject: [elpa] externals/org f092cb3: ox-latex: Allow reference command to be customised
Date: Wed, 9 Jun 2021 13:57:13 -0400 (EDT)

branch: externals/org
commit f092cb30d9d59f71a5e9b6093857d194ec43c7b7
Author: TEC <tec@tecosaur.com>
Commit: TEC <tec@tecosaur.com>

    ox-latex: Allow reference command to be customised
    
    * lisp/ox-latex.el (org-latex-reference-command): Create a new variable
    so the user may modify the reference command used.
    (org-latex-link): Make use of the new `org-latex-reference-command' when
    generating references for labels without a description (previously using
    \ref).
    (org-latex-prefer-user-labels): Mention the new
    `org-latex-reference-command' when describing the generated LaTeX
    referencing labels.
---
 lisp/ox-latex.el | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9724b0d..a45474e 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -381,6 +381,9 @@ will be exported to LaTeX as:
   This is section \\ref{sec:foo}.
   And this is still section \\ref{sec:foo}.
 
+A non-default value of `org-latex-reference-command' will change the
+command (\\ref by default) used to create label references.
+
 Note, however, that setting this variable introduces a limitation
 on the possible values for CUSTOM_ID and NAME.  When this
 variable is non-nil, Org passes their value to \\label unchanged.
@@ -400,6 +403,18 @@ references."
   :version "26.1"
   :package-version '(Org . "8.3"))
 
+(defcustom org-latex-reference-command "\\ref{%s}"
+  "Format string that takes a reference to produce a LaTeX reference command.
+
+The reference is a label such as sec:intro.  A format string of \"\\ref{%s}\"
+produces numbered references and will always work.  It may be desirable to make
+use of a package such as hyperref or cleveref and then change the format string
+to \"\\autoref{%s}\" or \"\\cref{%s}\" for example."
+  :group 'org-export-latex
+  :type 'string
+  :version "28.1"
+  :package-version '(Org . "9.5"))
+
 ;;;; Preamble
 
 (defcustom org-latex-default-class "article"
@@ -2606,7 +2621,7 @@ INFO is a plist holding contextual information.  See
           (let ((label (org-latex--label destination info t)))
             (if (and (not desc)
                      (org-export-numbered-headline-p destination info))
-                (format "\\ref{%s}" label)
+                (format org-latex-reference-command label)
               (format "\\hyperref[%s]{%s}" label
                       (or desc
                           (org-export-data
@@ -2614,7 +2629,7 @@ INFO is a plist holding contextual information.  See
           ;; Fuzzy link points to a target.  Do as above.
          (otherwise
           (let ((ref (org-latex--label destination info t)))
-            (if (not desc) (format "\\ref{%s}" ref)
+            (if (not desc) (format org-latex-reference-command ref)
               (format "\\hyperref[%s]{%s}" ref desc)))))))
      ;; Coderef: replace link with the reference name or the
      ;; equivalent line number.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]