Case protection in BibTeX export format

A place for users to ask each other questions, make suggestions, and discuss Bookends.
lyndondrake
Posts: 51
Joined: Sat Jul 04, 2015 3:36 am

Case protection in BibTeX export format

Post by lyndondrake »

Hi,

In general, I like using sentence case for my references within Bookends, because it is unambiguous which words are capitalised on purpose. I would like to preserve my careful use of case in my BibTeX export, which is actually aimed at BibLaTeX and for which Title case is best practice. I would like to case-protect some fields, so that instead of:

title = {The Names Shaddai and Abram},

I would get:

title = {The Names {{Shaddai}} and {{Abram}}},

In other words, any words with capitalisation in them would be case-protected. This is what Zotero's BetterBibTeX exporter can do and it's quite useful.

Is there a way to offer an option, e.g. via a special character which would BibTeX case-protect the preceding field? Maybe the § character as it's not used in the special characters at this point.
iandol
Posts: 465
Joined: Fri Jan 25, 2008 2:31 pm

Re: Case protection in BibTeX export format

Post by iandol »

What you want is not possible within Bookends AFAIK, and Jon would hopefully be able to say if this would be possible. However, shouldn't it be the job of the system that creates the bibliography to respect your title case?

For my use (biology) where terms must be enforced wether the rest of the title is title case or not, my workaround was to write a ruby script to do this for me, which can be automated to work each time the BibTeX file is changed:

https://github.com/iandol/dotfiles/blob ... fixCase.rb

You'd need to change the word lists to those you use, if you wanted to make use of it...
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Case protection in BibTeX export format

Post by Jon »

Bookends has the option in preferences to case-protect acronyms (like DNA), but not just a capitalized word. In your example, Name is capitalized, yet you didn't surround it with curly brackets in the desired export. Was that an oversight? If not, and you only want specific words protected, I think what you want is equivalent to the "Don't change case" option in preferences. Do you and any others reading this think it would be useful if Bookends surrounded any words in this list that begin with a capital letter in curly brackets? In such as case, if Shaddai and Abram were entered in preferences you'd get {The Names {{Shaddai}} and {{Abram}}}.

Jon
Sonny Software
lyndondrake
Posts: 51
Joined: Sat Jul 04, 2015 3:36 am

Re: Case protection in BibTeX export format

Post by lyndondrake »

Actually that's a great suggestion — you are right that it's definitely possible for me to make a list of all the words which should be case-protected, and that's likely to be extremely subject-specific so a user-defined list is no doubt the best approach.
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Case protection in BibTeX export format

Post by Jon »

I've played with that, and you should note that case protection works in the opposite way, too. Meaning that words that should appear in lowercase in that list are protected as well.

An example where I've added "United States" to the protected words in preferences. Note that the lowercase exclusions are protected as well.

{the} {United States} {is} {in} North America

I assume that is not acceptable and you would only want words beginning with caps to be protected. Right?

Jon
Sonny Software
lyndondrake
Posts: 51
Joined: Sat Jul 04, 2015 3:36 am

Re: Case protection in BibTeX export format

Post by lyndondrake »

Yes, I hadn't thought about that possibility but you're correct.
iandol
Posts: 465
Joined: Fri Jan 25, 2008 2:31 pm

Re: Case protection in BibTeX export format

Post by iandol »

Jon wrote: Fri Apr 08, 2022 7:19 am Do you and any others reading this think it would be useful if Bookends surrounded any words in this list that begin with a capital letter in curly brackets? In such as case, if Shaddai and Abram were entered in preferences you'd get {The Names {{Shaddai}} and {{Abram}}}.
In my script to do this post-export, I have two lists: [keep case] and [enforce case]. The second ignores the source case, always protects with a defined pattern. The first only protects the case if it is already in that case. In my field I have lots of terms like "ON cells" and I want to preserve "ON" but not if it is "on" or "On" in the title. In general I think a [keep case] list add flexibility. The main difference in these two situations is whether one matches the case when pattern matching — i.e. lets say you are using regex for "Shaddai", does one match case insensitively?

As a basic function, I think your solution should cover most use cases, I assume you will match case insensitively then replace with the case in the list or just wrap whatever was in the title?
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Case protection in BibTeX export format

Post by Jon »

