Using Better BibTeX in Zotero to improve Citation Key management and more

Samuel Mok published on
7 min, 1348 words

This guide will help you manage your BibTeX citation keys when using Zotero and Overleaf for LaTeX writing. We'll cover installing the essential Better BibTeX extension and how to ensure your citation keys are consistent and manageable.

Managing BibTeX Citation Keys with Zotero: Better BibTeX for LaTeX Users

Why Better BibTeX?

When writing in LaTeX and managing your references with Zotero, the standard BibTeX export can sometimes be less than ideal, especially regarding citation keys. Better BibTeX (BBT) is a Zotero extension that significantly improves BibTeX export and offers much more control over your citation keys, making your LaTeX workflow smoother. If you're serious about using LaTeX, installing Better BibTeX is highly recommended!

Installation of Better BibTeX

Installing Better BibTeX is straightforward. There are two main methods: via the Zotero add-on market, or as a standalone plugin. Using the add-on market is recommended for automatic updates.

A. Via Add-on Market (Recommended)

  1. Download the Add-on Installer: Download the zotero-addons.xpi file from this link: https://github.com/syt2/zotero-addons

    • Important for Firefox users: If you are using Firefox, right-click on the link and choose "Save As...". Otherwise, Firefox might try to install it as a browser extension instead of a Zotero extension.
  2. Install the Plugin in Zotero: Go to Zotero -> Tools -> Plugins. Click on the 'settings' cogwheel icon and select "Install Plugin From File...". Locate and select the zotero-addons.xpi file you just downloaded.

    Screenshot showing Zotero menu: Tools -> Plugins, and the Plugins window with the settings cogwheel and "Install Plugin From File..." option.

  3. Install Better BibTeX from the Add-on Market: Open the Add-on Market from the main page (see screenshot below). Search for "Better BibTeX for Zotero" in the list. Click on it to select, and then click "Install" (or right-click -> Install, or double-click -> Install).

    Screenshot showing where to open the Add-on Market.

B. Standalone Installation

  1. Download Better BibTeX: Download the latest version of Better BibTeX from: https://github.com/retorquere/zotero-better-bibtex

    • Important for Firefox users: Again, if using Firefox, right-click the download link and select "Save As..." to prevent Firefox from installing it as a browser extension.
  2. Install the Plugin in Zotero: Follow the same steps as in step 2 of the "Via add-on market" method: Go to Zotero -> Tools -> Plugins, click the 'settings' cogwheel, and select "Install Plugin From File...". Select the downloaded Better BibTeX file and install it.


Handling Citation Keys: Importing and Customization

Now that you have Better BibTeX installed, let's address managing your citation keys, especially when migrating from Mendeley.

The Challenge with Mendeley and Citation Keys

Mendeley's BibTeX key generation will not align with the default Zotero settings. Better BibTeX provides solutions to standardize and control these keys.

Importing Citation Keys from a .bib file (e.g., from Overleaf/Mendeley)

A quick solution to align your citation keys is to import your existing .bib file (for example, from a LaTeX/Overleaf project or exported from Mendeley) into Zotero.

  1. Export your .bib file: Download your .bib file containing your references and Mendeley citation keys. You can typically get this from your Overleaf project or by exporting from Mendeley.

  2. Import into Zotero: In Zotero, go to File -> Import. Select your .bib file, click "Next," choose your file, and continue clicking "Next" until the import is complete.

    Zotero will import the references and, thanks to Better BibTeX, it will try to recognize existing items in your library and merge them while preserving the citation keys from the .bib file. Better BibTeX also "pins" these imported citation keys, meaning they won't be automatically changed unless you explicitly "unpin" them.

Manual Citation Key Adjustment

