[Tex/LaTex] How to edit the table of contents

table of contents

I have:

\documentclass[12pt]{book}

\begin{document}
\tableofcontents

\chapter{chapter name}
\section{section name}
\subsection{subsection name}
\end{document}

I get
enter image description here

I want to add the word 'Chapter' before the number 1 where it is written chapter name.
I want also to add a point line in front of the chapter name like in the section line.

I try to use this:

\documentclass[12pt]{book}

\usepackage[utf8]{inputenc}
\usepackage{newtxtext}
\usepackage[english]{babel}
\usepackage{titletoc}

\addto\captionsenglish{\renewcommand*\contentsname{Contents}}

\titlecontents{chapter}[5.3em]
{\vspace{0.3cm}}
{\contentslabel[\textbf{\chaptername~\thecontentslabel}]{5.3em}}
{\hspace*{-5.3em}}
{\titlerule{1pc}{.}\contentspage}[\smallskip]

\titlecontents{section}[5.3em]
{\smallskip}
{\thecontentslabel\enspace}
{\hspace*{-5.3em}}
{\hfill\contentspage}

\titlecontents{subsection}[6.92em]
{\smallskip}
{\thecontentslabel\enspace}
{\hspace*{-6.92em}}
{\hfill\contentspage}

    \begin{document}

    \tableofcontents
    \newpage

    \chapter*{Preface}
    \addcontentsline{toc}{chapter}{Preface}
    \chapter{Looking-Glass House}
\section{A First section}
\section{Another section}
\subsection{A subsection}
    \end{document}

But I have this:
enter image description here

I have problem with the dotted line and I want that tha chapter nae be bold !

Best Answer

Here is how to do it with titletoc. Note you'll have to redo the formatting of lower level sectioning titles (mainly the horizontal spacing) to make the layout consistent. The lengths may have to be adjusted depending on the document font, the font size, &c.

    \documentclass[12pt]{book}
    \usepackage[utf8]{inputenc}
    \usepackage{fourier, erewhon, cabin}
    %\usepackage{newtxtext}
    \usepackage[english]{babel}
    \usepackage[showframe]{geometry}
    \usepackage{titletoc}
    \usepackage{lipsum} \addto\captionsenglish{ \renewcommand*\contentsname{\centerline{Table of contents}}}

    \titlecontents{chapter}
    [5.5em] %5.3
    {\bigskip}
    {\contentslabel[\bfseries\textsc{\chaptername}~\thecontentslabel]{5.5em}\textbf}%\thecontentslabel
    {\hspace*{-5.5em}\textbf}% unnumbered chapters
    {\titlerule*[1pc]{.}\contentspage}[\smallskip]%
%
 \titlecontents{section}
 [5.5em] % i
 {\smallskip}
 {\thecontentslabel\enspace}%\thecontentslabel
 {\hspace*{-5.5em}}
 {\titlerule*[1pc]{.}\contentspage}%]

 \titlecontents{subsection}
 [7.12em] %
 {\smallskip}
 {\thecontentslabel\enspace}%\thecontentslabel
 {\hspace*{7.12em}}
 {\titlerule*[1pc]{.}\contentspage}

    \begin{document}

    \tableofcontents
    \newpage

    \chapter*{Preface}
    \addcontentsline{toc}{chapter}{Preface}
    \chapter{Looking-Glass House}
\section{A First section}
\section{Another section}
\subsection{A subsection}
    \lipsum[1]
    \chapter{The Garden of Live Flowers}
    \lipsum[2-5]
    \chapter{Looking-Glass Insects}
    \lipsum[6]
    \chapter{Tweedledum and Tweedledee}

    \end{document} 

enter image description here

Related Question