4

I'm using RefTex and cleveref. When I want to add a cross-reference I need to enter C-c ) C <SPC> to select the uppercase (\Cref) reference format and show all label types. I use this method to search 99% of the time, so I would like to bind it to a key sequence or just set it as the default.

EDIT

In the end I bound it to a fresh key, and do not override the standard behaviour. Instead I use a let of reftex-refstyle.

(eval-after-load "reftex"
  '(progn
     (define-key reftex-mode-map (kbd "C-c c")
       (lambda ()
     (interactive)
     (let ((reftex-refstyle "\\Cref"))
       (reftex-reference " "))))))
5

Looking to the reftex-ref.el source code I found the following (undocumented) solution: add to your .emacs the line

(setq reftex-refstyle "\\Cref")

Please note that this will make \Cref the default reference command even when the cleveref isn't actually loaded.

If you want to skip the selection of the label type as well, you have to pass the argument " " to the reftex-reference function. You can achieve that by binding C-c ) to (reftex-reference " "). To do this, add also the following code to you .emacs

(eval-after-load "reftex"
  '(progn
     (define-key reftex-mode-map (kbd "C-c )")
       (lambda ()
     (interactive)
     (reftex-reference " ")))))
  • Thanks, this works, as long as I set the variable before opening my tex file. However, I still have to select the label type and I would be happy for it to just show all labels. Is this also possible? – robin May 9 '14 at 11:09
  • @robin See the updated answer :-) – giordano May 9 '14 at 22:23
  • Thanks this is great, I will give it a go on Monday. So if I wanted to bind this to a key without affecting the standard behaviour of reftex-reference would it be possible to wrap (reftex-reference " ") in a let of reftex-refstyle? I'm guessing this might not work as I seemed to have to set the variable before opening the tex file. I'll try it in any case! – robin May 10 '14 at 23:10

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.