I am having an issue with a YASnippet for inserting a RefTeX citation. As many others have, I'm trying to use this snippet from GitHub with the following syntax

\cite{${1:label$(unless yas/modified-p (reftex-citation nil 'dont-insert))}}$0

however, the snippet will complete and include a citation, but I am getting extra characters around the citation label, so the citation ends up looking like


instead of like


and the file will not compile successfully because there are no parentheses around the entry titles in the .bib file.

Also, if I try to include multiple entries into one citation the result looks like

\cite{(pauling1936 giauque1933)}

instead of

\cite{pauling1936, giauque1933}

If I just use the RefTeX shortcut, C-c [ instead of attempting to use the YASnippet, the citation is formatted correctly for both single and multiple entries. Also, essentially the same code from GitHub will work perfectly for a reftex-reference call instead of a citation.

Perhaps I should mention that I am using Windows 8, Emacs 24.3.1, YASnippets 0.8, and AUCTeX 11.87.1, and my preamble doesn't have any \usepackage{} calls relating to bibtex.

  • 2
    I'm curious, why should one use this YASnippet to insert citations instead of RefTeX's C-C [ ? According to your question, the latter works as intended. Oct 8, 2013 at 12:03
  • I am using the default C-c [ command to insert citations at the moment while I write my paper, however, I would prefer to use the snippet because it's easier to just type "cite" and then hit TAB. I'm just confused about why the YASnippet isn't working. Oct 8, 2013 at 15:42
  • 1
    I agree with @YuppieNetworking. It sounds like the real problem is that C-c [ is an awkward combination for you. It would be much easier to bind reftex-citation to a more convenient key that to recreate an existing function in yas/snippet.
    – Tyler
    Oct 21, 2013 at 15:34

2 Answers 2


Yasnippet can get slightly buggy when you start embedding lisp code. I suggest you report this bug.

Meanwhile, here's how you can try to fix it.

\cite{${1:label`(unless yas/modified-p (reftex-citation nil 'dont-insert))`}}$0

Backticks are an alternative way to embed lisp in yasnippet, and they can work better (if the code you're embedding doesn't use backticks, if course). Let me know if it works.


The issue is that reftex-do-citation, which is the function that does the main work of reftex-citation used to return items from a list (i.e., (car (car selected-entries))).

Now it returns a list (i.e., (mapcar 'car selected-entries)).

The desired output (for both a single entry and multiple entries) can be obtained by modifying the code in the snippet:

\cite{${1:label$(unless yas/modified-p (mapconcat 'identity (reftex-citation 'dont-insert) ","))}}$0

You must log in to answer this question.

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