[They] force the eye to walk the width of the page like a prisoner being escorted back to its cell (p.35)

He is not a fan. And nor am I. I'm trying to recreate the style that Bringhurst suggests on that same page. It has the following features:

• section titles ragged left.
• page numbers ragged right.
• between the two, a large-ish center dot.
• More or less centered toc.

Here's what I have so far:

\documentclass{article}
\usepackage{tocloft}
\usepackage{graphicx}
\newcommand\meddot{\scalebox{0.7}{\textbullet}}
\renewcommand\cftsecfont{\hfill}
\renewcommand\cftsecpagefont{\normalfont}
\renewcommand\cftsecafterpnum{\cftparfillskip}
\renewcommand\cftdot{}
\usepackage{lipsum}
\begin{document}
\tableofcontents

\section{One}
\lipsum
\section{Two and then some more words to make it long}
\lipsum
\section{Three}
\setcounter{page}{40}
\lipsum
\section{Quattro}
\lipsum
\end{document}


The current code's deficiencies are:

• The page numbers aren't ragged right. (adding \raggedright to \cftsecpagefont has not effect. Adding \flushleft breaks it. [Missing item error])
• The TOC isn't centred: it is too far left.

What I'd really like is a kind of tabular with three columns: section number, title and page number. And control over spacing and alignment of all three individually…

My question is, is piecemeal fiddling with tocloft the best way to achieve what I want? And if so, how do I achieve it. If it isn't the best way, what better options to I have for pleasing looking tables of contents?

-
Would a titletoc solution be valid for you? –  Gonzalo Medina Nov 9 '11 at 0:26

If I understand your requirements correctly, the following simple code will do (feel free to change the lengths and settings according to your needs):

\documentclass{article}
\usepackage{titletoc}
\usepackage{lipsum}

\titlecontents{section}
[0cm]{\raggedleft\parshape 1 1cm \dimexpr\linewidth-3cm\relax}
{\contentslabel{1.5em}}{}{\hspace{0.8em}\textbullet\hspace{0.8em}\makebox[1em][l]{\thecontentspage}}

\begin{document}
\tableofcontents

\section{One}
\lipsum
\section{Two and then some more words to make it long}
\lipsum
\section{Three}
\setcounter{page}{40}
\lipsum
\section{Quattro}
\lipsum
\end{document}


-
I'd totally forgotten about the titletoc package. I've used titlesec enough that I should have remembered this! This is certainly easier than the tocloft way… (at least for what I want) –  Seamus Nov 9 '11 at 11:19

Very nice, but I don't like centered toc at documents that does not use this kind of symmetry for, e.g., all headings. I like the style without page column used by typographers Willberg or Forssman at some of their books:

\documentclass{article}
\usepackage{tocstyle}
\usepackage[english]{babel}
\usepackage{blindtext}
\usetocstyle{nopagecolumn}
\settocfeature[toc][1]{entryhook}{\normalfont}% but with normal font

\iffalse% change to \iftrue, if you like a big fat dot
\usepackage{graphicx}
\newcommand\meddot{\scalebox{0.7}{\textbullet}}
\fi

\begin{document}
\tableofcontents
\blinddocument
\end{document}


And sometimes I even like to remove the section numbers at the toc:

\documentclass{article}
\usepackage{tocstyle}
\usepackage[english]{babel}
\usepackage{blindtext}
\usetocstyle{nopagecolumn}
\settocfeature[toc][1]{entryhook}{\normalfont}% but with normal font
\makeatletter
\renewcommand*{\tocstyle@@numberline}[1]{}% No section numbers
\makeatother

\begin{document}
\tableofcontents
\blinddocument
\end{document}

-
I think it would be worth mentioning that the tocstyle package is only at the alpha stage of development, and that the package causes a warning that includes the line Maybe it would be better, not to load this package. –  Seamus Nov 9 '11 at 11:17
@Seamus: It's alpha but unchanged for two years. IMHO it's very stable. I know the author of the package. He often declares packages alpha, if he don't like to spend a lot of time in manual and support. Nevertheless he gives support. Germans will find additional information about the package at komascript.de. Last but not least I'm sure you can do the same with other toc packages. I've used this one, because I use it often. Do you think, it'd be better not to show a source example but only a picture to illustrate my suggestion? –  Schweinebacke Nov 9 '11 at 12:36

