forked from mirrors/org-mode
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.
This commit is contained in:
parent
f70e36252a
commit
f092cb30d9
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue