I simply want to make a local Table of Contents (TOC) which shows in its content what is below the level the TOC is inserted in and not outside.
For example, if I do \minitoc
inside \section{}
, the local TOC should only show the subsections and subsubsection inside this section.
Similarly, if I do \minitoc
inside \subsection{}
, the local TOC should only show the subsubsections inside this section.
But a TOC inside, say, a subsection
, will show everything starting from the section above, to the end of the document! Which is very confusing.
I'll show an MWE and then show what I want:
\documentclass{report}
\usepackage{minitoc}
\setcounter{secnumdepth}{5}
\begin{document}
\dominitoc
\setcounter{tocdepth}{1} %For the main TOC, only show chapter/section
\tableofcontents
\chapter{this is chapter heading}
\section{this is section heading}
\subsection{this is subsection heading}
\setcounter{minitocdepth}{5}
\minitoc %This TOC should only show the two subsubsection below!
\subsubsection{this is subsubsection heading}
\subsubsection{this is another subsubsection heading}
\subsection{this is another subsection heading}
\subsection{this is yet another subsection heading}
\section{this is yet another section}
\end{document}
The idea is the the local TOC should only show what is in the lower level and no more. It acts as a guide of what is inside that section or subsection.
This way, I can make a local TOC in each section or subsection, which only shows what is below it, and it gets cut off when the level goes up automatically.
I hope there is a simple solution for this. I am open to others solutions using etoc or something else as long as the local TOC only shows what is inside that level as described above.
Addition
I tried to use this answer, but I do not understand the answer (too complicated for me) and how to use it for the above example. This is what I tried:
\documentclass{report}
\usepackage{minitoc}
\usepackage{etoc}
\setcounter{secnumdepth}{5}
\begin{document}
%\dominitoc %Removed. switch to etoc
\setcounter{tocdepth}{1} %For the main TOC, only show chapter/section
\tableofcontents
\chapter{this is chapter heading}
\section{this is section heading}
\subsection{this is subsection heading}
%\setcounter{minitocdepth}{5} %Do not use now, we are using etoc
\localtableofcontents
\subsubsection{this is subsubsection heading}
\subsubsection{this is another subsubsection heading}
\subsection{this is another subsection heading}
\subsection{this is yet another subsection heading}
\section{this is yet another section}
\end{document}
I get this:
Which is not what I want. If someone knows how to implement the solution shown in here for my small example above, it will be great. Again, I am not asking for fancy heading, fancy line styles, minipages, and all that. A simple local TOC is all I want.
minitoc
can manage this. – karlkoeller Jan 2 '15 at 20:43\makeatletter \newif\ifTOC@marginpatched \newcommand{\SetTOCrightmargin}[1]{% \ifTOC@marginpatched\else \let\old@pnumwidth\@pnumwidth \let\old@dottedtocline\@dottedtocline \def\@dottedtocline##1##2##3##4##5{% \old@dottedtocline{##1}{##2}{##3}{##4}{##5\hskip\TOC@rightmargin}} \let\old@l@part\l@part \def\l@part##1##2{\old@l@part{##1}{##2\hskip\TOC@rightmar..
– Nasser Jan 2 '15 at 20:47