Auto labeling environments in AUCTeX

auctex, emacs, latex

Solution

Finally got it.

I was not aware that after adding something like

(setq reftex-label-alist
      '(
        ("theorem" ?t "thm:" "~\\ref{%s}" t  ("theorem" "th."))
        ))

to my `.emacs` I should do

reftex-reset-mode

If I put this into `.emacs` after my RefTeX options then everything works great.

Problem

If I insert some environment in AUCTeX by `C-c C-e` (for example `equation` or `figure`) then AUCTeX ask for a label with auto-inserted text `eq:` or `fig:`. I would like to add `theorem` environment to LaTeX environments in AUCTeX. I done this by ``` (add-hook 'LaTeX-mode-hook (lambda () (LaTeX-add-environments '("theorem" LaTeX-env-label) ))) ``` Moreover I hove something like ``` (setq reftex-label-alist '( ("theorem" ?t "thm:" "~\\ref{%s}" t ("theorem" "th.")) )) ``` Then when I use `C-c C-e` to add `theorem` environment then it ask for a label for a theorem but without auto `thm:` text. I need to add this manually. Is it possible to make AUCTeX add `theorem` environment acts the same as `equation` or `figure` adding auto `thm:` text to a label? To clarify, if I add `theorem` environment without a label and then use `C-c (` to use RefTeX to add a label then it ask for a label in the form `thm:`.

Original source