Org Roam Bibtex

Table of Contents

  1. Introduction
  2. Zotero for Bibliography management
  3. Set up Org Noter
  4. Set up Helm Bibtex
  5. Set up Org Ref
  6. Org Roam Bibtex (ORB)
  7. Workflow

I used heavily when setting this up.


Warning: There is a lot going on with this configuration. This assumes that you have org-roam set up. We will use:

  • org-ref to manage citation links
  • helm-bibtex to manage notes/pdfs
  • org-noter to take notes on a pdf
  • org-noter-pdf-tools to help with rendering the pdf and some integration.
  • org-roam-bibtex to stich all of these things together and generate templates for us.
  • Zotero an application to manage your external bibliography

Zotero for Bibliography management

Zotero is an application that has a lot of tools built in for managing bibliographies. I like it because it will fetch meta data from pdfs you link it automatically (if its available).

I havent had the time to explore its capabilities so I use it to generate a .bib file for org-roam-bibtex to use.

I use brew to manage as much as I on macos so thats how I installed Zotero:

brew cask install zotero

Side note: brew cask install is for any application that you need to drag into the application folder.

Everyone reccommends the better bibtex extention. From, heres how you install the extension:

  1. In the main menu go to Tools > Add-ons
  2. Select ‘Extensions’
  3. Click on the gear in the top-right corner and choose ‘Install Add-on From File…’
  4. Choose .xpi that you’ve just downloaded, click ‘Install’
  5. Restart Zotero

Now we want to set up a .bib file that will sync automatically when you capture a bibliography in Zotero.

Heres how:

  1. Right click My Library
  2. Click Export Library
  3. Select the correct options and press OK
    • Format: Better BibLateX
    • Check Export Notes
    • Check Keep Updated
  4. Name it masterLib.bib (or whatever you want)
  5. Select the export location, we will need the path to it later

Set up Org Noter

Heres the config for org noter you need inside of your config.el:

(use-package! org-noter
:after (:any org pdf-view)
;; The WM can handle splits
org-noter-notes-window-location 'other-frame
;; Please stop opening frames
org-noter-always-create-frame nil
;; I want to see the whole file
org-noter-hide-other nil
;; Everything is relative to the main notes file
org-noter-notes-search-path (list org_notes)

I had to install org-pdftools and org-noter-pdftools to actually view pdfs in emacs. I believe I ran M-x pdf-tools-install and added this to config.el:

(use-package org-pdftools
:hook (org-load . org-pdftools-setup-link))
(use-package org-noter-pdftools
:after org-noter
(with-eval-after-load 'pdf-annot
(add-hook 'pdf-annot-activate-handler-functions#'org-noter-pdftools-jump-to-note)))

Set up Helm Bibtex

At the top of my config.el I have some variables set:

org_notes "~/Desktop/03-resources/org-roam"
zot_bib "~/Desktop/03-resources/masterLib.bib"
org-directory org_notes
deft-directory org_notes
org-roam-directory org_notes
org-default-notes-file (concat org_notes "/")

This makes org_notes and zot_bib available in the file. Replace those paths with wherever your org-roam is set up as well as where you exported your masterLib.bib.

Heres my config for Helm Bibtex:

bibtex-completion-notes-path org_notes
bibtex-completion-bibliography zot_bib
bibtex-completion-pdf-field "file"
"#+TITLE: ${title}\n"
"#+ROAM_KEY: cite:${=key=}\n"
"* TODO Notes\n"
":Custom_ID: ${=key=}\n"
":NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n"
":AUTHOR: ${author-abbrev}\n"
":JOURNAL: ${journaltitle}\n"
":DATE: ${date}\n"
":YEAR: ${year}\n"
":DOI: ${doi}\n"
":URL: ${url}\n"

This sets where helm will look for bibliography entries (although, im not sure if Org Roam Bibtex overrides this template, is this really needed?). This is the template we will use when creating notes based off of a bibliography.

Set up Org Ref

Org ref lets you manage your cite: links. We use our zot_bib and org_notes variables we set earlier.

(use-package! org-ref
org-ref-completion-library 'org-ref-ivy-cite
org-ref-get-pdf-filename-function 'org-ref-get-pdf-filename-helm-bibtex
org-ref-default-bibliography (list zot_bib)
org-ref-bibliography-notes (concat org_notes "/")
org-ref-note-title-format "* TODO %y - %t\n :PROPERTIES:\n :Custom_ID: %k\n :NOTER_DOCUMENT: %F\n :ROAM_KEY: cite:%k\n :AUTHOR: %9a\n :JOURNAL: %j\n :YEAR: %y\n :VOLUME: %v\n :PAGES: %p\n :DOI: %D\n :URL: %U\n :END:\n\n"
org-ref-notes-directory org_notes
org-ref-notes-function 'orb-edit-notes

Its important to note (as does) that org-refs template options are not the same (note that I didnt write this template and just copy pastad). Heres a cheatsheet:

In the format, the following percent escapes will be expanded.
%l The BibTeX label of the citation.
%a List of author names, see also \`reftex-cite-punctuation’.
%2a Like %a, but abbreviate more than 2 authors like Jones et al.
%A First author name only.
%e Works like %a, but on list of editor names. (%2e and %E work as well)
It is also possible to access all other BibTeX database fields:
%b booktitle %c chapter %d edition %h howpublished
%i institution %j journal %k key %m month
%n number %o organization %p pages %P first page
%r address %s school %u publisher %t title
%v volume %y year
%B booktitle, abbreviated %T title, abbreviated
%U url
%D doi
%S series %N note
%f pdf filename
%F absolute pdf filename
Usually, only %l is needed. The other stuff is mainly for the echo area
display, and for (setq reftex-comment-citations t).
%< as a special operator kills punctuation and space around it after the
string has been formatted.
A pair of square brackets indicates an optional argument, and RefTeX
will prompt for the values of these arguments.

Org Roam Bibtex (ORB)

ORB stitches everything together, Heres my config:

(use-package org-roam-bibtex
:after (org-roam)
:hook (org-roam-mode . org-roam-bibtex-mode)
(setq orb-preformat-keywords
'("=key=" "title" "url" "file" "author-or-editor" "keywords"))
(setq orb-templates
'(("r" "ref" plain (function org-roam-capture--get-point)
:file-name "${slug}"
:head "#+TITLE: ${=key=}: ${title}\n#+ROAM_KEY: ${ref}
- tags ::
- keywords :: ${keywords}
\n* ${title}\n :PROPERTIES:\n :Custom_ID: ${=key=}\n :URL: ${url}\n :AUTHOR: ${author-or-editor}\n :NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n :NOTER_PAGE: \n :END:\n\n"
:unnarrowed t))))


First you need to add a PDF to Zotero. Ill use this pdf as an example. Store it in some place. Then head over to Zotero to add it to your bibliography.

Press the plus button and then Link to File. You should see Zotero auto fill a bunch of info.

Now you can add a citation in your notes with M-x helm-bibtex generates a cite link. cite:oneillColLaboratoryNotebook Press enter on the link, and select the Add Note option.

The note should be populated with properties and a ROAMKEY. Now its time to open the pdf. M-x org-noter. The pdf should show up in a new frame as well as the notes in an other. I want them to show up in the same frame but havent figured that out yet.

Now you can highlight a line in the pdf and type M-x org-noter-insert-note and type your note and press enter. Your note will be added to the page with properties to actually navigate to the highlight when you come back to your not later.

Its amazing.

Referred in