1

Until yesterday, it was all well, but today auctex+reftex doesn't insert automatically the keyval style labels.

I have, as part of custom-set-variables

'(reftex-label-alist
   '(
     (nil 97 nil "~\\cref{%s}" nil nil)
     ("bigthm" ?b "bigthm:" "~\\cref{%s}" nil nil)
     ("conj" ?c "conj:" "~\\cref{%s}" nil nil)
     ("cor" ?C "cor:" "~\\cref{%s}" nil nil)
     ("defn" ?d "defn:" "~\\cref{%s}" nil nil)
     ("lem" ?l "lem:" "~\\cref{%s}" nil nil)
     ("problem" ?p "problem:" "~\\cref{%s}" nil nil)
     ("prop" ?P "prop:" "~\\cref{%s}" nil nil)
     ("quest" ?q "quest:" "~\\cref{%s}" nil nil)
     ("rem" ?r "rem:" "~\\cref{%s}" nil nil)
     ("thm" ?T "thm:" "~\\cref{%s}" nil nil)
     )
   t)

The definitions of the theorem-like environments are in a latex style file called matyi.styand I have a corresponding matyi.el in ~/.emacs.d/site-lisp

When I enter C-c C-e the defn environment ends up looking like

\begin{defn}{Average}{}
  
\end{defn}

while I expected something like

\begin{defn}[label={defn:1}]{Average}{}
  
\end{defn}

I have

$ rpm -q emacs emacs-auctex
emacs-28.1-2.fc36.x86_64
emacs-auctex-13.1-1.fc36.noarch

on my Fedora Linux 36 system.

I also have

$ cat ~/.emacs.d/site-lisp/matyi.el
(TeX-add-style-hook
     "matyi"
     (lambda ()
       (TeX-run-style-hooks "tcolorbox" "tcolorboxlib-theorems" "cleveref")
       (LaTeX-add-tcolorbox-lib-theorems-newtcbtheorems
        '("defn" "defn")
        '("thm" "thm")
    '("problem" "problem")
    '("prop" "prop")
    '("lem" "lem")
    '("quest" "quest")
    '("cor" "cor")
    '("conj" "conj")
    '("rem" "rem")
    ))
     :latex)

and

TeX-style-private is a variable defined in ‘tex.el’.

Its value is ("/home/apu/.emacs.d/site-lisp/")
Original value was 
("/home/apu/.emacs.d/auctex/style")

TeX-auto-local is a variable defined in ‘tex.el’.

Its value is "auto"
5
  • Can you add the content of your matyi.el to your question? And what's the value of the variable TeX-style-private? matyi.el should actually reside in a directory in that variable. And what's the value of TeX-auto-local? Aug 27, 2022 at 18:29
  • 1
    I added what you requested. Aug 27, 2022 at 20:18
  • Thanks, one last thing: You don't have AUCTeX also installed from ELPA by chance and have updated it shortly? Aug 28, 2022 at 8:25
  • No, I don't but I'll do that and will report back. Aug 30, 2022 at 14:13
  • I installed latest auctex via elpa, but I still see the error. I try to come up with a minimal working example. Aug 30, 2022 at 14:30

1 Answer 1

2

The AUCTeX support file tcolorboxlib-theorems.el is now officially part of AUCTeX distribution, but the file has changed a little since its first incarnation. I think the easiest solution is that you adjust your matyi.el to tcolorboxlib-theorems.el which is actually just touching the arguments of the function LaTeX-add-tcolorbox-lib-theorems-newtcbtheorems. The new version can look like this:

(TeX-add-style-hook
 "matyi"
 (lambda ()
   ;; Run only the style hook for 'tcolorbox'
   (TeX-run-style-hooks "tcolorbox" "cleveref")

   ;; This is the library we want to use:
   (LaTeX-add-tcolorbox-tcbuselibraries
    "theorems")

   ;; Now load the library with the provided function:
   (LaTeX-tcolorbox-load-used-libraries)

   ;; These are the additional environments defined in 'matyi.sty':
   (LaTeX-add-tcolorbox-lib-theorems-newtcbtheorems
    "conj"
    "cor"
    "defn"
    "lem"
    "problem"
    "prop"
    "quest"
    "rem"
    "thm")

   ;; Add the envs to `LaTeX-label-alist':
   (let ((envs '(("conj" . "conj:")
                 ("cor" . "cor:")
                 ("defn" . "defn:")
                 ("lem" . "lem:")
                 ("problem" . "problem:")
                 ("prop" . "prop:")
                 ("quest" . "quest:")
                 ("rem" . "rem:")
                 ("thm" . "thm:"))))
     (dolist (env envs)
       (add-to-list 'LaTeX-label-alist env t)))

   ;; Also make them available to RefTeX:
   (when (fboundp 'reftex-add-label-environments)
     (reftex-add-label-environments
      '(("conj" ?c "conj:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         nil)
        ("cor" ?C "cor:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         nil)
        ("defn" ?d "defn:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         (regexp "[Dd]efinitions?") nil)
        ("lem" ?l "lem:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         (regexp "[Ll]emmas?") nil)
        ("problem" ?p "problem:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         (regexp "[Pp]roblems?") nil)
        ("prop" ?P "prop:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         nil)
        ("quest" ?q "quest:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         nil)
        ("rem" ?r "rem:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         nil)
        ("thm" ?T "thm:" "~\\cref{%s}"
         LaTeX-tcolorbox-lib-theorems-reftex-label-context-function
         (regexp "[Tt]heorems?") nil)))) )
 :latex)

You can also reset your additions to reftex-label-alist which are now done when matyi.el is loaded.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .