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.

For my masters thesis I would like to have a TOC list but hide the chapter, section and subsection from the PDF document. Is there any way to do that.

In other words. \subsection*{subsection} hides it from TOC, is there any reverse method as to hide from document body but show in TOC ?

Best, Abhi

share|improve this question
5  
Does this question help you? tex.stackexchange.com/questions/86082/… –  egreg Jan 1 '13 at 14:42
    
Do you want the sectioning headers (of level section, subsection, etc) to disappear completely from the body of the text, or should they be there but not numbered? –  Mico Jan 1 '13 at 14:49
add comment

1 Answer

up vote 2 down vote accepted

The only way that I can think to do this, is to create new commands that add the items to the TOC, and increment (or reset) the counters, but dont add to the actual document.

In the below code, I have called the standard chapter and section commands once, then called the \newchapter{...} and \newsection{...} custom commands. You will see standard TOC, yet only one chapterpage and section header.

The only thing that is perhaps a little unsatisfactory, needs more work, is the spacing in the TOC, since the numbers were physically added in the \newchapter and \newsection commands, otherwise they would have been left out and I couldn't think off the top of my head what the commands are to call the TOC spacings.

[For the Record, I don't actually think this is a good idea, since the whole point of a TOC is to allow the reader to direct themselves to particular sections and subsections etc. Without the headings, your readers will, in all likelihood, get confused.]

Here is what the TOC Looks Like:

TOC

Here is what the First Chapter and Section Looks Like:

First

Here is what the Second Chapter and Section Looks Like:

enter image description here

Finally, Here is the code to achieve the above.

\documentclass{book}
\usepackage{lipsum}


\begin{document}

\tableofcontents
\pagestyle{empty}
\chapter{First Chapter - Standard}
\section{First Section - Standard}
\lipsum[1]

\newcommand{\newchapter}[1]{
    \cleardoublepage
    \addtocounter{chapter}{1}
    \setcounter{section}{0}
    \addcontentsline{toc}{chapter}{\thechapter~#1}
}

\newcommand{\newsection}[1]{
    \addtocounter{section}{1}
    \setcounter{subsection}{0}
    \addcontentsline{toc}{section}{\thesection~#1}
}

\newchapter{Second Chapter - Modified}
\newsection{Second Section - Modified}
\lipsum[1]

\end{document}
share|improve this answer
add comment

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.