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.

I do not want few subsections/ sub subsections to appear in my table of contents which might fill up unnecessary space. What command do i use to manage these sections to decide what appears and what doesn't appear on my Table

share|improve this question

3 Answers 3

up vote 7 down vote accepted

If you want numbered sectional units not appearing in the ToC, you can use the tocvsec2 package to change the depth of the units in the ToC:

\documentclass{article}
\usepackage{tocvsec2}

\begin{document}

\tableofcontents
\section{Test section in ToC}
\subsection{Test subsection in ToC}
\settocdepth{part}
\subsection{Test subsection not in ToC}
\resettocdepth
\section{Another test section in ToC}

\settocdepth{part}
\section{Test section not in ToC}
\resettocdepth

\section{Yet another test section in ToC}

\end{document}

enter image description here

Notice, however, that now the ToC looks odd, since the numbering is not consecutive.

share|improve this answer
    
is there a manner in which i could do this without having to actually write out for each section/subsection the ToC? –  howtotag Feb 3 at 15:03
    
@howtotag Sorry, but I don't understand your question. Could you please elaborate? –  Gonzalo Medina Feb 3 at 15:07
    
In general, I just use \tableofcontents and the table gets autofille, i dont need any manual entering of the chapter or section names.. However in your soln. \section{Test section in ToC} \subsection{Test subsection in ToC} \settocdepth{part} \subsection{Test subsection not in ToC} \resettocdepth \section{Another test section in ToC} we required to enter each chapter seperately. Hence was wondering if we could do away with that –  howtotag Feb 3 at 15:24
    
@howtotag So you don't need to enter the titles for chapters and sections? Then how is the ToC produced? Can you please add to your question a minimal, but complete document (as in my answer) showing how are you producing your sectional units and the table of contents? –  Gonzalo Medina Feb 3 at 15:29
    
oops, my bad! sorry for wasting your time.. realised it when pasting my code.. Yea your answer answers my question!! Thanks for your patience!! –  howtotag Feb 3 at 15:38

You can use the titletoc package to help with this- in particular, its command printcontents command can be used.

The printcontents command has syntax

\printcontents[name]{prefix}{start-level}{toc-code}

which I have used in the code below together with

\startcontents[mytoc]
...
\stopcontents[mytoc]
...
\resumecontents[mytoc]

to 'dance' around the various headings that you do/don't want to appear in your toc.

Here's a complete MWE that demonstrates the idea- the output is exactly the same as Gonzalo's answer

% arara: pdflatex
\documentclass{article}
\usepackage{titletoc}
\begin{document}


\section*{Contents}
\startcontents[mytoc]
\printcontents[mytoc]{}{0}{}
\section{Test section in ToC}
\subsection{Test subsection in ToC}

\stopcontents[mytoc]
\subsection{Test subsection not in ToC}

\resumecontents[mytoc]
\section{Another test section in ToC}

\stopcontents[mytoc]
\section{Test section not in ToC}
\resumecontents[mytoc]

\section{Yet another test section in ToC}

\end{document}
share|improve this answer

For the sections or subsections which you don't want to see on the ToC have a * after the section or subsection.Something like this section*{the section name} or subsection*{the subsection name}.

Here is a demo code:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\section{Hi I am a section appearing}
\lipsum[4]
\subsection{Hi I am a subsection appearing}
\lipsum[4]
%Now to display the section but not in ToC
\section*{Hi}
\lipsum[5]
%Now to display the subsection but not in ToC
\subsection*{Hello}
\lipsum[5]
\end{document}
share|improve this answer
    
this basically removes the numbering from the subsection itself and naturaly wouldnt appear on the ToC –  howtotag Feb 3 at 15:03
    
Thats your question right? –  subham soni Feb 3 at 15:08
    
sorry nope, i want the numbering to remain but the subsections not to appear in the ToC thats it. –  howtotag Feb 3 at 15:23

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.