Whenever I insert a reference to a label starting with eq: RefTeX seems to decide to surround it with (), e.g. it will insert (\ref{eq:1)) into the buffer. This is particularly annoying if I am using cleveref, because (\cref{eq:1}) is not at all right.

It is implied in one other place (the only place I've seen it mentioned) that this surprising/unexpected behaviour and may be due to my own customisations (of which there aren't many at all)... but if I start emacs with emacs -Q to disable all of them, it still occurs for both of the built-in reference formats (\ref and \pageref).

I'm using Emacs 24.5 with RefTex 24.4 on Ubuntu.

It would be very nice to stop/control this behaviour.

1 Answer 1


After a bit of testing, I stand corrected (with respect what I said in the answer you mentioned): what you describe is indeed the default behavior, but of course can be changed. If you want to use amsmath style of referecen, add the following code to your init file:

(setq reftex-label-alist '(AMSTeX))

as also suggested in the RefTeX manual.

If in particular you want to use \eqref{} when cleveref is not loaded, and not to have anyway the parentheses around \ref{} in documents loading cleveref package add the following code to your init file (it's based on this answer, already mentioned in the question)

(setq reftex-label-alist '(AMSTeX)) ;; as before, but will be changed in cleveref document, see below

    (lambda ()
      (if (boundp 'reftex-ref-style-alist)
           '("Cleveref" "cleveref"
             (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
      (reftex-ref-style-activate "Cleveref")
      (set (make-variable-buffer-local 'reftex-label-alist)
       '(("equation"  ?e "eq:" "~\\ref{%s}" t
          (regexp "equations?" "eqs?\\." "eqn\\." "Gleichung\\(en\\)?"  "Gl\\."))))
       '("cref" TeX-arg-ref)
       '("Cref" TeX-arg-ref)
       '("cpageref" TeX-arg-ref)
       '("Cpageref" TeX-arg-ref)))))
  • Hm, so this improves/changes things somewhat: instead of (...), it uses eqref for eq:... labels (even if I try to use non-ref reference formats like pageref or the cref one I've defined).
    – huon
    Nov 13, 2015 at 11:03
  • @huon See the updated answer.
    – giordano
    Nov 13, 2015 at 11:28
  • Thanks! However, I'm still not sure that's really the right thing. I want RefTeX to understand that when I explicitly request the \cref format (added as you suggest in the answer that I linked in my question), it should just insert \cref instead of trying to guess what I mean with the heuristics that don't apply to the more intelligent referencing packages. I also don't really want to force the \cref format (not all the documents I work on use it).
    – huon
    Nov 13, 2015 at 11:46
  • (Lastly, it's not just the e key: this seems to be driven by the eq: prefix, for instance, if I use space to see all the labels in my file, RefTeX still inserts parens/eqref if I choose an eq:... label.)
    – huon
    Nov 13, 2015 at 11:48
  • Indeed reftex-typekey-to-format-alist is relevant not only when the e type of labels is selected, but every time a label with eq: prefix is chosen. If in a document with cleveref you always want to you only \cref you only need to set reftex-label-alist to nil there (add (set (make-variable-buffer-local 'reftex-label-alist) nil) in the hook of the other question, after reftex-ref-style-activate)
    – giordano
    Nov 13, 2015 at 12:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .