0

I would like to capitalize the first word of the title in-text with the \citetitle macro, or at least being able to use the title of a reference with its first letter capitalized.

In the bibliographic entry, the first word of the title is lowercase so it can be cited lowercase when needed in the text. Hence I redefined titlecase with the help of \MakeSentenceCase so the bibliography entry is correctly printed in the references section. If needed, words are protected by braces (see: biblatex manual, MakeSentenceCase definition).

I tried \Citetitle without success, but I am not sure to understand what it really does.

My goal is to be able to deal with capitalization of titles in french when they start a sentence (see: J.-P. Lacroux, Orthotypographie vol. II), but I deliberately simplified the question.

MWE, to be produced with `(pdf)latex file.tex ; biber file ; (pdf)latex file.tex:

\documentclass{article}

\usepackage[english]{babel}

\begin{filecontents*}{bib.bib}
@book{
mybook,
title=  {title of the book},
author= {Author Name},
date=   {2021-04-12},
}

@article{
myarticle,
title=  {title of the article},
author= {Author Name},
date=   {2021-04-12},
}
\end{filecontents*}

\usepackage[backend=biber]{biblatex}
\addbibresource{bib.bib}

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

\begin{document}

\citetitle{mybook} ; \Citetitle{mybook}

\citetitle{myarticle} ; \Citetitle{myarticle}

\printbibliography

\end{document}

1 Answer 1

0

The titlecase field format does not apply to \citetitle. We can make it apply to citetitle with the following redefinition

\documentclass{article}
\usepackage[english]{babel}
\usepackage[backend=biber]{biblatex}

\DeclareCiteCommand{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \printtext[citetitle]{%
     \printfield[titlecase]{labeltitle}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

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

\begin{filecontents*}{\jobname.bib}
@book{mybook,
  title  = {title of the book},
  author = {Author Name},
  date   = {2021-04-12},
}
@article{myarticle,
  title  = {title of the article},
  author = {Author Name},
  date   = {2021-04-12},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\citetitle{mybook}

\Citetitle{mybook}

\citetitle{myarticle}

\Citetitle{myarticle}

\printbibliography
\end{document}

Title of the book//Title of the book//“Title of the article”//“Title of the article”


If you only want to capitalise the first word with \Citetitle things are a bit more tricky. In that case I'd recommend the following, which is based on \MakeCapital and not on \MakeSentenceCase, which means it does not alter subsequent letters and does not respond to language settings.

\documentclass{article}
\usepackage[english]{babel}
\usepackage[backend=biber]{biblatex}

\DeclareCiteCommand{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \printtext[citetitle]{%
     \printfield[ifcap]{labeltitle}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareFieldFormat{ifcap}{\ifcapital{\MakeCapital{#1}}{#1}}

\begin{filecontents*}{\jobname.bib}
@book{mybook,
  title  = {title of the book},
  author = {Author Name},
  date   = {2021-04-12},
}
@article{myarticle,
  title  = {title of the article},
  author = {Author Name},
  date   = {2021-04-12},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\citetitle{mybook}

\Citetitle{mybook}

\citetitle{myarticle}

\Citetitle{myarticle}

\printbibliography
\end{document}

title of the Book//Title of the Book//“title of the Article”//“Title of the Article”

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .