hayagriva icon indicating copy to clipboard operation
hayagriva copied to clipboard

Automatic capitalization of titles in bibliography

Open ntrocado opened this issue 8 months ago • 6 comments

Description

As far as I can tell, Typst formats the titles of references in the bibliography following the capitalization in the .bib file, irrespective of citation styles that mandate sentence case, like APA.

For example:

@book{smith2023,
  author = {John A. Smith},
  title = {This is an Incredible Book},
  year = {2023},
}
A citation @smith2023.

#bibliography("refs.bib", style: "american-psychological-association")

will produce "This is an Incredible Book". But, according to the APA style, it should be printed "This is an incredible book" in lowercase except the first letter.

Latex does this right, and capitalizes according to the citation style, except where expressly indicated by {...} curly braces in the .bib file.

Use Case

It's useful to maintain a .bib file of references that is agnostic in relation to citation styles. The same references can then be used in different documents following different citation styles.

I have a .bib file with thousands of entries, and I'd rather not have to change them every time I have to use APA or Chicago, for example.

ntrocado avatar Jul 01 '25 12:07 ntrocado

This belongs in the Hayagriva repository.

(I can't move it myself)

Enivex avatar Jul 01 '25 12:07 Enivex

Looking further into this, apparently if titles are stored in sentence case and the citation style mandates for title case it actually works. The problem is just for the other way around (titles in title case in the .bib, and you're using APA).

With latex/bibtex this doesn't occur maybe because bibtex might be sentence casing everything on a first pass.

In any case, having to store all entries in sentence case is inconvenient but doable (with some smart regex)...

ntrocado avatar Jul 01 '25 13:07 ntrocado

I've just noticed this related issue: https://github.com/typst/hayagriva/issues/93

Still, it would be nice to have automated case conversion for styles like APA. I don't know in what level (csl?) this could be accomplished...

ntrocado avatar Jul 01 '25 13:07 ntrocado

The APA style does not specify sentence case. This is not a hayagriva bug. Just use a custom version, where you use sentence case for book titles.

Drodt avatar Jul 02 '25 08:07 Drodt

The APA style does not specify sentence case.

I don't think that's correct. From the APA website:

When to use sentence case

Use sentence case for the following:

titles of articles, books, reports, webpages, and other works in reference list entries, even if title case was used in the original work

ntrocado avatar Jul 02 '25 10:07 ntrocado

Sorry, I was unclear: The APA CSL file does not use sentence case for titles. You should fix that if you want it

Drodt avatar Jul 02 '25 13:07 Drodt