Zotero – exporting Unicode and LaTeX constructs to BibTex

 

You are reading the old blog! This post has been moved to http://www.ohadsoft.com/2012/06/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:

  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. Change the following:
     var alwaysMap = {
     "|":"{textbar}",
     "<":"{textless}",
     ">":"{textgreater}",
     "~":"{textasciitilde}",
     "^":"{textasciicircum}",
     "":"{textbackslash}"
    };  

    to the following:

     var alwaysMap = {
     "|":"{textbar}",
     "<":"{textless}",
     ">":"{textgreater}" //,
    // "~":"{textasciitilde}",
    // "^":"{textasciicircum}"
    // "":"{textbackslash}"
    }; 
  3. Change the following:
     value = value.replace(/[|<>~^]/g, mapEscape).replace(/([#$%&_])/g, "$1");  

    to the following:

     value = value.replace(/[|<>]/g, mapEscape).replace(/([#%&])/g, "$1");  
  4. Save the file.

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

References and further reading

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

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

http://gist.github.com/956623

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

Advertisements

3 Responses to “Zotero – exporting Unicode and LaTeX constructs to BibTex”

  1. Jorgen Says:

    Thanks for the tips for getting Latex-code instead of unicode symbols in the export.

    Like

  2. Bibliography, Biber, Emacs, Zotero, and UTF-8… | Theoretical Condensed matter Says:

    […] explained in this reference, you should pay attention to the export format. This is understandable, since the .bib file has to […]

    Like

  3. Zotero and BibTeX | Wheels on the bus Says:

    […] to preserve them.  After trying many variations and doing lots of web searching, I found a great blog post by Ohad Schneider, which lead me to a […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: