Skip to content

Instantly share code, notes, and snippets.

@jfbu
Created October 29, 2019 20:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfbu/88f77299fae9a9d920eb52d0183a3b41 to your computer and use it in GitHub Desktop.
Save jfbu/88f77299fae9a9d920eb52d0183a3b41 to your computer and use it in GitHub Desktop.
usage of etoc package to handle multiple TOCs, for example one short and one detailed mutually referencing one another
% we use etoc concept of depthtags
% here, it could be simplified but I added some complete
% mark-up in case the location of the TOCs are moved.
% of course, this can be extended easily to >2 TOCs
% with complex rules of listing or not one another
% jfbu Mardi 29 octobre 2019 à 21:38:25
\documentclass{memoir}
\pagestyle{plain}
\chapterstyle{default}
\setsecnumdepth{subsection}
\usepackage{hyperref}
% TOC STUFF
\usepackage{etoc}
\AtBeginDocument{\addtocontents{toc}{\protect\hypersetup{hidelinks}}}
\etocsettagdepth{AfterShort}{all}
\etocsettagdepth{AfterDetailed}{all}
\begin{document}
\frontmatter
\etocsettocdepth{1}
\etocsettagdepth{Short}{none}
\etocsettagdepth{Detailed}{all}
\renewcommand{\contentsname}{Short Contents}
\etocdepthtag.toc{Short}
\tableofcontents
\etocdepthtag.toc{AfterShort}
\clearpage
\etocsettocdepth{2}
\etocsettagdepth{Short}{all}
\etocsettagdepth{Detailed}{none}
\renewcommand{\contentsname}{Detailed Contents}
\etocdepthtag.toc{Detailed}
\tableofcontents
\etocdepthtag.toc{AfterDetailed}
\clearpage
\mainmatter
\newcommand\Sample{
\chapter{Chap}This is a chapter.
\section{Sec}This is a section.
\subsection{Subsec}This is a subsection.
}
\Sample\Sample
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment