2

Similar to How to Add Description to TOC, I want to add short descriptions to sections that show up in the TOC. Unfortunately, \addtocontents does not seem to work for minitoc, which I want to use. Here is a minimal example:

\documentclass{book}
\usepackage{minitoc}

\begin{document}
\dominitoc
\tableofcontents

\chapter{First Chapter}
\minitoc

\section{First Section}
\addtocontents{toc}{\noindent short description of the first section}
\addcontentsline{toc}{section}{this would work but it adds the page number and dots (which is unwanted)}

\section{Second Section}
\addtocontents{toc}{\noindent short description of the second section}

\end{document}

It creates the correct output for \tableofcontents but the short descriptions are missing for \minitoc: normal TOCminitoc TOC

Using \addcontentsline instead of \addtocontents works (see example) but the formatting with the dots and the page number is unwanted. Is there a way to get short descriptions for the sections/subsections into the TOC produced by minitoc?

Sebastiano
  • 54,118
Thomas
  • 141

1 Answers1

2

Solved the problem by using titletoc and \addcontentsline instead of minitoc and \addtocontents, respectively. To get rid of the page number and the dots produced by \addcontentsline, I used tocloft to create a new type of list entry, for which I turned off the page numbers.

Here is a working example:

\documentclass{book}
\usepackage{titletoc}
\usepackage{tocloft}
\usepackage{blindtext}

\newlistentry[chapter]{shortdescr}{toc}{1}
\cftpagenumbersoff{shortdescr}
\newcommand{\shortdescr}[1]{\addcontentsline{toc}{shortdescr}{\hspace{\cftsecnumwidth}#1}}

\begin{document}

\tableofcontents

\chapter{First Chapter}
\startcontents
\printcontents{}{0}{\section*{Contents}}

\section{First Section}
\shortdescr{short description of the first section}

\section{Second Section}
\shortdescr{short description of the second section}

\stopcontents

\chapter{Second Chapter}
\startcontents
\printcontents{}{0}{\section*{Contents}}

\section{First Section}
\shortdescr{\blindtext}

\section{Second Section}
\shortdescr{short description of the second section in the second chapter}

\stopcontents

\end{document}
Thomas
  • 141