Last active
March 15, 2022 09:19
-
-
Save kleinschmidt/5ab0d3c423a7ee013a2c01b3919b009a to your computer and use it in GitHub Desktop.
Insert markdown (pandoc-citeproc) formatted citations using RefTeX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; reftex in markdown mode | |
;; if this isn't already set in your .emacs | |
(setq reftex-default-bibliography '("/path/to/library.bib")) | |
;; define markdown citation formats | |
(defvar markdown-cite-format) | |
(setq markdown-cite-format | |
'( | |
(?\C-m . "[@%l]") | |
(?p . "[@%l]") | |
(?t . "@%l") | |
) | |
) | |
;; wrap reftex-citation with local variables for markdown format | |
(defun markdown-reftex-citation () | |
(interactive) | |
(let ((reftex-cite-format markdown-cite-format) | |
(reftex-cite-key-separator "; @")) | |
(reftex-citation))) | |
;; bind modified reftex-citation to C-c[, without enabling reftex-mode | |
;; https://www.gnu.org/software/auctex/manual/reftex/Citations-Outside-LaTeX.html#SEC31 | |
(add-hook | |
'markdown-mode-hook | |
(lambda () | |
(define-key markdown-mode-map "\C-c[" 'markdown-reftex-citation))) |
Thanks for sharing. Would this solution be able to allow to insert several citations in one shot? I see the code referring to key-separator, but I am not being able to make it work. I am very new to Emacs, so it will probably be my fault, but I wanted to make sure nonetheless.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this! This provided a much easier integration with Emacs & Zotero than
zotxt-emacs
.