Monday, November 5, 2012

Using Zotero with BibTeX

In the past few weeks I've been writing a paper, which means lots of formatting of images and references and things. But I've finally found an amazingly good solution to my reference management. Zotero is free software built to manage research references similar to the way iTunes manages music tracks. And it's wonderful.

I've been familiar with using BibTeX with my LaTeX papers for a while. It's pretty simple to go download the BibTeX citation from the hosting website, copy it into my .bib file, give it a meaningful key, and cite it in LaTeX. But Zotero can simplify this process even more. Zotero comes in two forms: the broswer version for Firefox, and the standalone version, extended with browser plug-ins. Since I use Chrome as my main browser, I chose the standalone version and installed the Zotero connector for Chrome.

Once that's all installed, the easy part comes (the research!). Whenever you find a new paper, video, news article, or anything you want to cite, a small icon pops up in the corner. By clicking on that icon, the reference is automatically added to your Zotero library, and downloaded for viewing offline (if you have the standalone version, at least).

Once your references are in your Zotero library, they are easy to sort into folders. The best part, however, is the export feature. All or any subset of the library can be exported as a BibTeX file. Unfortunately, I ran in to two problems, both of which I solved after a short bit of Googling.


First, I noticed very quickly that all the "keys" were not the same as I written myself. I had a system previously in which I used the author and year, like \cite{Feynman1964}, but Zotero was creating the BibTeX file with keys with author, title, and year. What a pain it would be to go change all the citations in my papers.


The solution is to rewrite the translator file, BibTeX.js. Typically found in Users/AppData/Local/Zotero ... keep going until a translators directory shows. In there, edit the file BibTeX.js. 

Find the line:
var citeKeyFormat = "%a_%t_%y";
And change it to whatever you want. I changed mine to:
var citeKeyFormat = "%a%y";


Second, my LaTeX compiler could not recognize special characters, (รจ), even though Zotero output them into the BibTeX file. Instead, I found that I could go change them to "\`e" or something similar, but again, I'm not a fan of manually changing everything.


The solution is to use Western character encoding on export. The place to change this isn't obvious at first. In export options, it's necessary to check the box that says "Display character encoding option on export." Then a dropdown menu shows up in the export dialog, where you should pick Western character encoding.

Hopefully you too can enjoy the benefits of Zotero to their fullest extent. It sure has made my life easier, and I owe a big thanks to the folks behind the software and the surrounding community.

No comments:

Post a Comment