Function: LaTeX-label

LaTeX-label is a byte-compiled function defined in latex.el.

Signature

(LaTeX-label NAME &optional TYPE NO-INSERT)

Documentation

Insert a label for NAME at point.

The optional TYPE argument can be either environment or section: in the former case this function looks up LaTeX-label-alist to choose which prefix to use for the label, in the latter case LaTeX-section-label(var)/LaTeX-section-label(fun) will be looked up instead. If TYPE is nil, you will be always prompted for a label, with an empty default prefix.

If LaTeX-label-function is a valid function, LaTeX label will transfer the job to this function.

If the optional NO-INSERT is non-nil, only the label is returned and no insertion happens. Otherwise the inserted label is returned, nil if it is empty.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-label (name &optional type no-insert)
  "Insert a label for NAME at point.
The optional TYPE argument can be either environment or section:
in the former case this function looks up `LaTeX-label-alist' to
choose which prefix to use for the label, in the latter case
`LaTeX-section-label' will be looked up instead.  If TYPE is nil,
you will be always prompted for a label, with an empty default
prefix.

If `LaTeX-label-function' is a valid function, LaTeX label will
transfer the job to this function.

If the optional NO-INSERT is non-nil, only the label is returned
and no insertion happens.  Otherwise the inserted label is
returned, nil if it is empty."
  (let ((TeX-read-label-prefix
         (cond
          ((eq type 'environment)
           (cdr (assoc name LaTeX-label-alist)))
          ((eq type 'section)
           (if (assoc name LaTeX-section-list)
               (if (stringp LaTeX-section-label)
                   LaTeX-section-label
                 (and (listp LaTeX-section-label)
                      (cdr (assoc name LaTeX-section-label))))
             ""))
          ((null type)
           "")
          (t
           nil)))
        ) ;; label
    (when (symbolp TeX-read-label-prefix)
      (setq TeX-read-label-prefix (symbol-value TeX-read-label-prefix)))
    (when TeX-read-label-prefix
      (funcall (or LaTeX-label-function #'LaTeX-label--default)
               name no-insert))))