# Setting local toc depth < main toc depth OR limiting the scope of a local toc

I am trying to set the main \tableofcontents and several \localtableofcontents in a large document. The document consists of an introduction, several parts, a conclusion and a bibliography.

As for the tocs:

• Introduction, Conclusion and Bibliography should be set as chapters on the main \tableofcontents. The latter two should be unnumbered.
• Each part's front page is to show a \localtableofcontents of the part in question

I tried to achieve this, making use of the {etoc} package. The following MWE produces the main toc as desired:

\documentclass{report}
\usepackage{titlesec}
\usepackage{etoc}

% to be able to show localtoc on part-page
\titleclass{\part}{top}
\titleformat{\part}[display]{\normalfont\huge\filcenter\bfseries}{\partname\ \thepart}{0pt}{}

\begin{document}

\tableofcontents

\chapter{Introduction}

\part{A Part}
\etocsettocstyle{}{}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{A Chapter}
\section{A section}

\part{Another Part}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{Another Chapter}
\section{Another Section}

% (1) change local toc's depth
%\etocsettocdepth{part}
%\etocignoretoctocdepth

% (2) limit scope of last local toc
%\etocsetnexttocdepth{part}
%\invisiblelocaltableofcontents

\chapter*{Conclusion}
% to add unnumbered conclusion to toc:

\bibliographystyle{plainnat}
% to add unnumbered bibliography to toc:
\bibliography{\jobname}
\end{document}


However, it fails to exclude the Conclusion and Bibliography from the last \localtableofcontents:

My thoughts were to either:

1. \etocsettocdepth the last \localtableofcontents to not include chapters anymore just before the conclusion
2. limit the scope of the last \localtableofcontents to not reach the conclusion anymore

My attempts are commented out in the MWE above. But they could just as well be executed, as they seem to have no effect anyway...

How do I exclude the Conclusion and the Bibliography from the last \localtableofcontents?

• For a similar purpose, I use minitoc instead of etoc, but may be this could help. For the formatting of local tables, minitoc uses the same macros as regular tables of contents. If this is also the case of your package, you could create a full .toc as usual with the maximal deoth and locally tweak the table of contents typesetting by redefining \l@chapter, l@section and siblings to some macro that gobble its arguments without typesetting anything. Minitoc is said incompatible with titlesec but it nevertheless works flawlessly. – Jhor Mar 5 at 11:24
• @Jhor I am not familiar with {minitoc}, but from what I gather it creates a separate file for each toc. {etoc} does not. It adds \etoc@startlocaltoc{n} to the .toc file. And somehow it seems to know where to stop. But I don't know how to tell it to stop early... – D.Roepo Mar 5 at 14:51
• Of you main concern is the scope and not the depth, have a look to parttoc package that has all the features you want. Unfortunately, if you use it jointly with titlesec AND hyperref, you'll get hundreds of error messages... – Jhor Mar 5 at 15:04

For cases like this, etoc has the command \etocsetlocaltop. It has a slightly odd syntax, to insert a part separation to the toc file, you write

\etocsetlocaltop.toc{part}


This adds a marker to toc which behaves as if a new part started. For more details, see chapter 48 of the etoc documentation.

So the full document becomes

\documentclass{report}
\usepackage{titlesec}
\usepackage{etoc}

% to be able to show localtoc on part-page
\titleclass{\part}{top}
\titleformat{\part}[display]{\normalfont\huge\filcenter\bfseries}{\partname\ \thepart}{0pt}{}

\begin{document}

\tableofcontents

\chapter{Introduction}

\part{A Part}
\etocsettocstyle{}{}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{A Chapter}
\section{A section}

\part{Another Part}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{Another Chapter}
\section{Another Section}

% limit scope of last local toc
\etocsetlocaltop.toc{part}

\chapter*{Conclusion}
% to add unnumbered conclusion to toc:
`