Amsbook class + two tables of contents

There are a few things to change in starttoc to make it compatible with amsbook:

  1. we want to avoid that it writes an entry in the table of contents, which chapter* normally does in amsbook;
  2. we don’t want that it takes the initiative to set the headers, because amsbook takes care of the business anyway.
documentclass{amsbook}
usepackage{shorttoc}

makeatletter
renewcommandshorttoc[2]{%
  begingroup
  [email protected]=#2relax
  @restonecolfalse
  [email protected]
    parsep[email protected]
  fi
  [email protected]@restonecoltrueonecolumnfi
  [email protected][3]{}%
  chapter*{#1}%
  @startshorttoc{toc}[email protected]twocolumnfi
  endgroup
}
makeatother

title{Title}

begin{document}
maketitle

shorttoc{Contents}{1}

setcounter{tocdepth}{3}
renewcommand*contentsname{Contents (detailed)}
tableofcontents

chapter{Chapter}
section{Section}
subsection{Subsection}
subsubsection{Subsubsection}

Some subsubsection text

end{document}

The redefinition of shorttoc is essentially the same as in the package, but

  1. @tocwriteb is (locally) disabled in order not to produce a TOC entry
  2. chapter*{#1} does not issue @mkboth.

Short contents

enter image description here

Detailed contents

enter image description here

Below I define firstToC to print the first Table of Contents and secondToC to print the second one. The first one turns off overwriting of the .toc (setting @fileswfalse, locally). The second removes the printing of the ToC within the ToC (again, locally).

enter image description here

documentclass{amsbook}

makeatletter
newcommand{firstToC}{{%
  @fileswfalse% Don't overwrite the current ToC
  @starttoc{toc}contentsname
}}
newcommand{secondToC}{{%
  renewcommand{@tocwrite}[2]{}% Don't write ToC to ToC
  renewcommand{contentsname}{Contents (detailed)}%
  @starttoc{toc}{contentsname}%
}}
makeatother

begin{document}

setcounter{tocdepth}{1}%
firstToC

setcounter{tocdepth}{3}%
secondToC

chapter{Chapter}
section{Section}
subsection{Subsection}
subsubsection{Subsubsection}
Lorem ipsumldots

end{document}

Leave a Comment