I'm having a formatting issue with my document's table of contents (ToC).
Specifically, I'm trying to capitalize the first letter of each word in the ToC entries using the \capitalisewords
command from the mfirstuc
package. I'm also using the \titlecontents
command from the titleps
package to format my ToC.
However, \capitalisewords
does not seem to work as expected. The ToC entries remain unchanged.
Interestingly, other case-changing commands like \MakeUppercase
work perfectly.
Here's a minimal working example (MWE) that demonstrates the issue:
\documentclass{report}
\usepackage{lipsum, mfirstuc, titletoc}
\usepackage[colorlinks = true]{hyperref}
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\addvspace{.5em}}% <above-code>
{\thecontentslabel\quad\capitalisewords}% <numbered-entry-format>
{\capitalisewords}% <numberless-entry-format>
{\bfseries\hfill\contentspage}% <filler-page-format>
[]%
\titlecontents{section}[3.8em]{}{\contentslabel{2.3em}\capitalisewords}{\hspace*{-2.3em}\capitalisewords}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}[7em]{}{\contentslabel{3.2em}\capitalisewords}{\hspace*{-3.2em}\capitalisewords}{\titlerule*[1pc]{.}\contentspage}
\begin{document}
\tableofcontents
\chapter*{starred chapter title}
\addcontentsline{toc}{chapter}{starred chapter title}
\lipsum[1]
\chapter{chapter title}
\lipsum[2]
\section{section title}
\lipsum[3]
\subsection{subsection title}
\lipsum[3-18]
\end{document}
Here is the resulting ToC: