Do you use Zotero to produce references in BibTeX format?
Are you fed up with continually exporting your Zotero library manually?
AutoZotBib is a Zotero plugin which will automatically keep a specified BibTeX file in sync with your Zotero library. Whenever you add, delete or modify a reference in Zotero the BibTeX file will be immediately updated, ready for you to use with your LaTeX file.
AutoZotBib works with both the Firefox and Standalone versions of Zotero. Simply load your version and follow the instructions below.
First, you need to set the file that you want to continually export BibTeX references to. To do this, click the gears icon in the Zotero interface and choose AutoZotBib Preferences. In the dialog box type the full path to the file you want to use. For example, on my Mac I chose a path of /Users/robin/Documents/ZoteroOutput.bib and on my Windows machine I chose C:\Users\Robin\ZoteroOutput.bib. Close the preferences window.
Now, whenever anything in your Zotero library changes it will update the .bib file that you specified - all automatically.
Unfortunately the BibTeX support in Zotero isn't very flexible, particularly in regard to setting the BibTeX keys for each item. The standard BibTeX export translator has very few options for setting the BibTeX keys, so I tend to use an alternative BibTeX translator created by a guy called Tan (spartanroc on GitHub) which add support for methods for generating BibTeX keys, as well as fixing a number of other issues with the BibTeX translators. His translators are available on GitHub but I have made a slightly modified version available for download on this page. This version changes only two things from Tan's original: I have added a proper GUID for the exporter, and I have set the default BibTeX key format to AuthorYear, with an alphabetical suffix in case of clashes. For example, Wilson2011, and Wilson2011a if there is a clash.
To install the new BibTeX export translator you need to copy it to the Zotero translators directory. To find this directory, open Zotero Preferences, choose the Advanced tab and click Show Data Directory. Inside this directory, open the translators directory and paste in the BibTeX_RobinTan.js file. This exporter will now be available when manually exporting from Zotero.
It is possible to set AutoZotBib to use this modified BibTeX exporter through a hidden setting. To do this, you need to open the config editor. In Firefox, go to about:config in the address bar, in standalone Zotero go to Preferences->Advanced->Open about:config. Once you're in the config editor, type autozot into the search box and double-click on the extensions.autozotbib.bibtex_translator_guid item in the list. Then simply paste in the following value DA47106C-1265-4D19-8E75-0A4CD77CD369, click OK and exit the config editor.
You should then find that your automatically-updated .bib file uses the new exporter, thus giving you my default style of cite key as well as the other improvements. If you want to change the cite key style, simply edit BibTeX_RobinTan.js file, changing the var citeKeyFormat = line using the instructions in the comments. If you want to change back to the default bibtex translator, then simply edit that configuration value again and set the value to 9cb70025-a888-4a29-a210-93ec52da40d4.
Code and Acknowledgements
The code for this extension is available at the AutoZotFile GitHub Repository.
Writing this extension was a weekend project designed to add the one feature that I really wanted in Zotero. I couldn't have done it without looking at code from the Zotero Sample Plugin and the Zot2Bib plugin.