retorquere / zotero-better-bibtex

Make Zotero effective for us LaTeX holdouts
https://retorque.re/zotero-better-bibtex/
MIT License
5.24k stars 288 forks source link

Exported fields should have the same capitalization as in Zotero #1144

Closed gilbertohasnofb closed 5 years ago

gilbertohasnofb commented 5 years ago

Exported fields should have the same capitalization as in Zotero. When the first word in the title field is written in lower case letters only, BBT capitalizes it during the exportation. However, if any letter other than the first one is capitalized, BBT keeps the same capitalization as in Zotero.

Here are two concrete examples to illustrate this: if a title of a source is called foobar, BBT will wrongly export it as Foobar. On the other hand if the title of a source is called fooBar, BBT will correctly export it as fooBar.

I would suggest that the exported bib file should always keep the same capitalization of all fields as the user input in Zotero; this minimizes the chance of cryptic issues such as this and leaves it up to the user to ensure that his database is clean and consistent.

retorquere commented 5 years ago

Can you right-click that reference and send a BBT error report?

gilbertohasnofb commented 5 years ago

Sure. Report ID: MGSM9TXZ-euc. Let me know if I can help with anything else.

retorquere commented 5 years ago

BTW BBT does not keep the same capitalization of all fields as the user input in Zotero, and this is by design -- Zotero requires the fields in Sentence case, but BibLaTeX requires fields to be in Title Case. Going from sentence case to title case is an imperfect process so there could well be errors in the implementation (using Zotero's title caser BTW), but in the general case it is false that BBT ought to export the fields as-is without recapitalization. TBH the choice of biblatex for Title Case is unfortunate if you ask me, but that's not going to change.

gilbertohasnofb commented 5 years ago

@retorquere I see, I was not aware of these particularities of biblatex. So this possibly mean that any lowercase word in a title will also be converted to sentence case, e.g. 'Studying foobar: A Computer Library' will likely become 'Studying Foobar: A Computer Library'. If that's the case then this issue will likely not only affect the first word of a title but actually any lowercase word.

retorquere commented 5 years ago

I've imported that reference and had Zotero generate a bibliography for it, and using right-click-generate-bibliography that comes out as

Agostinho, Gilberto 2018 LilypondLibrary: A Library of Fortran Subroutines for Outputting Lilypond Code. Fortran. https://github.com/gilbertohasnofb/lilypondLibrary, accessed April 23, 2018.

So Zotero capitalized that word too. BBT aims to output bibtex code that renders to what Zotero would when it renders its own bibliography, with the idea that the transformation from what's in Zotero to its bibliographies best captures user intent. You can prevent Zotero from recapitalizing the first word by adding the title in Zotero as

<span class="nocase">lilypondLibrary</span>: A Library of Fortran Subroutines for Outputting Lilypond
Code

which makes it come out in Zotero as

Agostinho, Gilberto 2018 lilypondLibrary: A Library of Fortran Subroutines for Outputting Lilypond Code. Fortran. https://github.com/gilbertohasnofb/lilypondLibrary, accessed April 23, 2018.

BBT understands nocase and will not change the case of the word on export.

gilbertohasnofb commented 5 years ago

@retorquere Thank you so much for the explanations; I do see how this is not as trivial a issue as I first thought, I was not aware of the automatic capitalization by Zotero and biblatex. Surrounding words with <span class="nocase">foobar</span> does the trick, I just tested with a couple of references. It does have the downside of making my Zotero database a bit uglier and difficult to read, but the output is perfect and that matters the most. Thanks once again.

retorquere commented 5 years ago

@retorquere I see, I was not aware of these particularities of biblatex. So this possibly mean that any lowercase word in a title will also be converted to sentence case, e.g. 'Studying foobar: A Computer Library' will likely become 'Studying Foobar: A Computer Library'. If that's the case then this issue will likely not only affect the first word of a title but actually any lowercase word.

It doesn't, only lowercased words at the start of sentences (because that's how Zotero behaves).

It does have the downside of making my Zotero database a bit uglier and difficult to read

I fully agree and would love to see a prettier way to display this in Zotero, but that's out of my hands.

gilbertohasnofb commented 5 years ago

It doesn't, only lowercased words at the start of sentences (because that's how Zotero behaves).

Hmm, are you sure about that? I just tested this and it seems that lowercase words in the middle of a title do get automatic capitalization too. For instance, I renamed a book in my library to Algorithmic composition: Paradigms of Automated Music Generation and it came out as Algorithmic Composition: Paradigms of Automated Music Generation in the exported bib file.

I fully agree and would love to see a prettier way to display this in Zotero, but that's out of my hands.

Absolutely. And I do greatly appreciate you explaining this workaround to me.

retorquere commented 5 years ago

Yeah sorry, I was thinking about brace-protection. You're right, most words are capitalized, because that's how bib(la)tex expects them, whereas in Zotero you're expected to have them in sentence case.

gilbertohasnofb commented 5 years ago

Great, so basically the solution to this is to add the "nocase" span to every word that must be left untouched by autocapitalization, regardless of the position. Thanks once again, and I believe we can close this issue.

retorquere commented 5 years ago

That's the general rule in Zotero.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.