Is it possible to get it without using package titletoc
? I'm using special chapter style which doesn't work with this package.
[Tex/LaTex] How to change spaces between items in Table of Contents
line-spacingtable of contents
Related Solutions
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:
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}
Since you're using the book
class, I presume that everything in the front matter is intended to be under the plain
pagestyle:
\documentclass[a4paper,oneside]{book}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{lipsum} % just for the example
\pagestyle{fancy}
\fancypagestyle{main}{%
\fancyhf{}%
\fancyhead[C]{\slshape\leftmark}%
\fancyfoot[C]{\thepage}%
\renewcommand{\headrulewidth}{0.4pt}%
\renewcommand{\footrulewidth}{0.4pt}%
}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.4pt}%
}
\appto\frontmatter{\pagestyle{plain}}
\appto\mainmatter{\pagestyle{main}}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
%%% fill with some mock text
\def\testsec{\section{B}\lipsum}
\def\test{\chapter{A}
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
}
\test
\test
\test
\test
\test
\test
\test
\test
\end{document}
However, I'd recommend against the footrule.
Best Answer
There are so many options... without further information, one possible option would be to use the
setspace
package and one of its commands of environments; for example,This approach will increase evenly the space between all sectional units. The following three options allow you to control separately the spacing for each group of sectional units.
Another option would be to use the
tocloft
package and redefine the\cftXafterpnum
family of commands:Yet another option, this time using the
etoolbox
package to patch the sectional units commands to add vertical space to the ToC:A fourth option not requiring any packages would be to redefine the
\chapter
and\section
commands as implemented in the used document class to add the vertical space to the ToC; an example withreport
: