Background

Our group writes its papers and grants in LaTeX. We edit LateX documents collaboratively using either (1) Overleaf or (2) by pushing and pulling from a private git repository shared via Dropbox (described here). For fast real-time editing of projects like grants, the group likes Overleaf because of its commenting, track changes, and chat features. It also has git support, so you can work offline if you don’t want to edit in public or if the project requires major surgery. For collaborative editing we tried Authorea, but found it inadequate (discussed here).

We use BibTeX or Biber to create bibliographies. References have so far been handled by each coauthor individually, with each coauthor contributing a .bib file to the project directory. Most of us have been reading and editing our .bib files using the free, open-source JabRef application. For sharing references, we have begun using Zotero. It is likewise open-source but allows you to share references. It has quite good BibTeX support.

The purpose of this memo is to summarize how to install and configure Zotero to create high-quality .bib files for use with LaTeX.

The Zotero application

Zotero is both a desktop application and a web application. As explained here, you do not need to register for a free web-application account to use Zotero. However,

If you choose to create an account and sync your data, you’ll also have access to your web library on zotero.org. However, while the web library allows you to view and edit your data and access synced files, for full functionality you’ll want to install Zotero on each synced computer.

I decide to register for a free account here for my research group. This allows me to synchronize the local copy of my references with a copy on the web and, more importantly, allows me to share a library with my students and collaborators.

Now download the Zotero application from here and install it. It asks for an admin password (in macOS at least). I am now running the “Zotero 5.0 for Mac” desktop application.

The Connector plug-in

Zotero’s killer feature is its ability to create a reference from a journal web page. To access this feature, you need to install an add-on for your web browser. My default web browser is Safari. After reading here, I think it best to use Zotero with the Firefox or Chrome browser instead.

Boot the Google Chrome browser, go to the Zotero downloads web page, and click on [Install Chrome Connector] on the right-hand side of the page.

Now configure the extension to sync with the web account and check that the extension is running. In Google Chrome,

Chrome > Preferences > Extensions (lower left)

then

Zotero Connector > [Details] > Extension options > Save to Zotero.org

and enter my Zotero user email and password. In Extension options, under Zotero Status, it says “Zotero is currently available”. The Zotero application has to be running or else this message says “Zotero is currently unavailable.”

The Better BibTeX extension

As installed so far, Zotero will save your references to a .bib file. However, the entries in the .bib file will have strange citation keys, will contain fields which you don’t need and which will confuse BibTeX, and special characters will not have been converted to LaTeX. The Better BibTeX extension fixes all these problems.

Follow the Better BibTeX extension intallation instructions here. Reboot Zotero.

Choose “Use the BBT default citekey format”, continue; click “Enable drag-and-drop citations”, continue; unclick “Unabbreviate journal names on import, click “Expand @string journal names on import, continue; note that I want to select “Better BibTeX” and not “BibTex” as the export format in Zotero, continue. New translators are automatically installed. Reboot Zotero.

Now tweak the Better BibTeX preferences. Go to

Zotero > Preferences > Better BibteX

and adjust the following settings from their default values.

Citation keys:

  • Citation key format: [Auth][year][month]
  • [x] Force citation to be plain text
  • Keep keys unique: within each library
  • On conflict with a pinned key, non-pinned keys will be: postfixed (causes key changes)

Export:

  • Add URLs to BibTeX export: in the ‘url’ field

Fields:

  • When a reference has both a DOI and a URL, export: both
  • Fields to omit from export (comma separated): issn, abstract, urldate, note, publisher, groups, timestamp, copyright, chapter, pmid, file, shorttitle, language, keywords
  • Include JabRef-specified metadata: no

Miscellaneous:

  • [x] Automatically abbreviate journal title if none is set explicitly
  • [x] Include comments about potential problems with the references
  • [x] Include automatic tags in export

Advanced. Export:

  • [x] Apply title-casing to titles
  • [ ] Apply case-protection to capitalized words by enclosing them in braces

Now when you export a library in “Better BibTeX” format, the resulting .bib file should be well behaved.

Playing nice with LaTeX

Some references still to be touched up. Here is an example: DOI:10.1002/adfm.202005662. In this example, we need “2D” and “Ruddelson-Popper” to be properly capitalized in the title, and probably we want the first dash in the title to be replaced by a long dash.

There are two way to achieve these modifications:

  1. In the .bib file, we really want the title to read “{2D}” and “{R}uddelson-{P}opper”. As explained here, any text between “<script>” and “</script>” is treated as literal LaTeX text upon export and is left alone. So in the title, replace “2D” with “<script>{</script>2D<script>}</script>”. Use this same trick to achieve “{R}” and “{P}” and to replace the dash by “—-“. This kludge works, but the article title is now essentially unreadable in Zotero. There is an easier way.
  2. Any entry tagged with #LaTeX (case-sensitive!) will have all fields exported as if they are wrapped in “<script>…</script>”, so you can include LaTeX markup in your references directly (see here). This is the easier solution. In the above example, add the #LaTeX tag to the reference and edit the title to be what we would want in LaTeX, “Light-dependent impedance spectra and transient photoconductivity in a {R}uddlesden—-{P}opper {2D} Lead–Halide perovskite revealed by electrical scanned probe microscopy and accompanying theory”. The title will again export properly but is now readable in Zotero.

Using these tricks I can touch up the article title in Zotero before export and not have to mess with the .bib file after export.

Share on: EmailLinkedInTwitterFacebook


Published

Last Updated

Category

research

Tags

Stay in Touch