Werden wir Helden für einen Tag

Home | About | Archive

Advent of emacs #13: How I do bibliography management in emacs

Posted on Dec 13, 2022 by Chung-hong Chan

I wrote about bibliography management in the past. I will keep this post simple.

I maintain my library in one single plain text \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) file here. It basically made me an oddman in my peers because they usually use EndNote or Zotero. But I don’t care, I am not a good collaborator anyway. Don’t write papers with me, I have enough collaborators (joke).

I have around 400 and counting entries in my library and managing them in plain text is still fast. I don’t hoard PDF files. Also, I thought I want to write notes. But I actually don’t. (I will write about the note-taking culture later) So, my \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) file is purely for one purpose: writing papers. It’s not a memory device. My Brain and of course the internet are better for that.

As it is for writing papers, there is a specific requirement: each entry must have its DOI, if it is available. Why? Because the journals of my field require DOIs. If one obtains \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) from Google Scholar, it has no DOI.

Adding entries

Suppose I have my \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) file in “~/dev/dotfiles/bib.bib”. And as I said, I just use my \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) file for writing papers. Suppose I’ve found a paper I wanna cite, this is my workflow:

  1. Copy the DOI from Firefox (or any source)
  2. Go back to emacs (By C . e)
  3. Run the custom command: M-x add-doi and paste yank the DOI (C-y)
  4. Auto: Fetch the \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) from Crossref
  5. Auto: Add it into “~/dev/dotfiles/bib.bib”
  6. Save it

My custom command add-doi is based on biblio by Clément Pit-Claudel et al.

(defun add-doi ()
  (interactive)
  (progn
    (setq doi-to-query (read-string "DOI "))
    (find-file "~/dev/dotfiles/bib.bib")
    (end-of-buffer)
    (doi-insert-bibtex doi-to-query)
    )
  )

My approach is quite primitive. But I guess it’s primitively good.

Customizing cite key

It is also important to turn on automatic cite key generation (biblio-bibtex-use-autokey). So that I don’t need to enter a cite key myself. I am really bad at naming things.

(use-package biblio
  :config
  (setq-default
   biblio-bibtex-use-autokey t
   bibtex-autokey-name-year-separator ":"
   bibtex-autokey-year-title-separator ":"
   bibtex-autokey-year-length 4
   bibtex-autokey-titlewords 3
   bibtex-autokey-titleword-length -1 ;; -1 means exactly one
   bibtex-autokey-titlewords-stretch 0
   bibtex-autokey-titleword-separator ""
   bibtex-autokey-titleword-case-convert 'upcase)
  )

In the end, the whole procedure looks like this. I can add an entry to my library under 10s.

But then how am I going to use my \(\mathrm{B{\scriptstyle{IB}} \! T\!_{\displaystyle E} \! X}\) file? Well, I am going to talk about how I write papers first. Stay tuned for tomorrow.


Powered by Jekyll and profdr theme