Wierdl Máté <wierdlm...@gmail.com> writes: In your other message, you wrote:
> I think at stackexchange the file you gave was the same. The possible > difference hence is the installation of the newer auctex? Nope, the new one I posted here is more user friendly in terms parsing the `label prefix' argument and making it available to AUCTeX and RefTeX. Putting things like this: %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% eval: (add-to-list 'LaTeX-label-alist '("theorem" . "thm")) %%% eval: (reftex-add-label-environments '(("theorem" ?m "thm:" "~\\ref{%s}" nil ("Theorem" "theorem") nil))) %%% End: in your .tex file is not necessary. You can use diff on those styles to see the changes. > \documentclass{article} > \usepackage[theorems]{tcolorbox} > \usepackage{cleveref} > > \newtcbtheorem[ > crefname={definition}{definitions} > ] > {defn}{Definition}{}{defn} > > %theorem > \newtcbtheorem[ > use counter from=defn, > crefname={theorem}{theorems} > ] > {thm}{Theorem}{}{thm} > > %\usepackage{my} > > \begin{document} > \begin{thm}[label={thm:1}]{Big One}{} > $1=2$ > \end{thm} > \begin{defn}[label={defn:1}]{Bigdef}{} > BIG. > \end{defn} > > In \cref{defn:1,thm:1}. > \end{document} > > > But if I put the preamble into my.sty, so I have this tcbcolor_test1.tex > > \documentclass{article} > > > \usepackage{my} > > \begin{document} > \begin{thm}[label={thm:1}]{Big One}{} > $1=2$ > \end{thm} > \begin{defn}[label={defn:1}]{Bigdef}{} > BIG. > \end{defn} > > In \cref{defn:1,thm:1}. > \end{document} > > > Then AUCTeX won't know about these thm and defn environments and reftex > won't offer them when I do C-c ). This is the expected behaviour. AUCTeX sees the \usepackage{my} macro and tries to load my.el. Save the next lines as my.el and put it in a directory where AUCTeX can find it. (TeX-add-style-hook "my" (lambda () (TeX-run-style-hooks "tcolorbox" "tcolorboxlib-theorems" "cleveref") (LaTeX-add-tcolorbox-lib-theorems-newtcbtheorems '("defn" "defn") '("thm" "thm"))) :latex) Now open your file again and hit `C-c C-n'. Best, Arash