Stop Zotero from escaping special characters in journal abbreviations
Hi all,
I'm trying to use the IEEEabrv file which contains a bunch of string definitions for abbreviated journal titles. This means exporting to a bibtex file and checking the "Use journal abbrevs." option. My journal abbrevs are like this: IEEE_J_AWPL. Unfortunately, Zotero exports that as IEEE\_J\_AWPL, and so a string replacement looking for IEEE_J_AWPL fails. Is there a way to tell zotero NOT to escape special latex characters?
Thanks,
Lefty
I'm trying to use the IEEEabrv file which contains a bunch of string definitions for abbreviated journal titles. This means exporting to a bibtex file and checking the "Use journal abbrevs." option. My journal abbrevs are like this: IEEE_J_AWPL. Unfortunately, Zotero exports that as IEEE\_J\_AWPL, and so a string replacement looking for IEEE_J_AWPL fails. Is there a way to tell zotero NOT to escape special latex characters?
Thanks,
Lefty
Now I've got a different problem. Zotero is wrapping the journal name in {}s. It seems that bibtex's @string command will not replace strings which are inside {}s. That's not an issue of using "bad" characters in the abbreviation strings, so is there a way to get zotero to stop wrapping journal abbreviations in curly brackets?
EDIT: Alternatively, is there somewhere I can just define my own "abbreviated journal titles" within zotero?
http://www.zotero.org/support/zotero_data
The relevant line is
https://github.com/zotero/translators/blob/master/BibTeX.js#L2155
for escaping and
https://github.com/zotero/translators/blob/master/BibTeX.js#L2174
for the curly brackets
note that both operations already don't run on some fields, so you could just add more.
Note that translators auto-update, so your customization would be overwritten on each translator update and, I believe, Zotero update, but since they're tiny changes they are easy to put back in. note quite sure I understand: you want an algorithm to create abbreviations? Or a list that Zotero uses for export? That's not possible. What is possible is to add a list that Zotero uses for citations with the Word/LibreOffice plugin
What I'm trying to achieve is basically a library of correct abbreviations. There is already a file that has the "standard" IEEE abbreviations; for instance it turns "Transactions on medicine and biology" into "Trans. Med. Biol." This is achieved by loading a IEEEabrv.bib file which adds a bunch of @string replacement lines before the main bib file is loaded, but the strings it's trying to replace are "IEEE_J_MB," so I need zotero's "use journal abbreviations" check box to generate the correct "IEEE_J_MB" type tags.
I would be equally happy if I could somehow teach zotero to automatically populate the journal abbreviation field based on some catalog, I could adapt that from this IEEE file. Currently the journal abbreviation field doesn't seem to be populated for most of my entries, although it is for some.
ps, here's information on the IEEEabrv file in question, if you're curious: http://www.michaelshell.org/tex/ieeetran/bibtex/
I'm trying to hack the BibTeX.js file and it doesn't seem to have any effect. To test things, I'm first trying to remove the braces from around the "author" field. (I'm not sure what the journal abbreviation field is called in the code). This doesn't appear to work. I've tried modifying line 2152 to be this:
if (!isMacro || field != "author" ) Zotero.write("{");
I also modified the corresponding close bracket code on line 2185.
If I understand correctly, with this modification if the field is "author" it won't write the opening or closing curly brackets. But when I open the .bib file the author list is still enclosed in curly brackets.
Am I misunderstanding what the BibTeX.js file is doing?
Thanks again for your help!
1. It should be
if (!isMacro && field != "author" ) Zotero.write("{");
2. the author field isn't actually written in that function - write fields deals with all the "normal" fields (e.g. for volume the above code works).
The author treatment is a bit more complicated, but should be pretty straightforward in terms of removing the curly brackets. It starts here, right in doExport:
https://github.com/zotero/translators/blob/master/BibTeX.js#L2424
Unfortunately if I do this:
if (!isMacro && field != "volume" ) Zotero.write("{");
the volume is still enclosed in brackets, so it seems I'm still missing something.
Also, do you know what the name of the journal abbreviation field is? I see that the "Short Title" field gets referenced as "shorttitle" in the code. Does "Journal Abbreviation" become "journalabbreviation"?
the above definitely works for volume, I tested it. Make sure you're modifying the right translator (there are separate bibtex and biblatex ones)
Here's what I've learned: it looks like if the code detects that the user wants to use journal abbreviations it copies the journalAbbreviation field into the journal field and then runs writeField(). This means that writeField never knows that the field in question is actually an abbreviation, so testing for journalAbbreviation will always fail.
Here's what I did instead:
I modified line 2410 to flag the entry as a macro:
writeField("journal", item.journalAbbreviation,true);
This means escape characters, extra braces, etc are all skipped. I think this is reasonably correct, I'm basically wanting to use the journal abbreviation as a macro that gets interpreted by a separate .bib file.
What do you think? Too ugly? Some nasty consequence I'm not anticipating?
Thanks for your help!
It turns out that the entries which lacked text versions of the abbreviated journal title (and for which I was trying to set up these keys with underscores) were just the entries I'd populated by pasting the DOI into Zotero. Entries grabbed from the journal website have the journal abbreviation in there just fine, so aside from papers I downloaded before I got Zotero, everything works fine with the default behavior, and for non-IEEE journals (ones where I don't have the keys for abbreviations anyway) my original solution breaks the abbreviations completely.