[Tex/LaTex] Table of Contents Style

fontspectable of contentstitletocxetex

I really enjoy the table of contents formatting (all sections of a chapter in a single paragraph), of the Motion Mountain's physics books. Does anyone know how to reproduce that kind of style? Is there a LaTeX package for managing TOC styles?

BTW, I need to use XeLaTeX, and it seems to exist an incompatibility between 'fontspec' and 'titletoc'.

Best Answer

The tocloft and titletoc packages let you customize the table of contents. In your case, the second package could be a better choice: the starred version of \titlecontents groups the entries in a single paragraph.

Here's a little example (of course, feel free to adapt it according to your needs):

\documentclass{scrbook}
\usepackage{titletoc}

\titlecontents{chapter}[0pt\addvspace{15pt}]
{\llap{\makebox[3em]{\oldstylenums{\thecontentspage\hfill\thecontentslabel}}\hskip1em}
  \small\scshape\vskip-\baselineskip}{}{}{}
\titlecontents*{section}[20pt]
{\upshape}{}{}
{, \oldstylenums{\thecontentspage}}[][\ \textbullet\ ][]

\begin{document}

\tableofcontents
\chapter{Test chapter one}
\section{Test section one one}
\section{Test section one two}
\section{Test section one three}
\section{Test section one four}
\section{Test section one five}
\chapter{Test chapter two}
\section{Test section two one}
\section{Test section two two}
\section{Test section two three}

\end{document}

The resulting ToC:

enter image description here

EDIT: as Alan Munn noticed in a comment, the above example fails to compile with fontspec and xelatex, due to the \addvspace{15pt} command in the first optional argument of \titlecontents{chapter}; a possible workaround would be to introduce the vertical skip in the second mandatory argument of \titlecontents:

\documentclass{scrbook}
\usepackage{fontspec,xltxtra}
\usepackage{titletoc}

\titlecontents{chapter}[0pt]
{\vskip15pt\llap{\makebox[3em]{\oldstylenums{\thecontentspage\hfill\thecontentslabel}}\hskip1em}
  \small\scshape\vskip-\baselineskip}{}{}{}
\titlecontents*{section}[20pt]
{\upshape}{}{}
{, \oldstylenums{\thecontentspage}}[][\ \textbullet\ ][]

\begin{document}

\tableofcontents
\chapter{Test chapter one}
\section{Test section one one}
\section{Test section one two}
\section{Test section one three}
\section{Test section one four}
\section{Test section one five}

\chapter{Test chapter two}
\section{Test section two one}
\section{Test section two two}
\section{Test section two three}

\end{document}
Related Question