[Tex/LaTex] Insert Table of Contents in chapter

etocminitoctable of contents

Any idea of how to create a mini table of contents (TOC) in the beginning of a chapter? Not the ordinary TOC in the beginning of the report, but a mini TOC in the beginning of a chapter (like, containing the specific chapter).

Best Answer

Here is a quick (stock) answer for this:

The easiest way is to use etoc package and its \localtableofcontents macro, at the appropriate place. The manual is at https://ctan.org/pkg/etoc.

\documentclass{book}

\usepackage{etoc}


\begin{document}
\tableofcontents % Global toc
\chapter{First}
\localtableofcontents % local toc
\section{First section}

\chapter{Second}
\localtableofcontents

\section{First section of 2nd chapter}

\end{document}

enter image description here

Edit Here is the memoir version.

For some reasons I can't figure out (the manual of etoc is not really clear in this case) it's necessary to use \localtableofcontents*. The individual tocdepth can be controlled with the \etocsettocdepth.toc{sectionlevel} command (note the .toc in the macro name`)

\documentclass{memoir}

\usepackage{blindtext}
\usepackage{etoc}


\setsecnumdepth{subsection}
\etocsettocdepth{subsection}
\begin{document}

\tableofcontents % Global toc
\chapter{First}
\etocsettocdepth.toc{section}

\localtableofcontents*
\section{First section}
\subsection{First subsection -- not in the local toc}

\blindtext

\chapter{Second}
\etocsettocdepth.toc{subsection}
\localtableofcontents*

\section{First section of 2nd chapter}
\subsection{First subsection of first section of 2nd chapter}

\end{document}

enter image description here