# Sections are inclued in TOC, but not in the body text

I need sections included in the TOC, but not in the body text for a PDF output; so when I click the section at TOC, it will jump to the related page [where section header/title is not displayed]. How do I do this?

-

It's an unusual request, but the titlesec package can help you here: use the explicit package option and do not use #1 in \titleformat; \titlespacing can be used to suppress the spacing associated to the sectional unit:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{hyperref}
\usepackage{lipsum}

\titleformat{\section}{}{}{0em}{}
\titlespacing*{\section}{0pt}{-12pt}{0pt}

\begin{document}

\tableofcontents

\section{Test Section One}
\lipsum[1-10]
\section{Test Section Two}
\lipsum[1-10]

\end{document}


With this approach, all you have to do to recover the section titles in your document is to comment out (or delete) the \titleformat, \titlespacing lines.

-
Will this ensure vertical spacing of section suppressed? –  Firdews May 6 '12 at 19:49
@Firdews: it does now in my updated answer. –  Gonzalo Medina May 6 '12 at 19:58

Here is a solution using \phantomsection. In the example, the words "Hidden Section" would be replace with whatever the name of your section is.

Code/Example:

\documentclass[]{article}

\usepackage[english]{babel}
\usepackage[]{lipsum}

\usepackage{hyperref} % needed for \phantomsection

\begin{document}
\setcounter{tocdepth}{5}
\tableofcontents
\clearpage

\lipsum[1-7]

\phantomsection
\lipsum[1-7]

\end{document}

-

Instead of \section{I do not want you} use \addcontentsline{toc}{section}{I do not want you} like in the following MWE.

\documentclass{article}
\begin{document}
\tableofcontents