1

I'm trying to remove a chapter in the ToC to instead replace it with a custom text. A easy way is do like this:

\chapter*{Chapter}
\addcontentsline{toc}{chapter}{Custom chapter name}

But this unfortunately removes all chapter numbers in the underlying sections and subsections.

How can I go around this?

1
  • Welcome to TeX.SX! Usually, we prefer to have a working document, not just fragments of code! In addition, it might confuse the reader to find different names of chapters in ToC and document
    – user31729
    May 22, 2016 at 15:05

2 Answers 2

2

Here's a somewhat cleaner way (in my point of view) to provide a different chapter number title:

Either manipulate the tocdepth counter temporarily or use \chapter[Other ToC Title]{Different in - body - title}.


\documentclass{book}

\usepackage{blindtext}

\begin{document}

\tableofcontents
\chapter{A regular chapter}
\blindtext[10]
\addtocontents{toc}{\protect\setcounter{tocdepth}{-5}} % Switch off toc appeareance for a moment
\chapter{In - document chapter name}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}
\addcontentsline{toc}{chapter}{Custom chapter name}
\section{Foo}
\blindtext

\chapter[And yet another chapter title in ToC]{And this is the long chapter title that shouldn't appear in ToC!}
\section{Foo bar}
\blindtext[10]


\chapter{Another regular Chapter}
\section{Foo bar bar}
\blindtext

\end{document}

enter image description here

0

Perhaps \refstepcounter{chapter} as in

\refstepcounter{chapter}%
\chapter*{Chapter}
\addcontentsline{toc}{chapter}{Custom chapter name}%

does the trick.

0

You must log in to answer this question.

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