Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a LaTeX document with short sections which results in subsections being listed in the table of contents in the same or subsequent pages.

How can I suppress the appearance of page number for each subsection and make a list of subsections in a single sentence under their section? Some books use this style...

Edit: I am using the report document class and no special toc package

share|improve this question

migrated from stackoverflow.com Jul 9 '12 at 15:28

This question came from our site for professional and enthusiast programmers.

2  
Please also indicate which document class you're using (article, report, book, memoir, something else?) as well as if you're already loading any packages (such as tocloft) that affect the way the table of contents is organized. –  Mico Jul 9 '12 at 17:45

1 Answer 1

up vote 7 down vote accepted

The titletoc package provides a means to have "in-line" or paragraph-style ToC entries. You format a specific entry using

\titlecontents*{<section>}[<left>]
  {<above code>}
  {<numbered entry format>}
  {<unnumbered entry format>}
  {<filler page format>}
  [<separator>][<end>]

The *-version of \titlecontents groups the entries in a single paragraph. Here's a minimal example highlighting its use, with the format settings taken from the titletoc documentation:

enter image description here

\documentclass[10pt]{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\titlecontents*{subsection}[1.5em]
  {\small}
  {\thecontentslabel. }
  {}
  {, \thecontentspage}
  [.---][.]

\begin{document}
\tableofcontents

\section{First section}
\subsection{First}\subsection{Second}\subsection{Third}
\subsection{Fourth}\subsection{Fifth}\subsection{Sixth}
\subsection{Seventh}\subsection{Eighth}\subsection{Ninth}
\subsection{Tenth}

\section{Second section}
\subsection{First}\lipsum[2]\subsection{Second}\lipsum[2]
\subsection{Third}\lipsum[2]\subsection{Fourth}\lipsum[2]
\subsection{Fifth}\subsection{Sixth}\subsection{Seventh}
\subsection{Eighth}\subsection{Ninth}\subsection{Tenth}

\section{Last section}
\subsection{First}\lipsum[3]\subsection{Second}\lipsum[3]
\subsection{Third}\lipsum[3]\subsection{Fourth}\lipsum[3]
\subsection{Fifth}\subsection{Sixth}\subsection{Seventh}
\subsection{Eighth}\subsection{Ninth}\subsection{Tenth}

\end{document}

This prints the page number \thecontentspage with every \subsection entry, which is the default. It could be possible to extend this to include a page number for all \subsections on a page only once. However, this may require additional compilations and some forethought as to what the presentation should look like. For example, do you start with the "collective" page number, or do you end with it? If not handled properly, it my be confusing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.