BibTeX Citation Tips

Date: 2022-04-27

Table of Contents

1 Introduction

This post contains miscellaneous tips for handling citations with BibTeX.

2 My procedure

While Google Scholar does offer BibTeX entries for anything you can find on it, they tend to be uneven (and often inferior) in quality to the ones you can find in more official databases. Here is my own personal procedure for finding BibTeX citations. The method varies by the field the paper is in:

For all other papers, I do the following1: I go to library.arizona.edu, search for the paper, then click ‘Export RIS’ and select ‘UTF-8’, then click ‘Download’. I then run the following command in my terminal: latest_citation_to_bibtex, which converts the .ris file to BibTeX and copies it to my clipboard. Then I can simply paste (Cmd-v) the BibTeX entry into my .bib file that I am using for the document I am currently working on.

This assumes that you have my latest_citation_to_bibtex script below with permissions that allow it to function as an executable and somewhere in your PATH:

#!/usr/bin/env bash

set -euo pipefail

# Get the latest file from the ~/Downloads directory, and if it is a .ris file,
# convert it to BibTeX format, normalize it with bibtool, copy it to the
# clipboard, and delete the original file. This is useful for when websites
# don't have BibTeX exports.
latest_citation_to_bibtex() {
    local file=$(ls -td ~/Downloads/* | head -n1)
    if [[ $file = *.ris ]]; then
        ris2xml $file | xml2bib | bibtool -f "%1p(author):%4d(year)" | pbcopy
        rm $file
    elif [[ $file = *.bib ]]; then
        cat $file | bibtool -f "%1p(author):%4d(year)" | pbcopy
        rm $file
    fi
}

latest_citation_to_bibtex

The latest_citation_to_bibtex script assumes the availability of the following tools on your computer: ris2xml, xml2bib, bibtool. You can install ris2xml and xml2bib by running

sudo port install bibutils

You can install bibtool by running

sudo port install BibTool

  1. Caveat: This procedure assumes that you have a macOS computer - pbcopy is used to copy things to the macOS clipboard, and the port command is used to manage packages using MacPorts.↩︎