[Tex/LaTex] Sentence case for titles in biblatex

biblatexcapitalization

I'd like to have the titles of articles in Biblatex in sentence case (first word capitialized, the rest lowercase, override with {}) as is the default in Bibtex.

I tried:

\DeclareFieldFormat{titlecase}{\MakeSentenceCase{#1}}

However it also makes converts other fields into sentence case, such as the booktile:

[Pai99] P Paillier. “ Public-key cryptosystems based on composite degree residuosity classes”. Eurocrypt. 1999 

I'd like:

[Pai99] P Paillier. “ Public-key cryptosystems based on composite degree residuosity classes”. EUROCRYPT. 1999

(This assumes that booktitle is EUROCRYPT in the .bib file)

Is there anyway to do this, short of adding {} to each booktitle entry?

Best Answer

The format definition

\DeclareFieldFormat{titlecase}{\MakeSentenceCase{#1}}

makes all titles in sentence case, which isn't what you want. Titles need to be printed according to both the entry and field types. For example, with the title field we need to handle @article and @book entries differently. With @inproceedings entries we need to handle the title and booktitle fields differently.

To do this we can redefine the title bibmacro to print the title field of @article and any @in* entry type in sentence case. Taking the original definition found in biblatex.def:

\DeclareFieldFormat{sentencecase}{\MakeSentenceCase{#1}}

\renewbibmacro*{title}{%
  \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}
    {}
    {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{inbook}%
      \OR\ifentrytype{incollection}\OR\ifentrytype{inproceedings}%
      \OR\ifentrytype{inreference}}
      {\printtext[title]{%
        \printfield[sentencecase]{title}%
        \setunit{\subtitlepunct}%
        \printfield[sentencecase]{subtitle}}}%
      {\printtext[title]{%
        \printfield[titlecase]{title}%
        \setunit{\subtitlepunct}%
        \printfield[titlecase]{subtitle}}}%
     \newunit}%
  \printfield{titleaddon}}

Alternatively we can identify book-like entries directly and apply sentence casing to everything else. This is trickier because many more types qualify as book-like references and titles for these sources are printed by more than just one macro. In biblatex.def these include: title, booktitle, maintitle, journal, periodical and issue. To avoid redefining all of these, you can redefine the titlecase format instead.

\DeclareFieldFormat{titlecase}{\MakeTitleCase{#1}}

\newrobustcmd{\MakeTitleCase}[1]{%
  \ifthenelse{\ifcurrentfield{booktitle}\OR\ifcurrentfield{booksubtitle}%
    \OR\ifcurrentfield{maintitle}\OR\ifcurrentfield{mainsubtitle}%
    \OR\ifcurrentfield{journaltitle}\OR\ifcurrentfield{journalsubtitle}%
    \OR\ifcurrentfield{issuetitle}\OR\ifcurrentfield{issuesubtitle}%
    \OR\ifentrytype{book}\OR\ifentrytype{mvbook}\OR\ifentrytype{bookinbook}%
    \OR\ifentrytype{booklet}\OR\ifentrytype{suppbook}%
    \OR\ifentrytype{collection}\OR\ifentrytype{mvcollection}%
    \OR\ifentrytype{suppcollection}\OR\ifentrytype{manual}%
    \OR\ifentrytype{periodical}\OR\ifentrytype{suppperiodical}%
    \OR\ifentrytype{proceedings}\OR\ifentrytype{mvproceedings}%
    \OR\ifentrytype{reference}\OR\ifentrytype{mvreference}%
    \OR\ifentrytype{report}\OR\ifentrytype{thesis}}
    {#1}
    {\MakeSentenceCase{#1}}}

edit by @moewe: Note that the biblatex documentation recommends to use the starred form \MakeSentenceCase* instead of \MakeSentenceCase. The starred macro considers the language of the entry (as given in the langid field, or failing that assuming the current language) and only applies sentence case where it is appropriate (by default only for English-language publications).