Zotero – exporting Unicode and LaTeX constructs to BibTeX

1 minute read

Zotero is a great reference manager, especially if you’re using Firefox. Its BibTeX export is invaluable for LaTeX / LyX users. However, it has a couple of sticking points whose solutions are not well documented. These issues can be especially annoying for researchers working in exact sciences (math, physics, etc.)

Problem 1: Article info contains special Unicode characters (such as é). As BibTeX doesn’t support Unicode, LaTeX compilation fails.

Solution:

  1. Zotero Preferences -> Export -> check Display character encoding option on export
  2. Whenever you export your database, pick a non-Unicode character encoding such as ISO-8859-1

Zotero will now convert the Unicode characters to their native LaTeX equivalents (for example, é will be converted into ‘{e}).

Note: You could also solve this on the LaTeX side by using Biblatex and biber. However, I wasn’t able to make them work under LyX.

Problem 2:Article info contains Latex constructs (e.g. $O_{3}$). Zotero escapes these and so they appear verbatim in the reference (e.g. $O_{3}$ instead of O₃)

Solution:

  1. Locate your Zotero data directory and open _translatorsBibTeX.js _with your favorite text editor
  2. Find the following : var alwaysMap = { "|":"{\textbar}", "<":"{\textless}", ">":"{\textgreater}", "~":"{\textasciitilde}", "^":"{\textasciicircum}", "\":"{\textbackslash}" };
  3. Change it to the following: var alwaysMap = { "|":"{\textbar}", "<":"{\textless}", ">":"{\textgreater}"
  4. Find the following:  value = value.replace(/[|<>~^\]/g, mapEscape).replace(/([#$%&_])/g, "\$1");
  5. Change it to the following: value = value.replace(/[|<>]/g, mapEscape).replace(/([#%&])/g, "\$1");
  6. Save the file.

Escaping of ~, ^, **,$,_** is now disabled, preserving your LaTeX constructs.

References and further reading:

https://forums.zotero.org/discussion/5324/bibtex-and-greek-characters/

https://groups.google.com/forum/?fromgroups#!topic/zotero-dev/U9fGc1f3TO8

https://gist.github.com/956623

https://www.rtwilson.com/academic/autozotbib

Leave a Comment