Skip to content

Instantly share code, notes, and snippets.

@JoschD
Last active May 16, 2023 11:26
Show Gist options
  • Save JoschD/de74505e9eb08fa355869c6073360775 to your computer and use it in GitHub Desktop.
Save JoschD/de74505e9eb08fa355869c6073360775 to your computer and use it in GitHub Desktop.
Better BibTeX Export

Add scripts into Preferences -> Better BibTeX -> Export -> Postscript

Change Zotero Presentation Items to techreport

and add Field 'Meeting Name' as type.

if (Translator.BetterBibTeX) {
  // Replace presentations with techreports
  if (zotero.itemType === 'presentation') {
    tex.referencetype = 'techreport';    
    if (zotero.meetingName && !zotero.type) {
      tex.add({ name: 'type', value: zotero.meetingName });
    };  
  };
}

Replace "and others" or "and et. al." with "et al."

if (Translator.BetterBibTeX) {
  // replace 'and others' with 'et al.'. 
  // This allows you to give only one author and 'et al.' or 'others' and have 'et al.' in the final document.
  if (zotero.creators.length === 2) {
    const lastCreator = zotero.creators[zotero.creators.length - 1];
    if (lastCreator.lastName === "et al." || lastCreator.name === "et al.") {   
       tex.has.author.bibtex = tex.has.author.bibtex.replace(/and\s+\{*et\s+al\.\}*/, '{et al.}}')      
      //Zotero.debug(JSON.stringify(tex.has.author.bibtex));
    };
     if (lastCreator.lastName === "others" || lastCreator.name === "others") {   
       tex.has.author.bibtex = tex.has.author.bibtex.replace(/and\s+\{*others\}*/, '{et al.}}')            
    };
  };
  
  // remove unnecessary fields
  tex.remove('file');
  tex.remove('keywords');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment