auctex-devel
[Top][All Lists]
Advanced

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

Re: problems with thmstools (and automatic insertion of labels (reftex)


From: Arash Esbati
Subject: Re: problems with thmstools (and automatic insertion of labels (reftex)
Date: Mon, 27 Mar 2023 09:46:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Uwe Brauer <oub@mat.ucm.es> writes:

> In a moment because right now I have a more pressing problem:
>
> I put 
> (add-to-list 'LaTeX-label-alist '("cor" . "cor:"))

This should also go into a hook, but I think you really should solve
this differently.

> To my reftex_init file, because it is then more convenient to
> configure the labels.
>
> I load the reftex_init file from my auctex_init file
>
> Like this 
>
>
> ,----
> | (load "auctex.el" nil t t)
> | (load "preview-latex.el" nil t t)
> | 
> | (require 'tex-site)
    ^^^^^^^^^^^^^^^^^^

Don't do this; (load "auctex.el" nil t t) is sufficient.

> In my reftex_init file I have added
> (add-to-list 'LaTeX-label-alist '("cor" . "cor:"))
>
> However when restarting emacs I obtain the following error, I attach.
>
> Since this label is defined in auctex's latex.el
>
> I thought 
> (require 'latex)
>
> In my reftex_init file would solve the issue but it did not. I could
> try out an explicit load-file command, but I presume there are more
> elegant solutions.

I strongly suggest that you write a small LaTeX package
ub-thmtools-envs.sty like this and put it where TeX can find it:

--8<---------------cut here---------------start------------->8---
\ProvidesPackage{ub-thmtools-envs}[2023/03/27 v1.0]
\RequirePackage{thmtools}
\declaretheorem{cor}[%
  name=Corollary,
  Refname={Corollary,Corollaries},
  numberwithin=section
]
\declaretheorem{lem}[%
  name=Lemma,
  Refname={Lemma,Lemmas},
  numberwithin=section
]
\declaretheorem{prop}[%
  name=Proposition,
  Refname={Proposition,Proposition},
  numberwithin=section
]
\declaretheorem{thm}[%
  name=Theorem,
  Refname={Theorem,Theorems},
  numberwithin=section
]
% ...
\endinput
--8<---------------cut here---------------end--------------->8---

Also write the corresponding AUCTeX style file ub-thmtools-envs.el and
put it where AUCTeX can find it:

--8<---------------cut here---------------start------------->8---
(TeX-add-style-hook
 "ub-thmtools-envs"
 (lambda ()
   (TeX-run-style-hooks "thmtools")

   ;; Tell AUCTeX
   (let ((envs '(("cor" . "cor")
                 ("lem" . "lem")
                 ("prop" . "prop")
                 ("thm" . "thm"))))
     (dolist (env envs)
       (LaTeX-add-thmtools-declaretheorems env)
       (add-to-list 'LaTeX-label-list env t)))

   ;; Tell RefTeX
   (when (fboundp 'reftex-add-label-environments)
     (reftex-add-label-environments
      '(("cor" ?C "cor:%f:" "~\\ref{%s}" t ("Corollary" "Cor." "C."))))) ))
--8<---------------cut here---------------end--------------->8---

Now you can get rid of all the hassle with your init setup and just
write this in your .tex file:

  \usepackage{ub-thmtools-envs}

and you should be just fine, assuming that you have paring enabled.  It
is much more maintainable than having all the stuff somewhere in you
init process.

Best, Arash



reply via email to

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