7

I used

{\sffamily\tableofcontents}

to change the font from Times New Roman to sans serif in my table of contents. Then I used

\usepackage{tocloft}
\renewcommand\cftchapafterpnum{\vskip6pt}
\renewcommand\cftsecafterpnum{\vskip6pt}
\renewcommand\cftsubsecafterpnum{\vskip6pt}

in preamble to increase the space between ToC entries. But I found that all the entries in ToC (except chapter name) changed back to Times New Roman. How can I fix this. A MWE is given below:

\documentclass[fleqn, a4paper, 11pt, oneside]{book}
\pagestyle{plain}
\renewcommand{\rmdefault}{ptm}

\usepackage{tocloft}                  
\renewcommand\cftchapafterpnum{\vskip6pt}
\renewcommand\cftsecafterpnum{\vskip6pt}
\renewcommand\cftsubsecafterpnum{\vskip6pt}

\usepackage{newtxtext}

\begin{document}

{\sffamily\tableofcontents}

\chapter{QWERTYUIOP}              
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}              
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}              
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}              
\section{XYZXYZXYZXYZ}
\subsection{xyxyzxyzxyzxyz}

\end{document}
  • I can't replicate your problem. Can you please provide the community with a minimal working example (MWE)? – Werner Aug 14 '15 at 17:56
  • A minimal (non-)working example would help to help. – Bernard Aug 14 '15 at 17:57
  • I just added the MWE. – user48319 Aug 14 '15 at 18:17
6

When using tocloft, you have to set the fonts for each sectional component separately. There is no over-arching font setting, since each component is placed inside a box or group with their own font-specification. It allows the ultimate specificity, even though it might not suit your generic needs:

enter image description here

\documentclass{book}
\usepackage{mathptmx}

\usepackage{tocloft}
\renewcommand\cftchapafterpnum{\vskip6pt}
\renewcommand\cftsecafterpnum{\vskip6pt}
\renewcommand\cftsubsecafterpnum{\vskip6pt}

% Adjust sectional unit title fonts in ToC
\renewcommand{\cftchapfont}{\sffamily}
\renewcommand{\cftsecfont}{\sffamily}
\renewcommand{\cftsubsecfont}{\sffamily}

\usepackage{newtxtext}

\begin{document}

\tableofcontents

\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\subsection{xyxyzxyzxyzxyz}

\end{document}

Note that you'll have to set the page number fonts as well. This requires

\renewcommand{\cftchappagefont}{\sffamily}
\renewcommand{\cftsecpagefont}{\sffamily}
\renewcommand{\cftsubsecpagefont}{\sffamily}
  • The OP will probably also want to reset \cfttoctitlefont. – Mico Aug 14 '15 at 18:40
  • And \cftXpagefont for the page numbers. Also the chapter titles are no longer bold. – Heiko Oberdiek Aug 14 '15 at 18:45
5

Another solution based on titletoc, from the titlesecbundle;

\documentclass[fleqn, a4paper, 11pt, oneside]{book}
\pagestyle{plain}
\renewcommand{\rmdefault}{ptm}

\usepackage{newtxtext}
\usepackage{titletoc}

\contentsmargin[1cm]{0cm}
\titlecontents{chapter}[0em]{\vskip12pt\bfseries\sffamily}
{\thecontentslabel\enspace}
{\hspace{1.05em}}
{ \hfill\contentspage}[\vskip 6pt]

\titlecontents{section}[1em]{\sffamily}
{\thecontentslabel\enspace}
{}
{\titlerule*[1pc]{.}\quad\contentspage}[\vskip 4pt]

\titlecontents{subsection}[2.7em]{\sffamily}
{\thecontentslabel\enspace}
{}
{\titlerule*[1pc]{.}\quad\contentspage}[\vskip 3pt]

\usepackage{etoolbox}
\pretocmd{\contentsname}{\sffamily}{}{}

\begin{document}

\tableofcontents
\chapter*{INTRODUCTION}
\addcontentsline{toc}{chapter}{INTRODUCTION}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\chapter{QWERTYUIOP}
\section{XYZXYZXYZXYZ}
\subsection{xyxyzxyzxyzxyz}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy