[Tex/LaTex] How to hide the table of content’s heading

sectioningtable of contents

Is there any chance to hide the "Table of contents" heading that \tableofcontents generates?

If figured that \renewcommand\contentsname{} works (it sets the title to "", an empty string), but it does not remove the heading completely – the space is still blocked.

Best Answer

If you are using the article class you can find the definition of \tableofcontents in the article.cls file:

\newcommand\tableofcontents{%
    \section*{\contentsname
        \@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
    \@starttoc{toc}%
    }

Now you can just remove the part where \section* is defined:

\documentclass{article}
\makeatletter
\renewcommand\tableofcontents{%
    \@starttoc{toc}%
}
\makeatother
\begin{document}
\tableofcontents
\section{test}
\section{test2}
\end{document}
Related Question