Org-Bibliography

Published: February 11, 2021
Edited: March 22, 2021
Categories: code

There are a few solutions for tracking bibliographies, the most prominent is Zotero but of course I’d like something to integrate into Emacs and Org mode. Luckily this problem has seen some man-hours, there is helm-bibtex and org-ref, and ebib, and pals. The former two are what I’ll use, I already use helm (half in preparation for using helm-bibtex) but I do wonder how it works all over. It’s already installed so let’s see how it works through ox-hugo: turing50:comput.

Not too bad, though there are a few things here coupled, more than I’d like but hey. The literal text is the name of the PDF in my library folder, which was governed by the biblio-lookup. There’s a better discipline for naming these things isn’t there…

The setup is simple, just a couple of packages and a few variables. Mostly for demonstration I’ll have proper DRY discipline:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
(defvar bibliography-file "~/org/tex/refs.bib")
(defvar library-directory "~/org/lib/")
(defvar research-notes-file "~/org/tex/notes.org")

(use-package helm-bibtex
  :straight t
  :bind (("C-c m b" . 'helm-bibtex))
  :config
  (setq bibtex-dialect 'biblatex
        bibtex-completion-bibliography (list bibliography-file)
        bibtex-completion-notes-path research-notes-file
        bibtex-completion-library-path (list library-directory)))
(use-package org-ref
  :straight t
  :config
  (setq reftex-default-bibliography (list bibliography-file)
        org-ref-default-bibliography (list bibliography-file)
        org-ref-bibliography-notes research-notes-file
        org-ref-pdf-directory library-directory
        org-latex-pdf-process
        '("latexmk -shell-escape -bibtex -f -pdf %f")))

The only necessary point of entry for everything is C-c m b from which the helm interface gives access to any useful bibliography functions.1 For example, here in the org-mode file I use to manage this site, I press C-c m b, type “Turing” and press enter the result is the string cite:turing50:comput gets inserted and later interpreted into: turing50:comput. Or instead of pressing enter I can choose one of the eleven other actions which include browsing the DOI, opening the PDF, attaching notes, or attaching the PDF to an email.

I’m aware of org-roam-bibtex too, maybe I should check it out because I do like the quick note taking of org-roam… interesting but I may yet prefer to use the notes function under helm-bibtex, I’ll try that first. The important thing is now I’ve got it working through ox-pdf! yay.

For that there are just a couple of lines to include to place and populate the bibliography:

1
2
bibliography:tex/refs.bib
bibliographystyle:plain

I think I’ll refactor my PDF names now.2

Bibliography

[turing50:comput] Turing, Computing machinery and intelligence, Mind, LIX(236), 433-460 (1950). link. doi.


  1. I started using C-c m as a prefix for “media”. Originally it was prefixed notmuch and helm-notmuch, and before that mu4e but mnemonically “mail”. “Media” now because it prefixes emms as well. ↩︎

  2. Note the use of the relative path name. Proper discipline would probably be to make a snippet to output those two lines with an absolute path. ↩︎