Here a modification based on tocloft:

\documentclass{article}
\usepackage{tocloft}
\usepackage{graphicx}
\newcommand\meddot{\scalebox{0.7}{\textbullet}}
\makeatletter
\renewcommand*{\l@section}[2]{%
\ifnum \c@tocdepth >\z@
\if@cfthaschapter
\vskip \cftbeforesecskip
\else
\fi
{\leftskip \cftsecindent\relax
\rightskip \@tocrmarg
\parfillskip -\rightskip
\parindent \cftsecindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima \cftsecnumwidth\relax
\let\@cftbsnum \cftsecpresnum
\let\@cftasnum \cftsecaftersnum
\let\@cftasnumb \cftsecaftersnumb
\def\numberline##1{\mbox{}\llap{\makebox[\cftsecnumwidth][l]{##1}}}%
\null\nobreak\hskip \cftsecnumwidth%
\parbox[t]{.5\linewidth}{\cftsecfont #1}%
\cftsecfillnum{#2}}%
\fi}
\makeatother
\usepackage{lipsum}
\begin{document}
\tableofcontents

\section{One}
\lipsum
\section{Two and then some more words to make it long}
\lipsum
\section{Three}
\setcounter{page}{40}
\lipsum
\section{Quattro}
\lipsum
\end{document}


My result isn't the same as Gonzalo but I understand your question in such way.

EXPLANATION of the code

To modify an entry in the toc very often packages like tocloft or titlesec are recommended. Without using such a package the command \@dottedtocline is mentioned. In the following explanation I want to explain how to modify the toc without these commands.

First we take a simple example:

\documentclass{article}
\begin{document}
\tableofcontents
\section{foo}
\subsection{bar}
Text
\end{document}


\tableofcontents creates the Contents but the command also read the file \jobname.toc and evaluate the file. In the toc you will find the following line:

\contentsline {section}{\numberline {1}foo}{1}


You see the command \contentsline and three argument:

{section}    {\numberline {1}foo}     {1}


Before we speak about the argument have a closer look to the command \contentsline. The command is defined very simple in the file latex.ltx

\def\contentsline#1{\csname l@#1\endcsname}


You see that our toc-entry with the expanded command \contentsline is only:

\l@section{\numberline {1}foo}{1}


In the next step we will analyse the 2 argument of \l@section:

{\numberline {1}foo}{1}


It contains of the argument {\numberline {1}foo} and the page number {1}

In this way \l@section must be defined as a command which works with two arguments and either an external definition of \numberline or a definition inside \l@section. A simple example is:

• make the section number bold
• put a bullet between title and page number
• add the word page to the page number:

The modification can be done by

\renewcommand\l@section[2]{%
%Definition for the skip above
{\def\numberline##1{\textbf{##1}\ }%
\null #1\hfill\textbullet\hfill\mbox{page~#2}%
}\par%
}


The example no looks

\documentclass{article}
\makeatletter
\renewcommand\l@section[2]{%
%Definition for the skip above
{\def\numberline##1{\textbf{##1}\ }%
\null #1\hfill\textbullet\hfill\mbox{page~#2}%
}\par%
}
\makeatother
\begin{document}
\tableofcontents
\section{foo}
\subsection{bar}
Text
\end{document}


The result of your example is:

Note: The explanation is for every contentstype equivalent. In this way you can modify \l@subfigure or l@table.

-
This solution does look similar, but it's much harder to understand what's going on, and I don't understand the code well enough to know how to easily modify it. Gonzalo's solution has the advantage that it abstracts the messy details away. –  Seamus Nov 9 '11 at 11:13
@Seamus: Should I add some explanation? –  Marco Daniel Nov 9 '11 at 12:12
It might help. I'm guessing the \l@section is what's used to build each entry in the toc? For more finegrained control, it is obviously the right way to go to start modifying this directly, and it would help to know how to do that. –  Seamus Nov 9 '11 at 12:23
@Seamus: Now I need a proof reader ;-) –  Marco Daniel Nov 9 '11 at 13:00