[Tex/LaTex] Remove bold style for chapter names in table of contents

chapterstable of contentstocloft

Problem:

I wish to have bold style for certain chapter names but not for others.

Minimal Working Example:

\documentclass{book}

\usepackage[titles]{tocloft}

%: ----------------------- Table of contents ------------------------
\renewcommand{\contentsname}{Table of contents}
\renewcommand{\cftchapfont}{\normalfont\bfseries}% titles in bold
\renewcommand{\cftchappagefont}{\normalfont\bfseries}% page numbers in bold
\renewcommand{\cftdotsep}{1}
\renewcommand{\cftchapleader}{\bfseries\cftdotfill{\cftsecdotsep}}% dot leaders in bold

\begin{document}

\tableofcontents
\chapter{Test Chapter One}
\section{Test Section One}
\section{Test Section One}
\subsection{Test Subsection A}
\subsection{Test Subsection B}

\pagenumbering{Roman}
\setcounter{page}{1}
\addcontentsline{toc}{chapter}{Test Chapter Two}

\end{document}

Output:

enter image description here

Desired output:

To get the second chapter name in the table of contents in normal style.

Best Answer

Another way: Writing the change of the \cftchap... etc. macros to the toc and make the font bold or just \normalfont.

I've adapted this for the page font as well as for the leaders...

The macro \enableboldchapterintoc enables this globally until \disableboldchapterintoc is used. Reenable it with another \enableboldchapterintoc etc, where needed.

\documentclass{book}

\usepackage[titles]{tocloft}


\newcommand*{\enableboldchapterintoc}{%
  \addtocontents{toc}{\string\renewcommand{\protect\cftchapfont}{\protect\normalfont\protect\bfseries}}
  \addtocontents{toc}{\string\renewcommand{\protect\cftchappagefont}{\protect\normalfont\protect\bfseries}}
  \addtocontents{toc}{\string\renewcommand{\protect\cftchapleader}{\protect\bfseries\protect\cftdotfill{\protect\cftsecdotsep}}}% dot leaders in bold
}
\newcommand*{\disableboldchapterintoc}{%
  \addtocontents{toc}{\string\renewcommand{\protect\cftchappagefont}{\protect\normalfont}}
  \addtocontents{toc}{\string\renewcommand{\protect\cftchapfont}{\protect\normalfont}}
  \addtocontents{toc}{\string\renewcommand{\protect\cftchapleader}{\protect\normalfont\protect\cftdotfill{\protect\cftsecdotsep}}}% 
}



%: ----------------------- Table of contents ------------------------
\renewcommand{\contentsname}{Table of contents}
\renewcommand{\cftchapfont}{\normalfont\bfseries\fi}% titles in bold
\renewcommand{\cftchappagefont}{\normalfont\bfseries}% page numbers in bold
\renewcommand{\cftdotsep}{1}
\renewcommand{\cftchapleader}{\bfseries\cftdotfill{\cftsecdotsep}}% dot leaders in bold


\begin{document}
\enableboldchapterintoc
\tableofcontents
\chapter{Test Chapter One}
\section{Test Section One}
\section{Test Section One}
\subsection{Test Subsection A}
\subsection{Test Subsection B}

\pagenumbering{Roman}
\setcounter{page}{1}
\disableboldchapterintoc
\addcontentsline{toc}{chapter}{Test Chapter Two}

\enableboldchapterintoc

\chapter{Foo}

\end{document}

enter image description here

Related Question