Brackets around words in .bib exports

I've often found that when using "add items by identifier" (usually DOI or ISBN) or using the browser extension to add items to my Zotero library, the entries will appear correctly in the Zotero desktop client, but will have idiosyncratic curly brackets {} around words in the title, author, etc. for the entry. For example, the below presents an Obama speech where the title has bracketed words.

address = {Roanoke},
type = {Transcript},
title = {Remarks by the {President} at a {Campaign} {Event} in {Roanoke}, {Virginia}},
url = {},
author = {Obama, Barack},
month = jul,
year = {2012},

Unfortunately, this can cause formatting issues with exported to e.g. BibTex. Typically, it creates large spaces around words and makes the bibliography largely unintelligible.

Anyone have any advice on how to address this behavior? Is this the result of some setting?
  • They're not actually correct in zotero; zotero expects them to be sentence cased, not title cased, and bibliographies as rendered in word can be wrong because of this. Right-click the title and select "sentence case", that will fix it.
  • Is there a way to batch change this? I have over 5,000 records I need updated and it'll take a little while to manually click through!
  • It's possible but I wouldn't advice it. The sentence case algorithm is very naive, and you need to check the results. It just blithely lowercases all words that are not at sentence start, so all proper nouns get lowercased too.
  • Yeah, I found more documentation on this and discussion of the issue:

    It's actually easier to go sentence case to title case in my situation (very few proper nouns in titles and I can manually change thos)e, so just looking if anyone has implemented something to do this
  • It's always easier to go from sentence case to title case, that's why Zotero has the titles in sentence case.

    If you open Tools -> Developer -> Run Javascript, check "Run as async function", and paste in this code

    function sentenceCase(text) {
    let haslowercase = false
    const restore = []
    let sentencecased = text.replace(/((?:^|[?!]|[-.:;\[\]<>'*\\(),{}_“”‘’])?\s*)([^-\s;?:.!\[\]<>'*\\(),{}_“”‘’]+)/g, (match, leader, word, offset) => {
    if (word.match(/^[A-Z]$/)) {
    const leaderlen = leader && leader.length
    restore.push([offset + leaderlen, offset + leaderlen + word.length, word])
    else if (word.match(/^[a-z]/)) {
    haslowercase = true
    if (leader && !leader.match(/^[?!]/) && word.match(/^[A-Z][^A-Z]*$/)) word = word.toLowerCase()
    return (leader || '') + word

    if (haslowercase) {
    for (const [start, end, word] of restore) {
    sentencecased = sentencecased.substr(0, start) + word + sentencecased.substr(end)

    // restore protected parts from original
    text.replace(/<span class="nocase">.*?<\/span>|<nc>.*?<\/nc>/gi, (match, offset) => {
    sentencecased = sentencecased.substr(0, offset) + match + sentencecased.substr(offset + match.length)
    return match

    return sentencecased

    for (const item of Zotero.getActiveZoteroPane().getSelectedItems()) {
    if (!item.isRegularItem()) continue
    const title = sentenceCase(item.getField('title'))
    if (title === item.getField('title')) continue
    item.setField('title', title)
    await item.saveTx()

    and click "Run", it will apply sentence casing to all items you have currently selected in Zotero. Inspecting the results is on you -- This one is a bit more refined than the Zotero sentence caser, but not much, and it has absolutely zero understanding of language (English or otherwise).
  • Regarding "Unfortunately, this can cause formatting issues with exported to e.g. BibTex. Typically, it creates large spaces around words and makes the bibliography largely unintelligible.", I wonder what you're using to render the bibtex, because I've never seen effects like this. Bracing words is best practice for keeping capitalization. Do you mean line breaking doesn't work because of the braces, leading to bad breaking? That would be very strange, because braces are also used for eg italics, and bibtex breaks across that just fine.

    I'd need to see a sample of what's going wrong, but from the sounds of it, your bibtex pipeline is wonky.
Sign In or Register to comment.