[Tex/LaTex] How to get multiple ToC entries in the same line

line-breakingmemoirtable of contents

I need that, in the ToC, all the \paragraph references appear in the same line, like.

1 First Chapter................................................1
 1.1 First Section.............................................1
   One paragraph 1, Another § 3, One more § 4
 1.2 Second Section.......................................7
   § in sec. two 7, Another § in sec. two 11

And so on… I'm using the memoir class, which, in its manual, actually uses this for its subsections, but don't explain how to do it.

Best Answer

The titletoc package provides a means to format ToC-entries:

enter image description here

\documentclass{memoir}% http://ctan.org/pkg/memoir
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\titlecontents*{subsection}% <section>
  [1.5em]% <left>
  {\small}% <above-code>
  {}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
  {}% <numberless-entry-format>
  {\ \thecontentspage}% <filler-page-format>
  [,\ ]% <separator>
  []% <end>
\setcounter{tocdepth}{2}% Display up to \subsection in ToC
\begin{document}
\tableofcontents
\chapter{First chapter} \lipsum
\section{First section} \lipsum
\subsection{One paragraph} \lipsum
\subsection{Another paragraph} \lipsum
\subsection{One more paragraph} \lipsum
\section{Second section} \lipsum
\subsection{Paragraph in section two} \lipsum
\subsection{Another paragraph in section two} \lipsum
\end{document}

I've left the original no-dotted-leader for the chapter formatting, since the bold typeface already links the title with the page number. However, it would be possible to add this as well.

I also typeset your paragraphs as \subsections, since there's no need to use \pararaph here. Not sure whether this is what you're after, since you only mentioned ToC specifications. I've also left the Contents in the ToC, which can be removed, if needed.

Page 16 of the titletoc documentation describes the layout of the command \titlecontents. Remember to compile twice for the ToC entries to settle.