12

I'm writing a book using the amsbook class, and I've included a page for acknowledgements using \chapter*{}, thinking it wouldn't show up in the ToC.

However, it does (and for some reason it's supposed to do so, according to the amsbook manual); so the question is, how do I get rid of it from the ToC?

Werner
  • 603,163
Anto
  • 121
  • As for the reason amsbook (and other ams classes) do this: The intended use of this class is a technical volume. The prototypical use of a starred chapter in a technical volume is an executive summary. The executive summary goes in the table of contents. – David Hammen Jun 12 '11 at 16:51

3 Answers3

14

The amsmath FAQ has a solution. Here's a modification of it, in a complete example:

\documentclass{amsbook}
\DeclareRobustCommand{\gobblefour}[4]{}
\newcommand*{\SkipTocEntry}{\addtocontents{toc}{\gobblefour}}
\begin{document}
\tableofcontents
\SkipTocEntry\chapter*{Hidden chapter}
\chapter{Shown chapter}
\end{document}

Just place \SkipTocEntry before a TOC entry you would like to hide.

If you use hyperref, take one argument more:

\DeclareRobustCommand{\gobblefive}[5]{}
\newcommand*{\SkipTocEntry}{\addtocontents{toc}{\gobblefive}}
Stefan Kottwitz
  • 231,401
5

You can change the value of the tocdepth counter just before the particular sectional unit which must not show in the ToC and then restore the original value:

\documentclass{amsbook}

\begin{document}
\tableofcontents
\addtocontents{toc}{\setcounter{tocdepth}{-1}}
\chapter*{Preface}
\addtocontents{toc}{\setcounter{tocdepth}{2}}

\end{document}
Gonzalo Medina
  • 505,128
5

Renewal of \addtocontents to gobble it's arguments can also be used to remove its entry into the ToC:

\documentclass{amsbook}
\begin{document}
\tableofcontents
{\renewcommand{\addtocontents}[2]{}
\chapter*{Preface}}% Not included in ToC
\chapter*{Acknowledgements}% Included in ToC
\end{document}

Localization of the \renewcommand allows for it to work only within the group.

Werner
  • 603,163
  • I like this solution, but unfortunately, it doesn't seem to work correctly for subsections (using amsart): it prevents the subsection name from printing at all, not just in ToC. For sections it works fine. I'm using hyperref if it at all matters. – tomasz Jun 03 '14 at 18:53