My objective is to print a mini ToC under a section but this mini ToC should only print the subsection* automatically and not appear in the main ToC. As a reference, I am using the following: sample and another sample.

What I have gathered so far is that I can use, say:

\printcontents[sections]{}{3}{} % allows printing of subsection* only


\subsection*{Test subsection not in ToC}
\addcontentsline{ptc}{subsection}{Test subsection in ToC now} % must be added manually unless a command is created that takes as argument the subsection.

but all of this seems a bit cumbersome.

Can anyone suggest an automatic minitoc creation of subsection* level under a section?

For the sake of completion, here is mwe:


\section{Test section in ToC}
\subsection*{Test subsection not in ToC}
\subsection{Test subsection in ToC}


You can redefine \subsection to automate this via xparse:

enter image description here


\RenewDocumentCommand{\subsection}{s o m}{%


\printcontents[mytoc]{}{2}{} % allows printing of subsection only


\section{Test section in ToC}\lipsum[1]
\subsection*{Test subsection now in ToC}\lipsum[2]
\subsection{Test subsection in ToC}\lipsum[3]

  • Will this interfere with the main ToC? I just want to print locally? That is, mytoc should only appear under the corresponding section and not under the main ToC.
    – azetina
    Jun 23 '16 at 19:25
  • I updated the question. Would you suggest to create a new title class similar to subsection? If so one would need to somehow declare commands so that it prints a mini ToC containing it locally.
    – azetina
    Jun 23 '16 at 19:30
  • @azetina: When I take my answer and add \tableofcontents at the start of the document, I get the \subsection* only in the section ToC, not the \tableofcontents. That's because the \subsection* ToC-entry is written to .ptc, not .toc.
    – Werner
    Jun 23 '16 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.