1

I would like to adapt the style and content of my ToC, but I'ma little bit stuck with the tocloft package ^^ e.g., how to set the horizontal ruler? Do I change the command that is used in the ToC or do I add this in my latex document? (see page 5 "To add a horizontal line across the whole width of the ToC below an entry for a Part:...")

It should look like this:

CHAPTER N

Title of my chapter


N.M Title of my section .......... pagenumber

N.M Title of my section .......... pagenumber

Variation:

Chapter N | Title of my chapter


N.M Title of my section .......... pagenumber

N.M Title of my section .......... pagenumber

Additionally, I would like to change the font family of the chapters within the ToC and the document itself, as well.

Thank you very much!

1 Answer 1

6

Here's one possible solution (feel free to adapt it according to your needs); the tocloft package was used to change the formatting for chapter entries in the ToC and the sectsty package was used to change the formatting for chapter headings in the document:

\documentclass{book}
\usepackage{sectsty}
\usepackage{tocloft}
\usepackage{lipsum}

\newlength\mylen

\renewcommand\cftchappresnum{\chaptername~}
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylen}

\renewcommand\cftchapaftersnumb{\\\hspace*{\dimexpr-\mylen-1.5em\relax}}
\addtocontents{toc}{\cftpagenumbersoff{chapter}}

\makeatletter
\renewcommand{\@tocrmarg}{0em}
\renewcommand\cftchapafterpnum{%
  \par\vskip-1ex\hspace*{\dimexpr-\mylen-1.5em\relax}\hrulefill\par}
\makeatother

\renewcommand\cftchapfont{\sffamily}
\chapterfont{\sffamily}

\begin{document}
\tableofcontents

\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
\chapter{Test Chapter Two}
\section{Test Section Two One}
\section{Test Section Two Two}

\end{document}

enter image description here

1
  • 1
    I tried to adapt your code, but I'm kind of lost :-( I searched the documentation at ctan.org/pkg/tocloft, but can't find explanations for the commands like cftchapaftersnumb. Now I would like to write "Chapter x" in normal font, followed by a "|" and the chapter name in bold, without a new line. How can I access the chapter name?
    – strauberry
    Commented Dec 29, 2013 at 16:52

You must log in to answer this question.

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