Zotero – exporting Unicode and LaTeX constructs to BibTeX
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:
- Zotero Preferences -> Export -> check Display character encoding option on export
- 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:
- Locate your Zotero data directory and open _translatorsBibTeX.js _with your favorite text editor
- Find the following :
var alwaysMap = { "|":"{\textbar}", "<":"{\textless}", ">":"{\textgreater}", "~":"{\textasciitilde}", "^":"{\textasciicircum}", "\":"{\textbackslash}" };
- Change it to the following:
var alwaysMap = { "|":"{\textbar}", "<":"{\textless}", ">":"{\textgreater}"
- Find the following:
value = value.replace(/[|<>~^\]/g, mapEscape).replace(/([#$%&_])/g, "\$1");
- Change it to the following:
value = value.replace(/[|<>]/g, mapEscape).replace(/([#%&])/g, "\$1");
- 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
Leave a Comment