Implementation of "Title Case" in Bibtex
As far as I am aware, there is no BibTeX (nor any biblatex
) style that implements a "convert to title case" macro/function (there was a question a while back on how to achieve this with biblatex
, the answer shows a way to get started with such a macro in biblatex
with Biber).
There is, however, a function to turn titles into sentence case (uppercase first letter of the first word, rest lowercased). It depends on the style whether or not this function is used. If your style applies sentence casing you will probably find a line like this in the .bst
file title "t" change.case$
.
So the rules is to give the titles in Title Case in the .bib
file and have the bibliography style convert them to Sentence case if desired (cf. What is the proper casing to use when storing titles in the bibliography database?).
Generally then, titles in .bib
files should always be given in title case, where additionally words that always have to be capitalised in a certain way (names, acronyms, formulae etc.) are enclosed in curly braces {}
.
Example
title = {From {Brouwer} to {Hilbert}: {The} Debate on the Foundations of Mathematics in the 1920s}
title = {{NASA} Ends Unmanned Launchings in {Florida}}
See also BibTeX loses capitals when creating .bbl file, especially Alexis' answer.
The change.case$
built-in function is described in the source (texk/bibtex-x/bibtex-4.c
in TeX Live):
* The |built_in| function change.case$ pops the top two (string)
* literals; it changes the case of the second according to the
* specifications of the first, as follows. (Note: The word `letters' in
* the next sentence refers only to those at brace-level~0, the top-most
* brace level; no other characters are changed, except perhaps for
* special characters, described shortly.) If the first literal is the
* string t, it converts to lower case all letters except the very
* first character in the string, which it leaves alone, and except the
* first character following any |colon| and then nonnull |white_space|,
* which it also leaves alone; if it's the string l, it converts all
* letters to lower case; if it's the string u, it converts all
* letters to upper case; and if it's anything else, it complains and
* does no conversion. It then pushes this resulting string. If either
* type is incorrect, it complains and pushes the null string; however,
* if both types are correct but the specification string (i.e., the
* first string) isn't one of the legal ones, it merely pushes the second
* back onto the stack, after complaining. (Another note: It ignores
* case differences in the specification string; for example, the strings
* t and T are equivalent for the purposes of this |built_in|
* function.)
That's complex and I didn't understand most of it, but in practice, I think that what needs to be remembered is that even after punctuation characters like ".", "!" or "?", the letters are converted to lower case by default... except after ":" (colon). Indeed,
title = {Test! Test? Test: Test. Test, Test}
in a .bib file yields:
\newblock Test! test? test: Test. test, test.
This only exception is rather strange and unexpected.
This can be done in the following way, if you are willing to create a custom .bst file. In your document, you need the following lines:
\usepackage{titlecaps}
\Addlcwords{the of into}
where the \usepackage
makes use of the titlecaps
package which has the \titlecap
macro. The \Addlcwords
macro provides a list of words that should remain lower case and not be capitalized.
In your .bst
file, you need to add a new macro:
FUNCTION {titlecap}
{ duplicate$ empty$
{ pop$ "" }
{ "\titlecap{" swap$ * "}" * }
if$
}
The only thing left to do is to use it for the various document styles that you are formatting. For example, a line in your style might have said something like this:
title ". " * output
which prints the title, concatenates a period and outputs the result. Now, you would edit that to say:
title titlecap ". " * output
which will first apply the titlecap
macro to title
, before concatenating the period and outputting the result. the invocation of \titlecap
in the macro will capitalize the first letter of each word, except those in the exclusion list. See package documentation at http://ctan.org/pkg/titlecaps.