Prevent extra braces in BibTeX export
Hello!
I'm using Zotero to generate BibTeX files and I would like to change the way that braces in the title field are handled. For now Zotero puts Braces around every capitalized word in the Title in order to preserve the capitalization. I'm trying to turn off that behavior as I believe it's not the optimal way of doing it.
Most BibTeX and BibLaTeX are able to properly convert titles to lower case but not to convert them to title case. Therefore I am storing all titles in title case (that's also how most get automatically imported via the browser plugin) and put braces around those words that should not be converted in case a style requires lowercase.
Thus for those styles requiring Title case, proper capitalization is already achieved, and for those requiring lowercase it is easy to automatically convert as proper names are protected and will remain as they should be.
For example, this is how a title is stored in Zotero:
Dual Language Education in {Canada} and the {USA}
And when exporting to a .bib file it should produce.
Title = {Dual Language Education in {Canada} and the {USA}},
Unfortunately as of now the words "Language" and "Education" also get braces and I have no idea how to turn that off.
Any help much appreciated!
I'm using Zotero to generate BibTeX files and I would like to change the way that braces in the title field are handled. For now Zotero puts Braces around every capitalized word in the Title in order to preserve the capitalization. I'm trying to turn off that behavior as I believe it's not the optimal way of doing it.
Most BibTeX and BibLaTeX are able to properly convert titles to lower case but not to convert them to title case. Therefore I am storing all titles in title case (that's also how most get automatically imported via the browser plugin) and put braces around those words that should not be converted in case a style requires lowercase.
Thus for those styles requiring Title case, proper capitalization is already achieved, and for those requiring lowercase it is easy to automatically convert as proper names are protected and will remain as they should be.
For example, this is how a title is stored in Zotero:
Dual Language Education in {Canada} and the {USA}
And when exporting to a .bib file it should produce.
Title = {Dual Language Education in {Canada} and the {USA}},
Unfortunately as of now the words "Language" and "Education" also get braces and I have no idea how to turn that off.
Any help much appreciated!
I'd this urge you to use sentence casing and edit your BST styles if needed.
If you'd prefer to use the more idiosyncratic method, you'd need to edit BibTeX.js (or possibly use the better bibtex extension) and put up with the breakage when using anything other than bibtex export (e.g. sharing data with others and the word processor plugins).
Would you be able to let me know how to edit BibTeX.js?
I'm not using a word processor plugin or sharing so it should be fine,
I only need the BibTeX export to be tweaked.
I'm already using the Better BibTeX extension but I couldn't find any option to control the braces.
You wrote that Zotero tends to import titles in sentence case, but I don't seem to get that behavior on my system (I'm using the Firefox integrated version of Zotero). It seems to respect whatever the format is on the website that it imports the titles from. Google books for example has the books in Title case whereas Google scholar uses sentence case, who knows why. And that's how they end up in my Zotero.
Or is there a setting how to control this?
If you use Better Bibtex's styles, you will need to consult with their support services for how to do it. They do seem to have settings to control title casing: https://github.com/retorquere/zotero-better-bibtex/wiki/Configuration
If you use Zotero's style, you may first try to use the hidden BibTeX.export.dontProtectInitialCase preference. If this is insufficient, you'd need to modify the translator.
I would suggest manually correcting to sentence case after import where it is in title case so that you get correctly protected proper nouns in Bibtex.
And it works not only for the BibTeX translator, but also for Better BibTeX!
@adamsmith I spent some time trying to figure out what the best practice would be for storing titles, and the way that I described above seems to me still the best solution for BibTeX users, although for those using Zotero for export to other formats that's obviously not the case.
Storing everything in Sentence case and then having it convert to Title Case for those bib styles that require it might work if all titles are in English. But if there's a lot of foreign language stuff, which has different rules then it gets messy, as one would have to keep a language ID field always up to date so that BibTeX or BibLaTeX know how to render each title. Therefore I prefer to store them in Title case, while protecting uppercase words, for English titles or, for other languages I store them in whatever the language demands, in which case I usually protect the entire string. Thus it's easy for BibTeX to convert titles to lower case if required.
Don't know if there's any better way of doing it?
In any case, this seems like it shouldn't be limited to BibTeX. If the CSL processors are handling casing appropriately, I'd expect some BibTeX-like toolchain should be able to handle it as well.
If not, it seems like a much better way to go would be to have Zotero store entries in sentence case and fix on export to Bib(La)Tex. The translator could first preserve capitalization using brackets and then perform a sentence-to-title-case conversion for you.
It is true that the BibTeX importer doesn't undo the titlecasing, but that's a right-click away after import in the Zotero interface.
Fully agreed with @adamsmith, the way to go is to have references in sentence case in Zotero and let the BibTeX translator deal with Title Casing. That way, you don't have the extra braces (which ought to do no harm BTW), but the rule for the BibTeX exporters is, as it should be, "if you have capitals in your text other than at the start, I must assume you want them there", which is only achievable using braces. The single-wrap braces don't always achieve that BTW for reasons that could drive a man to drink.
Capitalization is only needed for references that are in English(ish) languages, BTW. I don't know how the stock BibTeX translator does it (I've looked, but I can't find where it would be doing the title casing), but BBT will only do it to English(ish) references. Refs without language specified are assumed to be English.
"Design of a new 680 nm laser". Here "nm" stands for the nanometer unit, and should be kept in lowercase all the time, even if converted to Title Case:
"Design of a New 680 nm Laser".
It doesn't look like Zotero can handle such a case. Of course, in BibTeX, you would protect the case with braces {nm} and everything would be easy.
Note this is not a BibTeX/LaTeX issue. Exporting to Word or whatever wouldn't work either for cases such as above.
Also I'm not sure I would agree that this casing issue should be fully handled at the export phase. When using BibTeX, the casing is normally handled by the style file (the BST), and the BIB file should have the data in such a way as it can lead to both correct Title and Sentence case, depending on the style you use. If you export with correct sentence case in the BIB file, and no protection, then use a style that generates title case, you are in trouble for titles like above. Therefore the exporter shouldn't just output whatever case is deemed correct, it should also protect special cases so a conversion down the track is still possible.
Anyway, irrespective of this later point, if Zotero provides a way to handle my "680 nm laser" case, that would already be a big plus.
Design of a new 680 <span class="nocase">nm</span> laser
Documentation: https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#html-like-formatting-tags
The export via the standard BibTeX or BibLaTeX exporter however is broken and should be fixed:
title = {Design of a new 680 {\textless}span class="nocase"{\textgreater}nm{\textless}/span{\textgreater} laser},
However, if there has to be markup, I can't see why
Design of a new 680 .span class="nocase".nm./span. laser (using "." for "<" and ">")
is better than
Design of a new 680 {nm} laser
?? I guess the HTML is more general, but seriously that's a lot of markup to protect one letter. Anyway, happy it can be done. And I think better-bibtex handles it properly.
Thanks
There's long been the desire to implement this more elegantly, i.e. don't display the tags in the field and don't require manual marking up, and when that's implemented, I think we should include a proper solution for no-case tagging (which may well just use the same syntax behind the scenes).
I'm having trouble getting the tweaks described above in this threat to work again after updating to Zotero 5 (I had been using the Firefox extension prior to Quantum).
I am trying to suppress adding extra braces for capitalized words in titles upon BibTeX export.
I have added
user_pref("extensions.zotero.BibTeX.export.dontProtectInitialCase", true);
to
/Users/[name]/Library/Application Support/Zotero/Profiles/[string]/prefs.js
but to no avail.
(I'm also using Better BibTeX, not sure if that makes a difference)
Any hints much appreciated.
According to
https://retorquere.github.io/zotero-better-bibtex/configuration/
there seems to be a hidden pref
suppressTitleCase
so now I've tried to add
user_pref("extensions.zotero.translators.better-bibtex.suppressTitleCase", true);
to the same
/Users/[name]/Library/Application Support/Zotero/Profiles/[string]/prefs.js
but that doesn't do anything either (and that line is also deleted again upon restarting Zotero).
Any further ideas?
Edit: also, make sure you're using the right translator. BBT preferences affect BBT BibTeX, the other ones the regular one. Finally, what exactly are you after -- this is a pretty complex thread, so it's not entirely clear what behavior specifically you want to prevent.
Essentially:
I'm trying to prevent the addition of extra {braces} to protect capitalized words in title fields when exporting form Zotero to BibTeX formats.
I've been storing titles in title case in Zotero and manually protected proper names and words in all caps (I know I'm not following established best practices :/ but there's a few reasons for this: (a) I have lots of foreign language titles where I'd like to keep the original casing, (b) I mostly use Chicago which wants title case anyways, (c) conversion to sentence case is fairly easy in LaTeX but not the other way round.)
In the previous Firefox Zotero it was working fine, I had Better Bibtex installed and then "extensions.zotero.BibTeX.export.dontProtectInitialCase" to true and all was fine.
But not any more after updating ...
Any help?
PS: I did choose "Better BibTeX" under Export.
extensions.zotero.translators.BibTeX.export.dontProtectInitialCase
and with that it works for the stock BibTeX export. You should post to the Better BibTeX issue tracker with the problem with the BBT export not taking that preference (which I can replicate)
without "translators". I've changed it and it works now, although only without Better BibTeX. Thank you for your help!
The suppressTitleCase preference ought to work for BBT, if it doesn't I'd appreciate a bug report on the github issue tracker.
I already have "correct" bib files. When I import one of them into Zotero under BBT and export it to a bib file using BBT, it's converted to a "wrong" bib file. By "wrong", I mean a wrong brace protection. For example, when the original was
Coastal-Trapped Waves and Wind-Driven Currents Over the Continental Shelf
the converted result was
Coastal-{{Trapped Waves}} and {{Wind}}-{{Driven Currents Over}} the {{Continental Shelf}}
Bibtex or biber converts the original correctly to sentence case or title case depending on the style but the braces in the latter prevents that conversion from happening.
In terms of sentence or title casing, my bib files are inconsistent because the entries are from various sources or from copy-and-pasting from manuscripts and papers. Nevertheless the cases are correctly protected by braces in my bib files.
So, I'm interested in what's happened to this discussion.
If you right-click the title and convert it to sentence case, the export will change appropriately. I could look at sentence-casing on import, but that's bound to have nasty edge cases, and it would require extensive changes to the parser. I can't make any commitments on this one.
More generally, a) BBT does not (cannot) guarantee damageless round-tripping of bibtex because of the many subtle and not so subtle differences between the reference model of bib(la)tex and zotero, and b) support for BBT happens on github. I happened to catch this because I posted on this thread before but that's not always going to happen.