1

I am facing a specific requirement for the format of the table of contents.

I am using the book class. Rather than 1 Introduction # in the table of contents, the requirement is Chapter 1: Introduction # (in which # is the page number).

In the text, rather than Chapter 1 (new line) Introduction the requirement is Chapter 1: Introduction.

What is the simplest way to achieve this?

\documentclass{book}
\usepackage{blindtext}
\begin{document}
\frontmatter
\tableofcontents

\mainmatter \chapter{Introduction}

\section{My subsection title} \blindtext[1]

\end{document}

Henk
  • 175

3 Answers3

2

Since you are using book class the following will do the trick:

\documentclass{book}
\usepackage{titlesec}% <-- to change chapter, section,... style
\usepackage[titles]{tocloft}% <-- changes to ToC
\usepackage{blindtext}

%rename \thechapter to easy display in ToC \renewcommand{\cftchappresnum}{Chapter } %punctuation for chapters in ToC \renewcommand{\cftchapaftersnum}{:} %Indentation for chapters in ToC %separation between the colon and "Introduction" is given in the second argument. The indentation for the whole line is given in the first argument \cftsetindents{chapter}{0ex}{13.5ex}

%Definition of the new chapter style \titleformat{\chapter}[hang]{\huge}{Chapter \thechapter :}{1ex}{}

%not sure if sections, subsections, etc. need an specific format %this for example will change the output of sections %\titleformat% %{\section} %<-- command, this will modify section %[hang] %<-- shape, for section it would be hang too %{\Large\bfseries} %<-- format %{\thesection} %<-- label, the number before the actual section name %{1ex} %<-- horizontal separation between label and title %{} %<-- code preceding the title body %[after code] %<-- code following the title body

\begin{document} \frontmatter \tableofcontents

\mainmatter \chapter{Introduction}

\section{My subsection title} \blindtext[1]

\end{document}

to obtain a better indentation for long chapter titles you can see this question

Luis Turcio
  • 2,757
1

This version does not use additional packages.

\documentclass{book}
\usepackage{blindtext}

\makeatletter \renewcommand*\l@chapter[2]{% \ifnum \c@tocdepth >\m@ne \addpenalty{-@highpenalty}% \vskip 1.0em @plus\p@ \setlength@tempdima{1.5em}% \begingroup \def\numberline##1{\hb@xt@@tempdima{@chapapp~##1:\hfil}}% \advance@tempdima by 4.5em \parindent \z@ \rightskip @pnumwidth \parfillskip -@pnumwidth \leavevmode \bfseries \advance\leftskip@tempdima \hskip -\leftskip #1\nobreak\hfil \nobreak\hb@xt@@pnumwidth{\hss #2% \kern-\p@\kern\p@}\par \penalty@highpenalty \endgroup \fi}

\def@makechapterhead#1{% \vspace*{50\p@}% {\parindent \z@ \raggedright \normalfont \ifnum \c@secnumdepth >\m@ne \interlinepenalty@M \if@mainmatter \Huge\bfseries @chapapp\space \thechapter: #1\par\nobreak \par\nobreak \vskip 20\p@ \else \Huge \bfseries #1\par\nobreak \fi \fi \vskip 40\p@ }} \makeatother

\begin{document} \frontmatter \tableofcontents

\chapter{Abstract}

\mainmatter \chapter{Introduction}

\blindtext[1]

\chapter{A very very very very very very very very very long title}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
1

Use the memoir class (a superset of the book and report classes).

% chaptocstyleprob.tex  SE 567907

\documentclass{memoir} \usepackage{blindtext}

%% styling the chapter titles \makechapterstyle{yourstyle}{% \renewcommand{\afterchapternum}{: } }

%% styling the chapter ToC entries \setlength{\cftchapternumwidth}{1.8em} \renewcommand{\cftchaptername}{Chapter\space} \renewcommand{\cftchapteraftersnum}{:}

\begin{document} \chapterstyle{yourstyle} %% use your chapter style \frontmatter \tableofcontents
%% or \tableofcontents* if you don't want the ToC listed in the ToC

\mainmatter \chapter{Introduction}

\blindtext[1]

\setcounter{chapter}{11}

\chapter{Another chapter}

\end{document}

The memoir class provides many methods for changing the appearance of a document. Read the manual (> texdoc memoir) for more information.

Peter Wilson
  • 28,066
  • Thanks Peter. I am using the book class, and have written a thesis in it. Switching to memoir now will be quite involved, I think. – Henk Oct 22 '20 at 17:53