Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

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)))))
      (add-to-list 'reftex-ref-style-default-list "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

I don't know why you have \ref enclosed in ( ), this isn't the default behavior of RefTeX, perhaps you put a dirty hack in your init file.

share|improve this answer
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 '13 at 15:12
@dustin I updated my answer, but you didn't specify that. –  giordano Jun 15 '13 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 '13 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 '13 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 '13 at 23:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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