6

I want to suppress the page numbers of chapters in the TOC of my document. A wme:

\documentclass{amsbook}

\begin{document}

\begin{titlepage}
\begin{center}
{ \huge \bfseries A title}
\end{center}
\end{titlepage}

\tableofcontents
\mainmatter

\chapter{First chapter}
\section{First section of first chapter}
Some blah, blah...
\section{Second section of first chapter}
Some more blah, blah...
\section{Third section of first chapter}
Some more blah, blah...

\end{document}

In the TOC the same page number, for the chapter and the sections, is repeated. This is the reason I want to avoid the page number for chapters. I have tried the ideas here: Omitting only the page number of chapter's heading in ToC but without luck. Also, the tocloft package seems not to work with the amsbook class. Any further idea?

0

1 Answer 1

5

It seems that amsbook is incompatible with tocloft so there's no easy way out. However let's try add this hack to the preamble (Edited based on Jubobs' suggestion):

\makeatletter
\def\@tocline#1#2#3#4#5#6#7{\relax
  \ifnum #1>\c@tocdepth % then omit
  \else
    \par \addpenalty\@secpenalty\addvspace{#2}%
        \begingroup \hyphenpenalty\@M
    \@ifempty{#4}{%
      \@tempdima\csname r@tocindent\number#1\endcsname\relax
    }{%
      \@tempdima#4\relax
    }%
    \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
    \rightskip\@pnumwidth plus4em \parfillskip-\@pnumwidth
    #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
    \ifnum #1=0
    \hfil\hbox to\@pnumwidth{}
    \else
    \hfil\hbox to\@pnumwidth{\@tocpagenum{#7}}\fi
    \par
    \nobreak
    \endgroup
  \fi}
\makeatother

This redefine the \@tocline command such that if the depth of the current line in the table of content is 0 (i.e. it is a chapter), then it will not print the page number.

Check out the result:

enter image description here

1
  • This solves the problem. Nice answer.
    – Grimolatto
    Commented Aug 4, 2013 at 16:44

You must log in to answer this question.

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