# Define \tableofcontents in document class that doesn't support it

I'm required to use the sigchi document class for a paper: https://github.com/sigchi/Document-Formats/blob/master/LaTeX/sigchi.cls

I'm also required to include a table of contents on the first page, but using the standard \tableofcontents produces a stack overflow:

TeX capacity exceeded, sorry [input stack size=5000].
\@latexerr #1#2->\GenericError


Turns out a table of contents is usually prohibited in this template, as seen in the .cls file:

\def\tableofcontents{\@latexerr{\tableofcontents: Tables of contents are not
allowed in the acmconf' document style.}\@eha}


If I comment out this bit from the .cls file, I get an undefined control sequence error.

I guess, then, that the \tableofcontents command needs to be explicitly defined by a document class? In my case, it isn't. How do I add it? Would I be able to grab the source of the command definition from a standard article document class and stick it into my sigchi.cls? Or is there a package I could use?

EDIT

Here's a MWE with just a few sections. This will not compile as soon as you add a \tableofcontents.

\documentclass{sigchi}

\begin{document}

\section{First section}
\subsection{Subsection}

\section{Second section}

\end{document}

• The \tableofcontents command is defined by the class, usually, but it is possible to use the usual definition as defined by book.cls etc., with caution however. Please show us a minimal version of your document that would compile if there is no \tableofcontents – user31729 Dec 28 '16 at 11:51
• A problem might still pop up: Do you plan to hand in this document as a paper? The editors might refuse the addition of a \tableofcontents – user31729 Dec 28 '16 at 11:52
• @ChristianHupfer My department has prescribed this for all theses (don't ask...). The sigchi class is normally used for short articles which obviously don't need a TOC, but for a thesis, a TOC is required. – Elise Dec 28 '16 at 11:57
• What about sigchi-ext -- that class does have a \tableofcontents – user31729 Dec 28 '16 at 12:03
• Sorry but if someone require that you to use a specific cls then it is their responsability to ensure that the cls fullfils whatever they want. It is imho quite impertinent from your department to expect from you to hack a latex class to write your thesis. – Ulrike Fischer Dec 28 '16 at 12:08

The sigchi.cls is not meant for a thesis, it misses several features necessary for typesetting a thesis (or has redefined it strangely)

The easiest way is to use a 'copy' of the \tableofcontents version provided by article.cls

Please note that the page layout is awkward, but this is another question too.

\documentclass{sigchi}

% Perhaps useful?
%\usepackage[paper=letterpaper]{geometry}

\makeatletter
\newcommand{\contentsname}{Contents}% For example
\renewcommand{\tableofcontents}{%
\section*{\contentsname}
\@starttoc{toc}
}

% sigchi.cls does \let\thepage\relax (don't ask!), so define it again
\newcommand{\thepage}{\arabic{page}}

\makeatother

\begin{document}
\tableofcontents
\clearpage
\section{First section}
\subsection{Subsection}

\section{Second section}

\end{document}

• @Elise: A, I forgot that you have disabled \def\tableofcontents. Better use the original version of the class again – user31729 Dec 28 '16 at 12:17
• And I'm absolutely aware that the template is unsuitable for a thesis... My complaints have been so far ignored :( – Elise Dec 28 '16 at 12:18
• @Elise: I hope you will succeed with your thesis anyway. Perhaps using article or memoir miming the look of sigchi` might be even better – user31729 Dec 28 '16 at 12:19