Tweaking default BibTeX key pattern via BibLaTeX.js translator in Zotero 5

I've been using the following key pattern [auth][year][shorttitle][volume] with Zotero 4 and BBT extension for quite a long time. Now when Zotero 5 has arrived (great job, by the way!) and BBT still being not compatible, how can I tweak the default translators in order to match the pattern I universally utilize?

var citeKeyFormat = "%a%y%t%v";

doesn't exactly use [shorttitle] as %t (it grabs the first word instead), and it seems like %v is not recognized as a key for volume.

Also, how reliable is this method of manual translators tweaking with Z5? Won't my changes be overwritten with an update in the future?
  • edited July 31, 2017
    The BibTeX translator is a file called BibTeX.js in the "translator" directory of your Zotero data folder: http://www.zotero.org/support/zotero_data
    Same for the BibLaTex translator: BibLaTeX.js

    In BibTeX.js and BibLaTeX.js, there are only three wildcards: %a %y and %t

    To add other wildcards, I think you just have to edit var citeKeyConversions (here in BibTeX.js, there in BibLaTeX.js).

    Short Title:
    "s":function (flags, item) {
    if (item["shortTitle"]) {
    return item["shortTitle"].toLowerCase().replace(citeKeyTitleBannedRe, "");
    }
    return "noshortTitle";
    }


    Volume (i.e. volume holding the item (e.g. “2” when citing a chapter from book volume 2))
    "v":function (flags, item) {
    if (item["volume"]) {
    return item["volume"];
    }
    return "";
    }


    and then adjust var citeKeyFormat accordingly.
    Also, how reliable is this method of manual translators tweaking with Z5? Won't my changes be overwritten with an update in the future?
    They will be. But you can change the translatorID, label, and lastUpdated at the beginning of the js file to create your own custom translator.
  • @Gracile Thank you, function for [volume] works fine, but [shorttitle] will always return `noshortTitle` when not explicitly defined in Zotero entry ("Short Title" field, which is in 95% of my entries is empty).

    I would expect [shorttitle] to return the value according to it's defined in JabRef (e.g. "The first 3 words of the title", http://help.jabref.org/en/BibtexKeyPatterns), and not the content of the field of similar name, which is in 95% of my entries is empty.
  • JabRef's key patterns are far from a "standard" and Zotero does not attempt to emulate them.
  • It would of course be possible to program your own shortTitle code into this translator that extracts the first three words from the title field. You can look at the code for Zotfile to see how such a regex pattern might be programmed.
  • edited August 1, 2017
    @andselisk what bwiernik said… something like this (without regex here) is perhaps too basic for your need:

    "s": function (flags, item) {
    if (item["title"]) {
    return item["title"].toLowerCase().replace(citeKeyTitleBannedRe, "").split(/\s+/g).slice(0,3).join("_");
    }
    return "";
    }


    adjust join("_") to modify the separator…
  • @bwiernik, @Gracile Thank you guys very much, the code works for me.

    I guess it's been feature-requested and discussed million times before, but I would really, really appreciate if the devs include a BibTeX-key constructor in Zotero GUI. This would make things so much easier.
  • If you want to tweak the citekey, BBT is currently the most convenient option even if I do say so myself. The pattern formatting roughly follows the JabRef patterns.
  • edited September 29, 2017
    @emilianoeheyns : at the time of the original post, as @andselisk wrote, BBT was not compatible with Zotero 5. That's now the case, thank you for the amazing work !
  • I wouldn't exactly call it amazing (it's a bit of a hodge podge), but yeah, a lot happened in the past two months.
Sign In or Register to comment.