[Top][All Lists]

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

Re: [AUCTeX-devel] Any equivalent to `reftex-label' in AUCTeX

From: Mosè Giordano
Subject: Re: [AUCTeX-devel] Any equivalent to `reftex-label' in AUCTeX
Date: Tue, 18 Aug 2015 23:35:17 +0200

Hi Arash,

2015-08-18 22:19 GMT+02:00 Arash Esbati <address@hidden>:
> Hi all,
> caption.sty has an undocumented command `\captionbox' with the following
> syntax:
>     \captionbox[list entry]{heading}[width][inner-pos]{contents}
>     \captionbox*{heading}[width][inner-pos]{contents}
> `heading' contains the caption text and the `\label{}'.  Currently, I
> have the following code in `caption.el' to implement this command:
> --8<---------------cut here---------------start------------->8---
> (defun LaTeX-arg-caption-captionbox (optional &optional prompt)
>   "Query for the arguments of `\\captionbox' incl. a label and
> insert them."
>   (let* ((caption (TeX-read-string (TeX-argument-prompt optional prompt 
> "Caption")))
>          (label   (if (fboundp 'reftex-label)
>                       (reftex-label nil t)
>                     (TeX-read-string (TeX-argument-prompt optional prompt 
> "Label"))))
>          (width   (completing-read (TeX-argument-prompt t prompt "Width")
>                                    (mapcar (lambda(elt) (concat TeX-esc (car 
> elt)))
>                                            (LaTeX-length-list))))
>          (inpos   (completing-read (TeX-argument-prompt t prompt "Inner 
> position")
>                                    '("c" "l" "r" "s")))
>          (heading (format "%s\\label{%s}" caption label)))
>     (LaTeX-indent-line)
>     (TeX-argument-insert heading optional)
>     (cond (;; 2 optional args
>            (and width (not (string-equal width ""))
>                 inpos (not (string-equal inpos "")))
>            (insert (format "[%s][%s]" width inpos)))
>           (;; 1st empty opt. arg, 2nd opt. arg
>            (and (string-equal width "")
>                 inpos (not (string-equal inpos "")))
>            (insert (format "[][%s]" inpos)))
>           (;; 1st opt. arg, 2nd empty opt. arg
>            (and width (not (string-equal width ""))
>                 (string-equal inpos ""))
>            (insert (format "[%s]" width)))
>           (t ; Do nothing if both empty
>            (ignore)))
>     (LaTeX-fill-paragraph)))
> (TeX-add-style-hook
>  "caption"
>  (lambda ()
>    '("captionbox"  [ "List entry" ] (LaTeX-arg-caption-captionbox) t)))
> --8<---------------cut here---------------end--------------->8---
> My question is, does AUCTeX has something equivalent to `reftex-label'
> or should I just read the label as a string?

To insert a new label there is `TeX-arg-define-label', instead to read
a label we have `TeX-arg-label'.  There is also `LaTeX-label' to
insert the whole "\label{}" macro (which is probably what you're
looking for, right?).  As a rule of thumb, in AUCTeX you should always
use these functions and avoid using reftex' ones, since the jobs are
seamlessly transferred to the reftex equivalents if
`reftex-plug-into-AUCTeX' has been called.


reply via email to

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