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 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!

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
Wow, really nice!! Thank you :-) –  strauberry Sep 4 '12 at 18:28
    
@strauberry You're welcome! I've updated my answer with some improvement (now the rule spans the whole text width). –  Gonzalo Medina Sep 4 '12 at 18:37
    
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 Dec 29 '13 at 16:52
add comment

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.