33

I stumbled upon this TOC today:

The sample TOC

I really like its structure and simplicity. The page numbers are right behind the entries, and not unnecessarily remote as they often are. The separation between chapter numbering on the left and titles on the right clearly sets the two apart.

I would like to reproduce this design for a book, but have no idea where to start. Can you show me how to reproduce this?

Bonus
Do you have any idea how this could be extended to also list sections, and remove the authors?

4
  • I suppose you want it to be automatically generated, as opposed to typing it in? May 16, 2014 at 13:29
  • 2
    Which document class do you use? Always nice if you add a minimal example. May 16, 2014 at 13:36
  • 3
    I just want to remark that for most theses this structure is too simple. This is clearly the TOC of a book that is a collection of chapters by different authors so the requirements are different. But if you're sure that nobody would ever want to look up the page number of a particular section or even subsection then sure, go for it :)
    – Christian
    May 16, 2014 at 22:50
  • I should have mentioned: do you think there is any way to add sections to this in a sensible way :-)?
    – Ingo
    May 17, 2014 at 8:05

2 Answers 2

42
+100

pretty toc

Use etoc.

The update enables sections in the TOC (see below for the first answer). Furthermore, it uses \chaptername, \partname (available in the book class) for internationalization. And it uses a non-breakable space before the page number.

pretty toc with sections

