Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Isn't \tableofcontents* a better way to do it? –  gnz Jun 2 '12 at 8:37
    
Doesn't work for me? I'm just getting that asterisk placed right below the heading. –  Niko Jun 2 '12 at 8:41
    
\tableofcontents* removes the ToC entry from the ToC itself in the memoir class. –  lockstep Jun 2 '12 at 8:47

2 Answers 2

up vote 14 down vote accepted

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}
share|improve this answer
    
Thanks, that worked a treat! –  Niko May 9 '12 at 16:12
1  
How and why does this work? (Feel free to edit the answer into your answer) –  doncherry Jun 22 '12 at 22:04
    
@doncherry Just take the original definition of \tableofcontents from article.cls and remove the code that creates the heading. –  Thorsten Jun 23 '12 at 6:08

If you want no TOC, but still want the "sidebar" created by hyperref you may do this:

\documentclass{...}
...
\usepackage{hyperref}

\begin{document}
\newsavebox{\hidden}\sbox{\hidden}{\vbox{\tablefocontents}}

<code>
\end{document}
share|improve this answer
    
The bookmarks are produced independently of the presence of the TOC. –  egreg Jun 2 '12 at 10:36
    
@egreg Thank you for this information, didn't know that. –  Peter Breitfeld Jun 2 '12 at 10:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.