v.5.0.4 - bibtext-key error with ampersands {\&}

I have today upgraded to v5 (awaiting eagerly that BetterBibTeX will be available at some point later...). When I export my bibliography in bibtex, I keep getting errors whenever there's an ampersand involved. No matter what I do in Zotero, when the title includes an ampersand - even included in {\&} - the exported bib file eliminates this in the output (only for the bibtex-key).

Is there a way to fix this?
  • just to understand correctly -- you're not getting an error message, right? Zotero just exports citekeys without ampersands? That's on purpose. Zotero does (and has for a long time) removed a bunch of words and characters from citekeys:
    https://github.com/zotero/translators/blob/master/BibTeX.js#L1121

  • jkr
    edited July 15, 2017
    no error message.

    > var citeKeyCleanRe = /[^a-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+/g;

    that's what not working in my case - or perhaps it does? Because I get an error message in RStudio running Markdown through pandoc-citeproc

    the output file using the new BibTeX.js still yielded

    @article{diks_e&f_2008

    thanks for the fast reply!
  • ah OK, had that turned around. So, it's not removing ampersands from citekeys as it should. The code was refactored a little in 5.0, and it's possible this broke. We'll look into it.
  • great, thx
  • actually, sorry, I looked at this too quickly. That code explicitly allows ampersands in citekeys. I never quite understand which characters are or aren't allowed in citekeys and it seems like every implementation has its own view on this (and I don't like modifying the citekey generation code so as to not break existing documents) but for your own purposes, if you just delete \& from the line above in your BibTeX.js it will remove the ampersands (the regular expression lists allowed, not forbidden, characters).
  • Excellent. That did the trick.
  • note that this change will get overwritten on bibtex.js updates in the future -- for such a small change, I'd just recommend to fix this when it comes up again so that you can benefit from other fixes in the bibtex translator
Sign In or Register to comment.