Auto labeling environments in AUCTeX
Asked Answered
C

1

10

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:.

Crudity answered 7/5, 2012 at 0:14 Comment(4)
have you set reftex-plug-into-AUCTeX to t?Gibbon
@rvf0068: yes, it's turned on.Crudity
@Gibbon now it works but i think there are still some issues: if you type theorem and then press C-c ), you can't select them for some reason.Conveyance
I can't explain it, but sometimes it helps me to reload the .tex buffer, and to reset AuCTeX (C-u C-c C-n).Gibbon
C
5

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.

Crudity answered 9/5, 2012 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.