# Add new toc-type showing different section levels

All references I found so far on the subject only show how to set the number of levels shown in a table of contents (through \setcounter{tocdepth}{n}.

But I would like to define a new (additional) type of toc that lists all sections below a given sectioning level. For example I would like to print a toc at the beginning of each \part, listing everything starting with \chapter. (This is especially important if the parts are in subfiles that I also would like to be compilable as standalone documents.

Is there a place (variable, command) where I can define the top level of a toc? Or are there packages for this purpose?

Thanks for any hints.

-
I suggest you start by looking at the minitoc package. –  Andrew Swann Feb 13 '13 at 11:53
Sorry to bother you, but I just noticed that you haven't accepted answers to your questions. Please consider doing so; I know that you have up-voted answers, but accepting an answer and up-voting are two different actions; in case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Feb 13 '13 at 16:37

You can use either the minitoc or the titletoc packages; a third possibility would be to manually create the partial ToCs using \@starttoc. Below I show exmples using the packages:

1) Using titletoc and its \startcontents, \printcontents commands. In the example I redefined \@endpart (as implemented in book.cls) so that the pártial ToCs are automatically generated by each \part command; I also made some adjustments so that these partial ToCs will be typeset starting in the same page in which the corresponding sectional heading is shown; additional horizontal rules were also added:

\documentclass{book}
\usepackage{titletoc}

\makeatletter
\def\@endpart{%
\vfil
\hrule
\startcontents[parts]
\printcontents[parts]{}{0}{}
\par\bigskip\hrule
\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\makeatother

\begin{document}
\tableofcontents

\part{Test Part One}
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}

\part{Test Part Two}
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}

\end{document}


And here are some images of the resulting partial ToCs:

and

A simple modification to the example allows to place the partial ToCs starting in their own page, and without rules, etc.

2) Now, an example using the minitoc package:

\documentclass{book}
\usepackage{minitoc}

\begin{document}
\doparttoc
\tableofcontents

\part{Test Part One}
\parttoc
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}

\part{Test Part Two}
\parttoc
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}

\end{document}


With the standard settings, each partial ToC is now typeset starting in its own page and with a heading, as the images illustrate:

and

-
Thanks. Both solutions do what I need. The minitoc version seems more straightforward and is probably enough for the actual task at hand. The titletoc approach looks somewhat more interesting and configurable, and I'll probably look into that too. –  uli_1973 Feb 13 '13 at 21:50