If importing doesn't fully resolve the issue (e.g., duplicates are not recognized, or you have other errors), you can manually adjust and pin citation keys within Zotero.

  1. Unpin the Current Citation Key: Right-click on a reference item in Zotero, go to "Better BibTeX," and select "Unpin BibTeX Key".

    Screenshot showing the context menu on a Zotero item with "Better BibTeX" and "Unpin BibTeX Key" highlighted.

  2. Paste the Desired Citation Key: In the right-hand pane of Zotero, locate the "Citation Key" field and paste your desired citation key directly into this field.

    Screenshot showing the right-hand pane of a Zotero item with the "Citation Key" field highlighted.

  3. Pin the Citation Key: After pasting the key, right-click on the item again, go to "Better BibTeX," and this time select "Pin BibTeX Key." This ensures the key remains as you set it.

Customizing Default Citation Key Generation

For a more permanent solution and to control how citation keys are generated for new items in Zotero, you can customize the citation key format in Better BibTeX settings. This is useful to ensure consistency across your library.

  1. Access Better BibTeX Settings: Go to Edit -> Preferences (or Zotero -> Settings on macOS), and select "Better BibTeX" in the left-hand sidebar.

    Screenshot showing Zotero Preferences/Settings window with "Better BibTeX" selected in the sidebar.

  2. Modify the Citation Key Formula: In the "Citation keys" tab, you'll see the "Citation key formula" field. You can change this formula to define how keys are generated.

    For example, the base formula: auth.lower + shorttitle(3,3) + year translates to: author's last name (lowercase) + first 3 words of the short title (up to 3 letters each) + year.

    You can adapt this formula to your preferred style. Here are a few more examples adhering roughly to Mendeley's standard style:

    • Example 1 (Capitalized Title Words): auth + (year? year : (origyear? origyear : date('%Y') )) + title.capitalize + Place
    • Example 2 (Title Substring - Max 30 characters): auth + (year? year: (origyear? origyear : date('%Y') )) + title.capitalize.substring(30) + Place
    • Example 3 (Title - First 4 words): auth + (year? year : (origyear? origyear : date('%Y') )) + title.capitalize.select(4) + Place

    Understanding the Formula:

    The formula uses a combination of fields and functions. Let's break down the example: auth + (year? year : (origyear? origyear : date('%Y') )) + title + Place

    • auth: Author's last name.
    • (year? year : (origyear? origyear : date('%Y') )): This is a nested conditional statement to determine the year. It checks:
      • Is there a 'year' field? If yes, use it.
      • If not, is there an 'origyear' field? If yes, use it.
      • If not, take the 'date' field and extract the year using date('%Y').
    • title: The title of the item.
    • Place: The publication place (if available).

    Important Notes about Formulas:

    • Case Sensitivity: Use .lower to force lowercase (e.g., auth.lower).
    • Functions: Better BibTeX provides various functions like shorttitle(), capitalize, substring(), select() etc. Refer to the Better BibTeX documentation for a full list.
    • Fields: You can use various Zotero fields in your formulas.
    • There are many more functions and fields. See the Better BibTeX documentation for details.
  3. Apply Changes to Existing Items (Refresh Citation Keys): After changing the formula, you can apply the new formula to existing items in your library. Select the items you want to update, right-click, go to "Better BibTeX," and choose "Refresh BibTeX key." This will regenerate the citation keys for the selected items based on your new formula.

Example BibTeX Key Generation

Let's consider an example:

Reference Details:

  • Title: Design resources in movement-based design methods: a practice-based characterization
  • Author 1: Vega-Cebrián, José Manuel
  • Date: 2023-07-10
  • Place: United States

Using the Formula: auth + (year? year : (origyear? origyear : date('%Y') )) + title + Place

Generated BibTeX Key: Vega-Cebrian2023DesignresourcesmovementbaseddesignmethodspracticebasedcharacterizationUnitedStates

Variations and Further Customization

As shown, you can customize the formula extensively to achieve various key formats. Experiment with different functions and field combinations to find a system that works best for you and your LaTeX workflow.

Conclusion

By installing and configuring Better BibTeX, you gain significant control over your BibTeX citation keys in Zotero. This guide provides you with the steps to install the extension, import existing keys, manually adjust keys, and customize the default key generation formula. This will help you ensure consistency and manageability in your LaTeX projects, especially when collaborating and migrating from other reference managers.