0

I want to add the word "Chapter" before the chapter number in the TOC (keeping the code) as follows

Table of contents

Chapter 1: Chapter name

and no as

Table of contents

1 Chapter name

How do it please?

enter image description here

This is my code

\documentclass[a4paper,11pt,x11names]{book}
\usepackage[french]{babel}
\usepackage{titlesec}
\usepackage{titletoc}

\usepackage{xcolor} \definecolor{ocre}{RGB}{243,102,25}

\contentsmargin{0cm}

\titlecontents{chapter} [1.25cm] {\addvspace{12pt}\large\sffamily\bfseries} {\color{ocre!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}} {\color{ocre}} {\ \color{ocre!60}\normalsize\titlerule*[.5pc]{.};\thecontentspage}

\titlecontents{section} [2.5cm] {\addvspace{5pt}\sffamily\bfseries} {\contentslabel[\thecontentslabel]{1.25cm}} {} {\ \normalsize\titlerule*[.5pc]{.};\thecontentspage}

\titlecontents{subsection} [3.75cm] {\addvspace{1pt}\sffamily\small} {\contentslabel[\thecontentslabel]{1.25cm}} {} {\ \titlerule*[.5pc]{.};\thecontentspage}

\begin{document}

\tableofcontents

\chapter{Chapter 1}

\section{Section 1}

\subsection{Subsection 1}

\subsubsection{Subsubsection}

\end{document}

Gallagher
  • 213

2 Answers2

1

Try

\titlecontents{chapter}
[3.5cm] 
{\addvspace{12pt}\large\sffamily\bfseries } 
{ \color{ocre!60}\contentslabel[\Large Chapter\enspace\thecontentslabel]{3.6cm}\color{ocre}}
{\color{ocre}}
{\ \color{ocre!60}\normalsize\titlerule*[.5pc]{.}\;\thecontentspage}

a

Simon Dispa
  • 39,141
1

I don't use the titletoc package but instead the tocloft package. The following code provides what you ask for.

% chapintocprob.tex  SE 623588

\documentclass[a4paper,11pt,x11names]{book} \usepackage[french]{babel} \usepackage{titlesec} %\usepackage{titletoc}

\usepackage{comment} \usepackage{tocloft}

\renewcommand{\cftchappresnum}{Chapter } % put this before chapter number \addtolength{\cftchapnumwidth}{4em} % extra space for the above \renewcommand{\cftchapaftersnum}{:} % put : after chapter number \renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % use detted leader \renewcommand{\cftchapfont}{\bfseries\color{ocre}} % ocre colour for title and dots \renewcommand{\cftchappagefont}{\bfseries\color{ocre}} % ocre page numbers \renewcommand{\cftchapafterpnum}{\vspace{\baselineskip}} % extra space below chapter titles

\renewcommand{\cftsecfont}{\bfseries} % bold section titles \renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftdotsep}} % bold section leader \renewcommand{\cftsecpagefont}{\bfseries} % bold section page number

\usepackage[T1]{fontenc} % PW suggested by package french.ldf

\usepackage{xcolor} \definecolor{ocre}{RGB}{243,102,25}

\begin{comment}

\contentsmargin{0cm}

\titlecontents{chapter} [1.25cm] {\addvspace{12pt}\large\sffamily\bfseries} {\color{ocre!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}} {\color{ocre}} {\ \color{ocre!60}\normalsize\titlerule*[.5pc]{.};\thecontentspage}

\titlecontents{section} [2.5cm] {\addvspace{5pt}\sffamily\bfseries} {\contentslabel[\thecontentslabel]{1.25cm}} {} {\ \normalsize\titlerule*[.5pc]{.};\thecontentspage}

\titlecontents{subsection} [3.75cm] {\addvspace{1pt}\sffamily\small} {\contentslabel[\thecontentslabel]{1.25cm}} {} {\ \titlerule*[.5pc]{.};\thecontentspage}

\end{comment}

\begin{document}

\tableofcontents

\chapter{Chapter 1}

\section{Section 1}

\subsection{Subsection 1}

\subsubsection{Subsubsection}

\end{document}

tocloft provides controls for all aspects of the ToC (and LoF, LoT) typesetting, from before the division number, through the dotted line to the page number and afterwards. It might be tedious to use but then it gives you conplete control over the typesetting of the ToC, etc.

Peter Wilson
  • 28,066