10

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.

2 Answers 2

11

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.

3
  • 2
    marlonob is using memoir. Your solution will also work, but you need to add \setcounter{tocdepth}{2} to get subsections into the TOC (which memoir doesn't do by default.)
    – Alan Munn
    Dec 20, 2011 at 3:21
  • @AlanMunn: Yikes! Thanks for picking that up.
    – Werner
    Dec 20, 2011 at 3:28
  • @Werner: Hey! Just what I needed. One more thing: I have changed the format for the page numbers --just the page numbers, not the title-- to be sans serif and \tiny with the memoir \renewcommand*{\cftparagraphpagefont}{\sffamily\tiny}. This is much more clear because of the numbers after the section sign, which can be confusing. Any idea of how to preserve that or stablish it with titletoc?. I will check the documentation anyway. Many thanks!
    – marlonob
    Dec 20, 2011 at 17:08
0

Here is the code for the memoir manual long ToC for in-line subsections.

There is a package file memsty.sty which includes the code

% memsty.sty
....
\newcommand*{\setupparasubsecs}{%
  \let\oldnumberline\numberline
  \renewcommand*{\cftsubsectionfont}{\itshape}
  \renewcommand*{\cftsubsectionpagefont}{\itshape}
  \renewcommand{\l@subsection}[2]{
    \ifnum\c@tocdepth > 1\relax
      \def\numberline####1{\textit{####1}~}%
      \leftskip=\cftsubsectionindent
      \rightskip=\@tocrmarg
%%      \advance\rightskip 0pt plus \hsize % uncomment this for raggedright
%%      \advance\rightskip 0pt plus 2em    % uncomment this for semi-ragged
      \parfillskip=\fill
      \ifhmode ,\ \else\noindent\fi
      \ignorespaces 
      {\cftsubsectionfont ##1}~{\cftsubsectionpagefont##2}%
       \let\numberline\oldnumberline\ignorespaces
    \fi}}

\AtEndDocument{\addtocontents{toc}{\par}}%%% OK

...

where the macro \setupparasubsecs makes the subsection entries in the ToC be in-line rather than on a line each.

The code for the manual includes

\documentclass[10pt,letterpaper,extrafontsizes]{memoir}
\usepackage{memsty}
...
\setupparsubsecs
\tableofcontents
...
\end{document}    

You must log in to answer this question.

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