Function: org-latex--label
org-latex--label is a byte-compiled function defined in
ox-latex.el.gz.
Signature
(org-latex--label DATUM INFO &optional FORCE FULL)
Documentation
Return an appropriate label for DATUM.
DATUM is an element or a target type object. INFO is the
current export state, as a plist.
Return nil if element DATUM has no NAME or VALUE affiliated keyword or no CUSTOM_ID property, unless FORCE is non-nil. In this case always return a unique label.
Eventually, if FULL is non-nil, wrap label within "\\label{}".
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-latex.el.gz
(defun org-latex--label (datum info &optional force full)
"Return an appropriate label for DATUM.
DATUM is an element or a `target' type object. INFO is the
current export state, as a plist.
Return nil if element DATUM has no NAME or VALUE affiliated
keyword or no CUSTOM_ID property, unless FORCE is non-nil. In
this case always return a unique label.
Eventually, if FULL is non-nil, wrap label within \"\\label{}\"."
(let* ((type (org-element-type datum))
(user-label
(org-element-property
(cl-case type
((headline inlinetask) :CUSTOM_ID)
(target :value)
(otherwise :name))
datum))
(label
(and (or user-label force)
(if (and user-label (plist-get info :latex-prefer-user-labels))
user-label
(concat (pcase type
(`headline "sec:")
(`table "tab:")
(`latex-environment
(and (string-match-p
org-latex-math-environments-re
(org-element-property :value datum))
"eq:"))
(`latex-matrices "eq:")
(`paragraph
(and (org-element-property :caption datum)
"fig:"))
(`src-block "lst:")
(_ nil))
(org-export-get-reference datum info))))))
(cond ((not full) label)
(label (format "\\label{%s}%s"
label
(if (eq type 'target) "" "\n")))
(t ""))))