auctex
[Top][All Lists]
Advanced

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

Re: key-val label style


From: Wierdl Máté
Subject: Re: key-val label style
Date: Fri, 18 Sep 2020 07:13:49 -0500

Thank you, Arash.  I think that's exactly what happened: I am using Fedora Linux, and it recently updated Emacs to 27.1.  

$ rpm -q emacs emacs-auctex
emacs-27.1-2.fc32.x86_64
emacs-auctex-12.1-8.fc32.noarch

I have written 3 books and some papers with tcolorbox and now I can't edit them in Emacs.  I'll look at what you are  suggesting.  

The most immediate problem is that in the notes I write for the class I am teaching  reftex doesn't show any of the references with label={ref} in them when I do C-c ), and I have well over hundred of them (lots of exercises), so manual referencing is out of the question.  

But yeah, it would be fantastic if Emacs could enter the environment with key-val style labels added automatically at the right place. 

Renumbering simple labels is very useful especially when I merge several documents but it's not as essential functionality. 

I remark that reftex doesn't recognize regular labels which have options, either.  For example, cleveref can use options like

\label[Theorem]{thm:1}

to give it a suggestion about what name to use in references.  This is handy when I want to use a single counter for all theoremlike environments.  I was going to switch to mdframed from tcolorbox, but it doesn't work with cref without labels with optional arguments. 

Máté

On Fri, Sep 18, 2020 at 5:17 AM Arash Esbati <arash@gnu.org> wrote:
Hi Máté,

Wierdl Máté <wierdlmate@gmail.com> writes:

> I am using the tcolorbox latex package which doesn't use the usual '\label'
> command.  Instead, one has to specify a label  in key-val form as in
>
> \begin{thm}[label={thm:1}]{}{}
>   $1=2/2$
> \end{thm}
>
> Is there a way to have reftex/auctex work with this variation?

AUCTeX/RefTeX were designed for vanilla LaTeX.  Additional packages are
supported via style files (within AUCTeX) and customization in RefTeX.
key-val labels are possible, but with some limitations (see below).

> What I mean is this
>
> 1) reftex keeps track of these as labels and  when I want to reference this
> theorem, 'C-c )' will show this to me.

You can add your environment to `reftex-label-regexps' in order to tell
RefTeX about `thm'.  But the regexp is somewhat complicated.

> (Until today, this was working fine, but now reftex doesn't recognize
> this form of a label.  I have no idea what happened, what's changed. )

Which version of Emacs are you using?  Have you updated to 27.1?
RefTeX's handling of key-val labels was changed there.

> 2) auctex/reftex enters a label in this key-val form when I do 'C-c ('.

You can teach AUCTeX to insert a key-val label when you insert the
environment with `C-c C-e ENV RET'; hitting `C-c (' in an environment
doesn't work.

> 3) the "renumber simple labels" function works with such references.

This is indeed a missing feature in RefTeX.  I never really looked how
RefTeX does this, hence I can't help.

Long time ago, I started writing a support file for tcolorbox's theorems
library.  That unfinished work is attached.  Set the variable
`TeX-style-private' to a directory of your choice, e.g.:

    (setq TeX-style-private
          (expand-file-name "~/.emacs.d/auctex-style"))

save the file there and open your .tex file.  Also hit `C-c C-n' to
parse your document.  Maybe you can report back if it works.

Best, Arash

reply via email to

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