BibTeX, biblatex and biberCapitalize first letter of each title sentence?

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
Matifou
Posts: 23
Joined: Fri Jan 14, 2011 11:27 am

Capitalize first letter of each title sentence?

Post by Matifou »

Hi

Bibtex by default will "de-capitalize" article titles, keeping only the first letter of whole title. This make sense, but if I have a two sentences title, I get something like:
BibTeX guide. the difficulty of getting capitals
Sure I could add in each citation a {} for first letter of second sentence but.. is there not something more automatic?

Thanks!!
Last edited by Matifou on Wed Feb 02, 2011 3:16 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Capitalize first letter of each title sentence?

Post by frabjous »

I doubt there's a way to handle this internal to BibTeX or LaTeX, and it's dependent upon the bst file anyway, but if you're using a halfway decent editor, you should be able to add the braces to the bib file with a single RegEx Find and Replace. If your editor doesn't support RegEx, it's time to get a different editor.
Matifou
Posts: 23
Joined: Fri Jan 14, 2011 11:27 am

Re: Capitalize first letter of each title sentence?

Post by Matifou »

well it is this change.case function actually (so not really .bst dependent I think), so yes indeed very difficult to change...

Regexp is a good idea, I have the editor but not the brain! :-) Any small hint I could work on? I guess rule should specify check only title line, replace letter by {letter} directly after first point, right?

Thanks!!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Capitalize first letter of each title sentence?

Post by frabjous »

Well, you didn't tell me what editor you're using and what specific version of RegEx it uses. For more simple RegEx system, I would search for:

Code: Select all

\(title\s*=\s*{[^}\.]*\.\s*\)\([A-Z]\)
And replace with:

Code: Select all

\1{\2}
So in Vim for example, the command would be:

Code: Select all

:%s/\(title\s*=\s*{[^}\.]*\.\s*\)\([A-Z]\)/\1{\2}/  
I think the same could be used with sed from the commandline on Unix-type systems (or, I guess, with sed for Windows):

Code: Select all

sed 's/\(title\s*=\s*{[^}\.]*\.\s*\)\([A-Z]\)/\1{\2}/' input.bib > output.bib
But if your editor uses perl-compatible or extended Regular Expressions instead, I think this would need to be changed... to search for:

Code: Select all

(title\s*=\s*\{[^\}\.]*\.\s*)([A-Z]) 
and replace with:

Code: Select all

\1\{\2\}
So you could use:

Code: Select all

perl -pe 's/(title\s*=\s*\{[^\}\.]*\.\s*)([A-Z])/\1\{\2\}/' input.bib > output.bib
From the command line.

All of the above assumes your entries look like:

Code: Select all

title = {Something. Something},
And not:

Code: Select all

title = "Something. Something",
or

Code: Select all

title = {Something.
         Something}
And that TITLE is not in all caps, etc., so it would really help to know what program you're using, exactly how it is formatted now, etc.

And FWIW, the change case function you mentioned is something built in to the .bst file. Not all .bst affect the case of titles.
Matifou
Posts: 23
Joined: Fri Jan 14, 2011 11:27 am

Re: Capitalize first letter of each title sentence?

Post by Matifou »

Dear Frabjous

Thanks so much for providing these more than detailed explanations! Very kind of you! I will go through them but consider definitely the topic as resolved!

Thanks again!
Post Reply