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.

When I'm adding \tableofcontents to my document the PDF generated contains a nice list of sections/subsections on the left side, when viewed in Adobe Acrobat (I also use hyperref package). Everything is fine.

But now I don't need this TOC to be visible in the document, but I want to keep it visible in the PDF. When I'm deleting \tableofcontents from the document it disappears in the PDF as well. How to solve it?

ps. Maybe this is the problem (my log)?:

Package hyperref Warning: Option `bookmarks' has already been used,
(hyperref)                setting the option has no effect on input line 33.
share|improve this question
4  
Works for me (i.e. when using hyperref without \tableofcontents, I still get bookmarks). –  lockstep Nov 1 '10 at 15:31

3 Answers 3

Here's a hack:

\newsavebox{\discard}
\sbox{\discard}{\vbox{\tableofcontents}}

The tableofcontents is generated and saved but never inserted into the document.

But I just read @lockstep's comment; you may not need any of this.

share|improve this answer
up vote 1 down vote accepted

This is what I've found and it works perfectly:

% ...
\phantomsection
\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
share|improve this answer

A simple way would be to use the pdfpages package or a tool like pdfjam to remove the table of contents page(s) from the pdf file.

Other solutions involving modification of macros such as \tableofcontents and \contentsline require to know which document class you are using. And of course you may create pdf bookmarks using hyperref commands yourself instead of using \tableofcontents.

share|improve this answer

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.