Skip to content

The AUCTeX-RefTeX Interface

RefTeX contains code to interface with AUCTeX. When this interface is turned on, both packages will interact closely. Instead of using RefTeX’s commands directly, you can then also use them indirectly as part of the AUCTeX environment[1]. The interface is turned on with

emacs-lisp
(setq reftex-plug-into-AUCTeX t)

If you need finer control about which parts of the interface are used and which not, read the docstring of the variable reftex-plug-into-AUCTeX or customize it with M-x customize-variable RET reftex-plug-into-AUCTeX RET.

The following list describes the individual parts of the interface.

  • AUCTeX calls reftex-label to insert labels
    When a new section is created with C-c C-s, or a new environment is inserted with C-c C-e, AUCTeX normally prompts for a label to go with it. With the interface, reftex-label is called instead. For example, if you type C-c C-e equation RET, AUCTeX and RefTeX will insert

    latex
    \begin{equation}
    \label{eq:1}
    
    \end{equation}

    without further prompts.

    Similarly, when you type C-c C-s section RET, RefTeX will offer its default label which is derived from the section title.

  • AUCTeX tells RefTeX about new sections
    When creating a new section with C-c C-s, RefTeX will not have to rescan the buffer in order to see it.

  • RefTeX supplies macro arguments
    When you insert a macro interactively with C-c RET, AUCTeX normally prompts for macro arguments. Internally, it uses the functions TeX-arg-label, TeX-arg-cite, and TeX-arg-index to prompt for arguments which are labels, citation keys and index entries. The interface takes over these functions[2] and supplies the macro arguments with RefTeX’s mechanisms. For example, when you type C-c RET ref RET, RefTeX will supply its label selection process (see Referencing Labels).

  • RefTeX tells AUCTeX about new labels, citation and index keys
    RefTeX will add all newly created labels to AUCTeX’s completion list.


  1. RefTeX 4.0 and AUCTeX 9.10c will be needed for all of this to work. Parts of it work also with earlier versions. ↩︎

  2. fset is used to do this, which is not reversible. However, RefTeX implements the old functionality when you later decide to turn off the interface. ↩︎