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
    Jun 15, 2013 at 15:12
  • @dustin I updated my answer, but you didn't specify that.
    – giordano
    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
    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
    Jun 19, 2013 at 23:41
  • If TeX-parse-self and TeX-auto-save are non nil, it must work. When you have a \usepackage{cleveref} in your document cleveref appears in TeX-style-list variable (check its value in your buffer) and the hook associated to cleveref is run, that is the hook I wrote in the answer.
    – giordano
    Jun 19, 2013 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.