# Error with \tableofcontents, after switching from report documentclass to amsbook and back again

I changed my documentclass from report to amsbook (from AMSLaTeX) and everything was fine. Then I decided to change it back to the report document class, but it will not compile. In order for it to compile, I am forced to comment out the \tableofcontents command. It gives the error message undefined control sequence. Any help would be much appreciated.

-
Remove all auxiliary files and compile again. –  lockstep Apr 11 '12 at 20:02

Let's see what happens when we compile the following file

\documentclass{report}
\begin{document}
\tableofcontents
\chapter{Title}
\section{X}
\end{document}


Here's the contents of the .toc file:

\contentsline {chapter}{\numberline {1}Title}{2}
\contentsline {section}{\numberline {1.1}X}{2}


When we change the first line of the file to be

\documentclass{amsbook}


the .toc file becomes

\contentsline {chapter}{\tocchapter {Chapter}{1}{Title}}{3}
\contentsline {section}{\tocsection {}{1}{X}}{3}


Thus we see that the amsbook class inserts some commands (\tocchapter and \tocsection) which are not understood by the standard class report; moreover it organizes the information in a slight different way.

One should also observe that the AMS classes are incompatible with tocloft, for a similar reason: they manage the .toc file in a different way.

## Solution

Remove the .toc file before compiling after having changed the class. This is a good thing to do in such circumstances with all auxiliary files, so that we start afresh with the new document class.

-