0

I am editing a document on Overleaf: https://www.overleaf.com/read/dfmmpdxfnpzd

Unfortunately, for some reason the chapter numbers are not shown in the table of contents. I went through all forums I could find, and each and every question (also here) revolves around removing numbers, which is obviously not helping.

I managed to make the word "Chapter" appear before the chapter name, but I can't figure out how to get the number. I am pretty sure, that the key to the problem is in line 41 in the options.sty file:

\renewcommand{\numberline}[1]{Chapter \thechapter }

I think \thechapter is just the current chapter, which is 0 at the beginning, which is why I get a 0. What command should I use instead, so that it know what chapter the line refers to?

Thanks for any helpful ideas!

PS: This is the second book, so the chapters should start at 27, but I think I already solved this problem.

EDIT:

Here is the problem in a nutshell:

\documentclass[12pt,openany]{book}

% Contents page
\usepackage[titles]{tocloft}
\renewcommand{\cftchapfont}{\itshape}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\numberline}[1]{Chapter \thechapter }

% chapter headings
\renewcommand\thechapter{\arabic{chapter}}
\usepackage[center,sc]{titlesec}

% headers/footers
\usepackage{fancyhdr}

\begin{document}
\frontmatter
%\input{frontmatter/titlepage}
\tableofcontents

\mainmatter
\pagestyle{fancy}
\setcounter{chapter}{26}
\chapter{Cast Adrift} Blablablabla

\end{document}

What I see in the table of contents is:

enter image description here

What I would like to see is "Chapter 27: Cast Adrift 1"

2
  • I won't go to an external site to debug your code. Such links will be invalid in short time and make your question useless for other users. Provide a small but complete example that demonstrates your problem here. Feb 27, 2021 at 8:57
  • Sorry, I thought it was more practical this way. I added a very short example. Feb 27, 2021 at 11:25

1 Answer 1

3

The argument of numberline contains the number:

\documentclass[12pt,openany]{book}

% Contents page
\usepackage[titles]{tocloft}
\renewcommand{\cftchapfont}{\itshape}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\numberline}[1]{Chapter #1 }

% chapter headings
\renewcommand\thechapter{\arabic{chapter}}
\usepackage[center,sc]{titlesec}

% headers/footers
\usepackage{fancyhdr}

\begin{document}
\frontmatter
%\input{frontmatter/titlepage}
\tableofcontents

\mainmatter
\pagestyle{fancy}
\setcounter{chapter}{26}
\chapter{Cast Adrift} Blablablabla

\end{document}

enter image description here

2
  • ...and after #1 add a colon to get "Chapter 27: Cast Adrift 1" as asked for.
    – Stephen
    Feb 27, 2021 at 11:36
  • I can't believe how easy that was, thanks a lot! I wasted at least 3 hours on two characters :D Feb 27, 2021 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .