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:
\addcontentsline{toc}{chapter}{Conclusion}
\bibliographystyle{plainnat}
% to add unnumbered bibliography to toc:
\addcontentsline{toc}{chapter}{\bibname}
\bibliography{\jobname}
\end{document}
However, it fails to exclude the Conclusion and Bibliography from the last \localtableofcontents
:
My thoughts were to either:
\etocsettocdepth
the last\localtableofcontents
to not include chapters anymore just before the conclusion- 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
?
minitoc
instead ofetoc
, 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 withtitlesec
but it nevertheless works flawlessly.{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...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...