'$' character in Bibtex export file

Hello Zotero guys,

Recently I have exported some references from my library to the Bibtex format to use inside Latex. Unfortunately, one of the references had the '$' character in its title and Zotero exported the Bibtex references with this character like this:

@inproceedings{anthony_$n-protractor:_2012, ...

The '$' character is a special character in Latex language causing some issues when I tried to cite this reference in my paper.
The solution was pretty obvious: I just renamed the citation to something without this character and everything worked.

The problem is that I have to do this everytime I export this set of references from Zotero to Bibtex. It would be nice if you change this behavior. This character could be replaced by anything, like DOLLAR or USD, or whatever other character.
  • I don't quite understand - the dollar character in the title is properly escaped with a backslash - that should be fine in Latex.

    Or is the problem the citekey? - do we need to escape the $ there as well?
  • edited April 13, 2013
    The problem is in the citekey. Sorry for not being that clear.
    If you scape that in the citekey, it will not work properly (I have tried).

    I believe a good solution is just to ignore this character (remove it) from the citekey, or replace it by something else.
  • that's a bug. It's not supposed to happen and there is code in place to prevent any illegal characters in citekeys - I'll see why that's not working correctly.
  • Ok, adamsmith. Thank you for your attention and support.
    Please, let me know if I can help you with anything regarding this problem.
  • If you want a quick fix you can open the bibtex translator -
    the file BibTeX.js in the translator directory of the Zotero data folder:
    http://www.zotero.org/support/zotero_data#locating_your_zotero_library - in any text editor,
    find this line:
    var citeKeyCleanRe = /[^a-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+/g;
    and remove the \$ so it reads

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

    The \$ looks like a very purposeful inclusion there, so I want to figure out why it's there in the first place before deleting it from the general translator.
  • I see.
    Well, I will do it as a quick fix. I hope you are able to fix it in next release.
    Thank you!
  • a follow up - researching this, $ is not generally banned from citekeys - what bibtex manager do you use?
  • I'm using Texmaker and Miktex for Windows.
    It is not a compile problem. But it does not generate the PDF file properly.
  • could you expand on that? I tried this out with a simple document running pdflatex mydoc.tex
    bibtex mydoc.aux
    pdflatex mydoc.tex

    and got a fine looking PDF inspite of a vermeulen_$topical_1996 citekey
    What exactly happens in your case?
  • edited April 13, 2013
    Well, thats awkward. It is generating the pdf file properly now.
    I dont know what happened. The PDF file was being generated without references..

    The only weird thing that happens with a $ character inside a citekey is that the TexMaker editor marks the whole text after the '$' as a command in math mode. But it is just an editor issue. Compilation and PDF creation (appearently) work fine.

    Well, I think I will keep out this '$' from the Bibtex translator, because the TexMaker editor is not working properly with that: it can't autocomplete any other command since the '$' is not followed by another '$' "ending a supposed command".
  • I think if we were to do this over I'd remove it. But since there may be people with existing documents with $ in their citekeys we're reluctant to change it now. (the editor thing is common btw - AucTeX in emacs does that, too).

    You may have to redo this in case of future updates (which don't coincide with Zotero updates - translators get updated almost instantly), but now that you know where/how that should be quick.
  • edited April 13, 2013
    Yes, that's what I will have to do.

    I dont think people who have '$' in their citekeys will have a big problem. LaTex will complain at compile time and it will be fixed by just changing the citekey's occurrences in the document. A find and replace would do the job very quickly.

    Another way to have a solution would be to create another BibTex translator with this feature, thus, people who has '$' in their citekeys will not be affected.
Sign In or Register to comment.