By default reftex-mode recognizes LaTeX-like citations, which have a format like \cite{Smith15}. (Locating the cursor above a reference shows a description of it in the mini-buffer and pressing C-& opens the bibliography file in the right spot).

I would like reftex-mode to also recognize my Pandoc-like citations, which have a format like @Smith15 (regexp:"@[A-Z][A-Za-z0-9]+").

Reftex-mode has some functions that allow extending it (e.g., reftex-cite-format, reftex-view-crossref-extra), but it is not clear how to use them to detect this type of citation.

Any ideas?

  • 1
    This post is related: it discusses how to use RefTeX to insert Pandoc citations, but not how to make it recognize Pandoc citations. – scaramouche Feb 24 '15 at 14:53

Unfortunately, the format of citations is hard-coded as the latex one in reftex source code (see function reftex-view-crossref in file reftex-dcr.el), so there's no easy way to change it. However, if what you need is just to be able to look up the citation at point, the following does it:

(require 'reftex-dcr)
(defun my-reftex-view-pandoc-cite ()
   "View pandoc citation"
   (interactive)
   (let ((w (word-at-point)))
    (if (eq ?@ (elt w 0))
    (setq dw (reftex-view-cr-cite "" (substring w 1) 'tmp-window))
      (if (and (eq arg 2) (windowp dw)) (select-window dw))
      (error "Not on a citation")
      )))

You don't need to enable reftex-mode but you have to tell RefTex about your bibliography file:

(setq reftex-default-bibliography '("biblio"))

Something similar could be done for the 'idle display' feature, but it may be more complex.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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