auctex+reftex 不会为 tcbcolorbox 环境插入标签

auctex+reftex 不会为 tcbcolorbox 环境插入标签

直到昨天,一切都很好,但今天auctex+reftex没有自动插入 keyval 样式标签。

我有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)

类似定理的环境的定义位于一个名为的乳胶样式文件中matyi.sty,我有一个相应matyi.el~/.emacs.d/site-lisp

当我进入C-c C-e环境时defn,它看起来就像

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

我原本以为是这样的

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

我有

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

在我的 Fedora Linux 36 系统上。

我也有

$ 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)

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"

答案1

AUCTeX 支持文件tcolorboxlib-theorems.el现在已正式成为 AUCTeX 发行版的一部分,但该文件自首次发布以来发生了一些变化。我认为最简单的解决方案是调整您的matyi.eltcolorboxlib-theorems.el实际上只是触及函数的参数LaTeX-add-tcolorbox-lib-theorems-newtcbtheorems。新版本可能如下所示:

(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)

您还可以重置现在加载reftex-label-alist时已完成的添加。matyi.el

相关内容