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?

  • 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
13

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}}
|improve this answer|||||
  • @Stefan Kottwitz: Also works for chapters without *, this is great! – bkarpuz Mar 25 '13 at 8:27
  • The FAQ link is broken, but the example code still works! – Mike Shulman Mar 26 '19 at 12:40
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}
|improve this answer|||||
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.

|improve this answer|||||
  • 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 3 '14 at 18:53

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.