# Setting up RefTeX with biblatex citation commands

How do I setup RefTeX with biblatex's citation commands? In Workflow for managing references? Seamus describes a workflow with RefTeX and mentions that

it wouldn't be too tricky to add \autocite and friends to aucTeX's cite insertion mechanism.

The biblatex citation commands I'd like to use with RefTeX is \autocite, \smartcite and \textcite. Also, I'd like RefTeX to work with csquotes' \blockcquote.

Note that I am not asking for anything that has to do with compilation (like Customising emacs to use biblatex-biber instead of bibtex).

The variable you need to hook into is reftex-cite-format. Somewhere in my Emacs init file, I have this code:

(eval-after-load 'reftex-vars
'(progn
;; (also some other reftex-related customizations)
(setq reftex-cite-format
'((?\C-m . "\\cite[]{%l}")
(?f . "\\footcite[][]{%l}")
(?t . "\\textcite[]{%l}")
(?p . "\\parencite[]{%l}")
(?o . "\\citepr[]{%l}")
(?n . "\\nocite{%l}")))))


You should to add your desired commands to this list. The first element in each pair is the letter you want to press after C-c [ to select the given citation format. The empty square brackets denote optional arguments; RefTeX has variables to control whether it prompts your for those. And %l is where the cite key goes.

(You could also set this variable via M-x customize-variable, but I loathe that particular feature of Emacs.)

I'm not sure what the syntax of \blockcquote is...if it has more non-optional arguments than just a cite key, RefTeX might not be able to fully support it (i.e., it inserts the command but you then have to move backwards to fill out other arguments).

• What's the line ;; ... for? – N.N. Oct 19 '11 at 6:29
• @N.N., just to indicate that other reftex-related customizations go there. I've edited to clarify. – Aaron Oct 29 '11 at 2:41
• Why is eval-after-load used here? gnu.org/software/emacs/manual/html_node/elisp/… says "Normally, well-designed Lisp programs should not use eval-after-load." – N.N. Jan 16 '12 at 11:23
• @N.N., your link also says "But it is OK to use eval-after-load in your personal customizations if you don't feel that they must meet the design standards [...] for wider use." Since this code is run at emacs startup, I use eval-after-load to defer loading the reftex-vars library (until the first TeX file is opened), which cuts down on startup time – drastically, if you use eval-after-load consistently. It's a fairly common .emacs idiom AFAIK. It's also possible to use the M-x customize interface for deferred variable setting, but I dislike it (and it can't really be copy/pasted). – Aaron Jan 17 '12 at 0:51
• It was quite easy to use the loathed customize-variable also. M-x customize-set-value, enter customize-set-value, enter reftex-cite-format, enter format string, enter \autocite[]{%l}. (Should I add this as another answer?) – trmdttr Jun 2 '16 at 16:59

Another way to integrate biblatex and csquotes with RefTeX is via YASnippet.

You make a snippet for every citation macro you want to use and have the snippets call reftex-citation.

I use a setup where I type "ct" and press Tab and then I get to choose between the two following snippets.

For \auctocite:

# -*- mode: snippet -*-
# name: autocite \autocite
# key: ct
# --
\autocite[$3]{${2:label$(unless yas/modified-p (reftex-citation 'dont-insert))}}$0


For \textcite:

# -*- mode: snippet -*-
# name: textcite \textcite
# key: ct
# --
\textcite[$3]{${2:label$(unless yas/modified-p (reftex-citation 'dont-insert))}}$0


I also use the following for \blockcquote:

# -*- mode: snippet -*-
# name: Formal blockquote \blockcquote
# key: fbq
# expand-env: ((yas/indent-line 'fixed))
# --
\blockcquote[$2]{${1:label$(unless yas/modified-p (reftex-citation 'dont-insert))}}{%$0%
}


For a collection of snippets for citing with biblatex see https://github.com/Sleft/yasnippet-latex-mode/tree/master/cite.

To get RefTeX to work with csquotes package I use this in my .emacs:

(eval-after-load "tex"
(lambda ()

This way when you run C-c C-m blockcquote it will prompt you for the correct arguments and you will get the RefTeX-dialog for choosing a citation label.
I have taken this from somewhere but don't remember where. The important part if you need to edit it is invoking TeX-arg-cite for the correct argument (citation label) of the macros.
• I tried this but it says C-c m is undefined. – N.N. Sep 18 '12 at 18:47