\documentclass{book}
\usepackage{etoc}
\etocsetlevel{authors}{1}
\etocsetlevel{section}{2}
\etocsetlevel{subsection}{3}
\etocsettocdepth{section}
\newcommand{\authorstotoc}[1]{\etoctoccontentsline{authors}{#1}}

\newlength{\tocleft}
\setlength{\tocleft}{3cm}

\newlength{\tocsep}
\setlength{\tocsep}{2em}


\etocsetstyle{part}{}{}{{\bfseries\makebox[0pt][r]
                              {\partname\ \etocnumber\hspace{\tocsep}}%
                     \etocname\kern1em\relax\etocpage\par}\vspace{3ex}}{}

% to avoid possible line breaks between chapter (or part) name and page number
% replace \quad by \kern1em\relax

\etocsetstyle{chapter}{}{}{\etocifnumbered
                             {\makebox[0pt][r]
                               {\chaptername\ \etocnumber\hspace{\tocsep}}}
                             {\ifcase\TEMP
                              \def\TEMP{1}\or\def\TEMP{2}%
                              \makebox[0pt][r]
                                  {\parbox[t]{\dimexpr\tocleft-\tocsep\relax}
                                   {\raggedleft Introductory\\ \strut \chaptername}%
                                   \hspace{\tocsep}}\fi
                              }\textbf{\etocname\kern1em\relax\etocpage}\par
                             \etocifnumbered{}{\vspace{2ex}}}{}

\etocsetstyle{authors}{}{}{\etocname\par\vspace{1ex}}{\vspace{2ex}}

\etocsetstyle{section}{}{}{\makebox[0pt][r]{\etocnumber\hspace{\tocsep}}%
                           \etocname\kern1em\etocpage\par}{}

\etocsettocstyle {\noindent\sffamily{\LARGE \contentsname}\par
                  \thispagestyle{empty}%
                  \noindent\rule{\dimexpr\tocleft-\tocsep}{1pt}\par\vspace{3ex}%
                  \leftskip\tocleft\parindent0pt\def\TEMP{0}}{}

\begin{document}
\frontmatter

\tableofcontents

\chapter{Preface}

\mainmatter

\chapter*{A Few Words About Systems Engineering}
\addcontentsline{toc}{chapter}{A Few Words About Systems Engineering}

\part{Systems Engineering Practice}

\chapter{Methodology for an integrated Definition of a System and its
  Subsystems: The Case-Study of an Airplane and its Subsystems}

\authorstotoc{Sergio Chiesa, Marco Fioriti and Nicole Viola}

\section{This is a section}

\section{This is another section}

\chapter{Complex-Systems Design Methodology for Systems-Engineering
  Collaborative Environment}

\authorstotoc{Guido Ridolfi, Erwin Mooij and Sabrina Corpino}

\section{Another section}

\section{One more section}

\chapter*{A Few Words About Systems Engineering}
\addcontentsline{toc}{chapter}{A Few Words About Systems Engineering}

\section*{An unnumbered section}
\addcontentsline{toc}{section}{An unnumbered section}

\end{document}

Earlier code, for the TOC without sections:

\documentclass{book}
\usepackage{etoc}
\etocsetlevel{authors}{1}
\etocsetlevel{section}{2}
\etocsettocdepth{authors}
\newcommand{\authorstotoc}[1]{\etoctoccontentsline{authors}{#1}}

\newlength{\tocleft}
\setlength{\tocleft}{3cm}

\newlength{\tocsep}
\setlength{\tocsep}{2em}


\etocsetstyle{part}{}{}{{\bfseries\makebox[0pt][r]
                              {Part \etocnumber\hspace{\tocsep}}%
                     \etocname\quad\etocpage\par}\vspace{3ex}}{}

% to avoid possible line breaks between chapter (or part) name and page number     
% replace \quad by \kern1em\relax

\etocsetstyle{chapter}{}{}{\etocifnumbered
                             {\makebox[0pt][r]
                               {Chapter \etocnumber\hspace{\tocsep}}}
                             {\ifcase\TEMP
                              \def\TEMP{1}\or\def\TEMP{2}%
                              \makebox[0pt][r]
                                  {\parbox[t]{\dimexpr\tocleft-\tocsep\relax}
                                   {\raggedleft Introductory\\ \strut Chapter}%
                                   \hspace{\tocsep}}\fi
                              }\textbf{\etocname\quad\etocpage}\par
                             \etocifnumbered{}{\vspace{2ex}}}{}

\etocsetstyle{authors}{}{}{\etocname\par\vspace{2ex}}{}

\etocsettocstyle {\noindent\sffamily{\LARGE \contentsname}\par
                  \thispagestyle{empty}%
                  \noindent\rule{\dimexpr\tocleft-\tocsep}{1pt}\par\vspace{3ex}%
                  \leftskip\tocleft\parindent0pt\def\TEMP{0}}{}

\begin{document}
\frontmatter

\tableofcontents

\chapter{Preface}

\mainmatter

\chapter*{A Few Words About Systems Engineering}
\addcontentsline{toc}{chapter}{A Few Words About Systems Engineering}

\part{Systems Engineering Practice}

\chapter{Methodology for an integrated Definition of a System and its
  Subsystems: The Case-Study of an Airplane and its Subsystems}

\authorstotoc{Sergio Chiesa, Marco Fioriti and Nicole Viola}

\chapter{Complex-Systems Design Methodology for Systems-Engineering
  Collaborative Environment}

\authorstotoc{Guido Ridolfi, Erwin Mooij and Sabrina Corpino}

\end{document}
8
  • to avoid possible line breaks between chapter name and page number replace \quad by \kern1em\relax.
    – user4686
    May 16, 2014 at 22:33
  • @ jfbu How can I use \usepackage[utf8]{vietnam} with your code? May 16, 2014 at 23:52
  • @minthao_2011 I don't know vietnamese, but I should have used \chaptername\ and \partname\ rather than Chapter and Part. There remains to translate Introductory in the code (and I don't know if it then should come before or after the translated Chapter).
    – user4686
    May 17, 2014 at 6:45
  • Wow, thanks. The simplicity of this solution is amazing. Do you have any idea how we could add sections to the TOC, by removing the authors?
    – Ingo
    May 17, 2014 at 8:07
  • @Ingo see update. Oh sorry, did you really want the authors removed? I have kept them and added sections.
    – user4686
    May 17, 2014 at 12:15
9

This is not an answer to “how to reproduce”, but could give you some notion about how to start. Look at the TOC of my note on functional analysis. It is not what you're after, but I think you'll agree it is nonstandard.

Here is some (most?) of the code implementing this, from a local class file:

\renewcommand\l@chapter[2]
  {\vrule width0pt height 16pt depth 4pt
   \normalfont\bfseries#1&\normalfont\bfseries#2\cr}
\renewcommand\l@section[2]{\small#1&\small#2\cr}

\renewcommand\tableofcontents{\par
  \bigskip
  \begingroup\centering
  \renewcommand\numberline[1]{Chapter ##1:\enspace}
  \leavevmode
  \vbox{\baselineskip10pt
    \halign{\hfil##\quad$\cdot$&\quad##\hfil\cr
      \@input{\jobname.toc}}}
  \par\endgroup
  \newwrite\tf@toc
  \immediate\openout\tf@toc\jobname.toc}

A bit of explanation: Here are the first two lines from the .toc file:

\contentsline {chapter}{\numberline {1}Transfinite induction}{3}
\contentsline {section}{Wellordering}{3}

These expand into (assuming @ is a letter)

\l@chapter{\numberline {1}Transfinite induction}{3}
\l@section{Wellordering}{3}

so \l@chapter and friends are the macros that need tweaking. Here, I made them produce output suitable for going into an \halign construct.

From these ideas, you may be able to produce something similar for your preferred layout. You will need to alter the \chapter command to also include author information in its call to \addcontentsline, and of course \l@chapter must be able to pick this information out of its two argument. Easy solution: Let the first argument have the form {chapter title}{author info} and use an auxiliary macro to tease the bits apart.

Disclaimer: It's years since I wrote that code. My understanding of it has very likely deteriorated.

You must log in to answer this question.

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