3

I'm typesetting a long text, divided (so far) in three parts.

Consider this MWE:

\documentclass{memoir}

\begin{document}
    \maxsecnumdepth{subsection}
    \maxtocdepth{subsection}
    \part{First part}
    \tableofcontents

    \chapter{First chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \chapter{Second chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \part{Second part}
    \tableofcontents

    \chapter{Third chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \chapter{Fourth chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}  

    \part{Third part}
    \tableofcontents

    \chapter{Fifth chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \chapter{Sixth chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}  
\end{document}

I want a table of contents in every part. It should show the chapters, sections and subsections of that part, but I also want it to show the chapters of the other parts.

So, for example, the toc's in the MWE should look like these: what i want

Is something like this possible? I have no idea where to start.

0

1 Answer 1

3

You can do this with package etoc. cf 44. Using depth tags in the documentation.

\documentclass{memoir}

\usepackage{etoc}% cf 44. Using depth tags section of manual

\begin{document}
    \maxsecnumdepth{subsection}
    \maxtocdepth{subsection}
    \part{First part}
\etocdepthtag.toc{PARTI}

\etocsettagdepth{PARTI}{all}
\etocsettagdepth{PARTII}{chapter}
\etocsettagdepth{PARTIII}{chapter}

    \tableofcontents

    \chapter{First chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \chapter{Second chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \part{Second part}
\etocdepthtag.toc{PARTII}

\etocsettagdepth{PARTI}{chapter}
\etocsettagdepth{PARTII}{all}
\etocsettagdepth{PARTIII}{chapter}


    \tableofcontents

    \chapter{Third chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}

    \chapter{Fourth chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}  

    \part{Third part}
\etocdepthtag.toc{PARTIII}

\etocsettagdepth{PARTI}{chapter}
\etocsettagdepth{PARTII}{chapter}
\etocsettagdepth{PARTIII}{all}

    \tableofcontents

    \chapter{Fifth chapter}
    \section{A section}
    \section{Another section}
    \subsection{W[![enter image description here][1]][1]ith a subsection}

    \chapter{Sixth chapter}
    \section{A section}
    \section{Another section}
    \subsection{With a subsection}  
\end{document}

Produces


FIRST TOC

enter image description here


SECOND TOC

enter image description here


THIRD TOC

enter image description here


Note: the collision IIIThird is as in your images and is not etoc-related. You can solve it I guess using the memoir commands.

1
  • Lovely, thanks a lot! Regarding your note: yeah I know, it doesn't look like that in the real document. Thanks!
    – titto
    Commented Sep 13, 2017 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .