Quick fix for BibTeX bug
New Zotero user here, trying to get the BibTeX support up and running for my library. The BibTeX exporter doesn't currently respect the "first name" and "last name" distinctions that we can type into the Zotero client. It's a one-line fix, though.
If you change the original code:
BibTeX.js:
...
for each(var creator in item.creators) {
var creatorString = creator.lastName;
if (creator.firstName) {
creatorString = creator.firstName + " " + creator.lastName;
}
...
to:
for each(var creator in item.creators) {
var creatorString = creator.lastName;
if (creator.firstName) {
creatorString = creator.lastName + ", " + creator.firstName;
}
then the BibTeX processor itself should do all your dirty work for you, as it has support built-in for comma-separated names. This will make things like "First name: Simon", "Last name: Conway Morris" work correctly, without you having to do anything like add braces in the translator (which breaks things like "van der Sloot") or add braces in Zotero itself (which breaks sorting).
I'd submit a patch if I knew where. Or, rather, I suppose I just did submit a patch, is this the right place to put it?
lastName: Johnland
firstName: John, de
and suffixes:
lastName: Frankson, Sr.
firstName: Frank
we'd get author lists like:
Johnland, John, de and Frankson, Sr., Frank
instead of the current:
John, de Johnland and Frank Frankson, Sr.
I suppose that's no worse.
Say you had a worst case scenario name, "ll, ss, ff, vv" ("Johnland, Sr., John, de"). BibTeX would see that and parse it as:
Last: Johnland
First: John, de
von: (blank)
Suffix: Sr.
So yeah, not great, but it's an easy tweak if you're worried about it.
Dropping particles have to be in the first name, it seems.
Of course, this is all a bit of a hack-- I still hope to see a more robust name entry system in a future release of Zotero, so we can explicitly set these parts as necessary.
So actually, BibTeX is completely compatible with that documentation file you sent along...
(I don't, on a related note, have a good idea for what to do with the more general names problem -- users would almost certainly be confused by *five* fields into which you can type inputs for every single name, especially users in languages that don't have particles, or that don't maintain a distinction between dropping and non-dropping particles. OTOH, there's no reliable way to detect the difference between dropping and non-dropping particles, so there's no clear way to deal with that problem with more code.)
It should work the way you request. If this works for you, please post here so that I can submit this change to be pushed to all users.
Where are those braces applied? They need to be applied *before* the comma-joining happens.
The easiest approach is to put a space between the last name and the comma, or we could add a special case for creators that would move the comma back out.
https://github.com/karnesky/zotero-bits/commit/a8a7f87bba141a6c56ff2e5d631312dba09feed6#BibTeX.js
Your proposed fix is something I considered, but I wasn't sure if there was ever a good reason to have a braced final comma. I can't think of any reason either-- so let's try this version:
Please go to http://github.com/ajlyon/zotero-bits/raw/master/BibTeX.js and save the file to the translators directory of your Zotero data directory (http://www.zotero.org/support/zotero_data).