0

Is there a way to group all e.g. subsections together in the TOC (at the beginning of the document) under a part heading? I'm currently using tocloft. Minimal example:

\documentclass[a4, 11pt]{article}

\usepackage{tocloft}

\begin{document}

\tableofcontents*

\newpage

\cftaddtitleline{toc}{part}{All the Sections}{}

\section{blah}

\subsection{blah1.1}

\subsection{blah1.2}

\section{blah2}

\subsection{blah2.1}

\subsection{blah2.2}

\section{blah3}


\cftaddtitleline{toc}{part}{All the Subsections}{}


\end{document}

This obviously compiles as:

Contents with subsections under sections

I want something like this (obviously with the correct section numbering):

contents with subsections together but with incorrect numbering

1 Answer 1

0

I am pretty sure what you want can be accomplished by etoc. I don't have time to put in a full MWE right now, but here's how I would do it:

  • I will print your ToC in two passes.
  • The first pass I will print to depth level 2 so that the sections are printed.
  • The second past I will print to depth level 3 AFTER using \etocsetlevel{section}{6} to make sections "invisible".

In the current manual, the commands you needs are in sections

    1. A powerful functionality of etoc: the re-assignment of levels with \etocsetlevel
    1. The \etocsettocdepth and \etocsetnexttocdepth commands

Pay attention to also the boxed text on pages 18-19 which describes something similar to what you want.

You must log in to answer this question.

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