How can I set up cleveref to work with AUCTeX and RefTeX? I have tried the advice on Emacs, RefTeX and Cleveref – can they work together? but it didn't work.

Additionally, when I hit enter, \ref{} portion is always enclosed in ( ). How can I get rid of ( ) enclosing the ref{}?

I also checked out:

AUCTeX – new commands recognized as such

this post but all the information is relatively old so maybe there is a newer answer?

1 Answer 1


Add the following code to your init file

    (lambda ()
      (if (boundp 'reftex-ref-style-alist)
       '("Cleveref" "cleveref"
         (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
      (reftex-ref-style-activate "Cleveref")
       '("cref" TeX-arg-ref)
       '("Cref" TeX-arg-ref)
       '("cpageref" TeX-arg-ref)
       '("Cpageref" TeX-arg-ref)))))

I've taken the value for reftex-ref-style-alist from this revision: http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/112689

For the \ref enclosed in ( ), add the following code to your init file:

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

as also suggested in the RefTeX manual (see also Emacs' RefTeX reftex-reference unconditionally surrounding `eq:...` reference with parens)

  • The code I posted works for me: if I press C-c C-m cref RET, I get \cref, not \ref, it's impossible you get a \ref. Please explain better what's your problem and, if you can, post all AUCTeX/RefTeX related customizations in your .emacs.
    – giordano
    Commented Jun 15, 2013 at 15:12
  • @dustin I updated my answer, but you didn't specify that.
    – giordano
    Commented Jun 15, 2013 at 15:38
  • @dustin which version of AUCTeX and RefTeX are you using? Here: AUCTeX 11.87 and RefTeX shipped with Emacs 24.3. Do you set AUCTeX TeX-parse-self and TeX-auto-save variables to t?
    – giordano
    Commented Jun 19, 2013 at 23:38
  • See the first lines of AUCTeX manual: gnu.org/software/auctex/manual/auctex.html If you want to exploit all AUCTeX features (in particular its ability to parse TeX documents) you have to set those variables to non-nil. My code works in that case, that's the most common case among AUCTeX users.
    – giordano
    Commented Jun 19, 2013 at 23:41
  • 1
    This doesn't seem to be working for me because the "cleveref" style isn't being set (it isn't in TeX-active-styles. I include the package with \usepackage[capitalise,noabbrev]{cleveref} in my master document, but reftex-ref-style-alist is never updated. How should the "cleveref" style become active?
    – robin
    Commented Mar 19, 2014 at 22:58

You must log in to answer this question.

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