1

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 !

1

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

  • How can I delete page framing? – S_25 Jun 24 '17 at 19:28
  • Remove the [showframe] option of geometry. It was there only to check the alignment at the left margin. – Bernard Jun 24 '17 at 19:37
  • okay. Is it possible to add the points in the rest of the line and to put the font of the contents like the font of the book (Times) ? – S_25 Jun 24 '17 at 19:56
  • I want to remove also the subsections please. Thank you very much – S_25 Jun 24 '17 at 19:57
  • Do you mean adding the dotted line for chapters? As for the font, it's only because I started from an old template. Replace \usepackage{fourier, erewhon,cabin} with \usepackage{times}. However, note times` is obsolete, as it doesn't change the maths fonts. Unless you have absolutely no maths to write, it's better to load newtxtext and newtxmath, based on TeX Gyre Termes, a Times-clone. – Bernard Jun 24 '17 at 20:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.