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 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'.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted
+50

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}
share|improve this answer
    
Nice... But it seems to be incompatible with fontspec and xelatex? For example, by adding: \usepackage{fontspec,xltxtra} \setmainfont[Mapping=tex-text]{Hoefler Text} –  Hugo S Ferreira Jul 31 '11 at 2:12
    
Damn: macfreek.nl/mindmaster/… –  Hugo S Ferreira Jul 31 '11 at 2:19
    
@Hugo S Ferreira: indeed, there seems to be an incompatibility and I don't know a workaround. I'll try to think of something. Perhaps you should add the information to your question (about you using XeLaTeX and fontspec). –  Gonzalo Medina Jul 31 '11 at 2:28
    
@Hugo Interestingly, it doesn't work even if I remove the titletoc stuff. Without a bug report (please, do) it's difficult to say where the problem is. As to the link, note it says \vspace{3px} and the error is what you could expect, since px is not a unit in TeX or XeTeX. –  Javier Bezos Aug 5 '11 at 14:26
2  
The error is caused by the \addvspace{15pt} command in the \titlecontents{chapter} command. That's the minimal document that fails. –  Alan Munn Aug 8 '11 at 17:01
show 5 more comments

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.