Bookends already matches "do not change" words (set in preferences) when outputting the title in either Sentence Case or Title Case. What I'm thinking of doing if specific for when BibTeX Markup is being used (as opposed to Styled Text, Plain Text, HTML, etc.). In this case, in addition to the usual setting of upper/lowercase, Bookends would wrap words that begin with a capital letter in the "don't change" list in curly brackets. Words in the list that are lowercase (e.g. the, a, an, etc.) would not be protected with curly brackets.

I'm not sure if this should be done automatically, or if should be opt-in with a preference setting. Maybe the BibTeX users reading this would weigh in on that (avoiding yet another preference setting would be my preference).

Jon
Sonny Software
kseggleton
Posts: 43
Joined: Fri Jan 01, 2016 6:47 am

Re: Case protection in BibTeX export format

Post by kseggleton »

Jon wrote: Tue Apr 12, 2022 10:15 am Bookends would wrap words that begin with a capital letter in the "don't change" list in curly brackets. Words in the list that are lowercase (e.g. the, a, an, etc.) would not be protected with curly brackets.
This would work well and I would be keen to see it implemented for my workflow.
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Case protection in BibTeX export format

Post by Jon »

It's done, and if no major problems crop up it will be in the next update.

Jon
Sonny Software
lyndondrake
Posts: 51
Joined: Sat Jul 04, 2015 3:36 am

Re: Case protection in BibTeX export format

Post by lyndondrake »

Many thanks, really appreciate this.
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Re: Case protection in BibTeX export format

Post by Dellu »

I'm not sure if this should be done automatically, or if should be opt-in with a preference setting. Maybe the BibTeX users reading this would weigh in on that (avoiding yet another preference setting would be my preference).

Jon
Sonny Software
For God's sake, please make this an option in the Preference.


I don't want a global case protection. The braces make the bib file look dirty. Furthermore, it will mess up bibliographies that want a specific type of case on the references. Bibliography styles are made for this purpose. One can have all in caps, all in small, or in title case outputs in the Latex from the same bibliography file using bibliography styles. Fixing the Case on the bib itself globally is undermining of the power that Latex gives us.

Assume Journal X wants references in all CAPS: and another journal Y wants references in Titles: you don't have to change the bib source itself for every journal. What you need is change the bibliography style. Journals often provide their own style that will take of reference formatting.
- Only abbreviations need protection. That is the standard approach.
lyndondrake
Posts: 51
Joined: Sat Jul 04, 2015 3:36 am

Re: Case protection in BibTeX export format

Post by lyndondrake »

Jon wrote: Tue Apr 12, 2022 5:42 pm It's done, and if no major problems crop up it will be in the next update.
Hi Jon, thanks for this. When I tick the checkbox for "Bracket "don't change case" words in title, {Paris}", and if I then close the Preferences and reopen, the tickbox is unchecked again.
iandol
Posts: 465
Joined: Fri Jan 25, 2008 2:31 pm

Re: Case protection in BibTeX export format

Post by iandol »

Dellu wrote: Wed Apr 13, 2022 3:07 am The braces make the bib file look dirty. Furthermore, it will mess up bibliographies that want a specific type of case on the references. Bibliography styles are made for this purpose. One can have all in caps, all in small, or in title case outputs in the Latex from the same bibliography file using bibliography styles. Fixing the Case on the bib itself globally is undermining of the power that Latex gives us.
At least in my field, there are a bunch of non-standard abbreviations that are not handled by generic formatting styles (whether it is BibTeX or CSL), like dLGN or ON-Cells or fMRI and these do need special case protection. Brackets {} are there for a reason in the BibTeX spec (and the equivalent in the JSON equivalents, there's nothing "dirty" about it), allowing users to customise their titles to override generic rules. Anyway, having this as an option is fine, although if you don't want case protection you can just NOT put capitalised words into the preferences list so then a prefs toggle becomes unnecessary...
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Case protection in BibTeX export format

Post by Jon »

When I tick the checkbox for "Bracket "don't change case" words in title, {Paris}", and if I then close the Preferences and reopen, the tickbox is unchecked again.
Sorry about that. The setting was actually saved but the preferences UI wasn't being set properly. Please download 14.0.8 again, this has been fixed in a silent update.

Jon
Sonny Software
Post Reply