[Tex/LaTex] Adjust TOC title font, size and weight using tocloft

table of contentstocloft

I would like to use the tocloft package to make some adjustments to my TOC. This MWE is based on the accepted answer to this question.

\documentclass [a4paper,11pt,twoside]{book}

\usepackage{fontspec} 
%\usepackage{titlesec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Book Antiqua}  
\setsansfont{Liberation Sans} %!Change to any font that you have on your system

\usepackage[dutch,english]{babel}

\usepackage{tocloft}

\renewcommand{\cftbeforechapskip}{\baselineskip}      % allow spacing after each chapter/section entry
\renewcommand{\contentsname}{Contents}
%\addto\captionsenglish{\def\contentsname{Contents}} %! Needed for babel? https://tex.stackexchange.com/questions/35903/formatting-the-title-of-the-toc
\renewcommand{\cftaftertoctitle}{\hfill}
%\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries} %!some command to make the heading large, bold and sans
\renewcommand{\cftbeforetoctitleskip}{-0.25in}        % Title is 1in from top
\renewcommand{\cftaftertoctitleskip}{2.0\baselineskip}% 1 double space after title
\renewcommand{\cfttoctitlefont}{\hfill}               % Blank space before title
\renewcommand{\cftaftertoctitle}{\hfill}              % Blank space after title
\renewcommand{\cftchapfont}{}                         % Can make it bold faced here; don't put a space in the {}
\renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchapdotsep}{\cftdotsep}             % Puts dots after chapter entries
\renewcommand{\cftchappresnum}{Chapter\ }             %
\renewcommand{\cftchapaftersnum}{}                    % Don't put a space in the {}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}%
\renewcommand{\cftchappagefont}{}                      %
\renewcommand{\cftchapnumwidth}{1in}

\setcounter{tocdepth}{0}

\begin{document}

\frontmatter
\tableofcontents

\mainmatter
\chapter{A really long chapter heading that will wrap around in the table of contents and end up inline with the chapter name}
\section{First section}

\chapter{Another chapter}
\end{document}

From the documentation, I would have thought that \renewcommand{\cftaftertoctitle}{\hfill} would have set the title to bold and large.
What am I getting wrong here?

Also, I would like to make sure that the title font and entry fonts are set to my sans font. Is there something more I have to do for that? Maybe \renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries\sffamily}?

Best Answer

The original code has

\renewcommand{\cftaftertoctitle}{\hfill}
%\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries} %!some command to make the heading huge and bold
\renewcommand{\cftbeforetoctitleskip}{-0.25in}        % Title is 1in from top
\renewcommand{\cftaftertoctitleskip}{2.0\baselineskip}% 1 double space after title
\renewcommand{\cfttoctitlefont}{\hfill}               % Blank space before title
\renewcommand{\cftaftertoctitle}{\hfill}              % Blank space after title
\renewcommand{\cftchapfont}{} 

So any font change for the title or the chapter toc entries is not used. Setting them to \hfill\Large\bfseries\sffamily etc. will change to large, bold sans serif entries, given that the font supports those settings.

Similar modifications must be applied to \cftsecfont etc, if desired.

\documentclass [a4paper,11pt,twoside]{book}



\usepackage{fontspec} 
\usepackage{titlesec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Book Antiqua}  
\setsansfont{Liberation Sans} %Change to any font that you have on your system

\usepackage[dutch,english]{babel}


\usepackage{tocloft}

\renewcommand{\cftbeforechapskip}{\baselineskip}      % allow spacing after each chapter/section entry
\renewcommand{\contentsname}{Contents}
\addto\captionsenglish{\def\contentsname{Contents}} %! Needed for babel? https://tex.stackexchange.com/questions/35903/formatting-the-title-of-the-toc
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries\sffamily} %!some command to make the heading huge and bold
\renewcommand{\cftbeforetoctitleskip}{-0.25in}        % Title is 1in from top
\renewcommand{\cftaftertoctitleskip}{2.0\baselineskip}% 1 double space after title
\renewcommand{\cftchapfont}{\large\bfseries\sffamily}                         % Can make it bold faced here; don't put a space in the {}
\renewcommand{\cftchappagefont}{\large\bfseries\sffamily}                         % Can make it bold faced here; don't put a space in the {}
\renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchapdotsep}{\cftdotsep}             % Puts dots after chapter entries
\renewcommand{\cftchappresnum}{Chapter\ }             %
\renewcommand{\cftchapaftersnum}{}                    % Don't put a space in the {}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}%
\renewcommand{\cftchappagefont}{}                      %
\renewcommand{\cftchapnumwidth}{1in}

\setcounter{tocdepth}{0}


\begin{document}



\frontmatter
\tableofcontents

\mainmatter
\chapter{A really long chapter heading that will wrap around in the table of contents and end up inline with the chapter name}
\section{First section}

\chapter{Another chapter}
\end{document}

enter image description here