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 change how a "Part" title appears in the Table of Contents of a memoir document. In particular, I'd like to have the "Part Title" between two lines. Take the following minimal example:

\documentclass[b5paper,10pt,twoside,openright,final,english]{memoir}
\usepackage{lipsum}
\usepackage[english]{babel}

\makepagestyle{part}
\makeevenfoot{part}{}{}{}
\makeoddfoot{part}{}{}{}
\makeevenhead{part}{}{}{}
\makeoddhead{part}{}{}{}

\begin{document}
\tableofcontents

\chapter{Introduction}
\lipsum

\addtocontents{toc}{\protect\mbox{}\protect\hrulefill\par}
\part{Basics}
\addtocontents{toc}{\protect\mbox{}\protect\hrulefill\par}

\chapter{A Chapter}
\lipsum

\end{document}

How can I force the lines in the Table of Contents to be longer and change the distance within the "Part" title?

share|improve this question

2 Answers 2

This way you can change the distance before the part entry:

\setlength{\cftbeforepartskip}{1ex}

And to fill to whole line, make a skip to the left:

\addtocontents{toc}{\hskip -\memRTLleftskip\protect\mbox{}\protect\hrulefill\par}

Here's a definition which does it once for all parts:

\setlength{\cftbeforepartskip}{0pt}
\makeatletter
\g@addto@macro{\cftpartbreak}{\hskip -\parindent\hrulefill\par}
\makeatother
\renewcommand{\cftpartafterpnum}{\par\vspace{-1.5ex}\hskip -\memRTLleftskip\hrulefill}

parts entries with lines

share|improve this answer
    
Thanks for your answer. Now I got how to change the length, however the second command does not seem to work. In fact, I would like the horizontal lines to start at same place where "I" appears in the ToC, whereas they start at "Basics" –  Daniele Jan 27 '12 at 14:35
    
@Daniele I updated my answer. –  Stefan Kottwitz Jan 27 '12 at 15:02

Working from Stefan's answer, if you want lines before and after the part title, the following would work:

\renewcommand{\cftpartafterpnum}{\par %
\vspace{-2\baselineskip} \hskip -\memRTLleftskip\protect\mbox{}\protect\hrulefill\par%
\vspace{0.5\baselineskip} \hskip -\memRTLleftskip\protect\mbox{}\protect\hrulefill\par}

enter image description here

See section 9.2 of memman.pdf for more information about \cftpartafterpnum and related commands.

share|improve this answer
    
Works perfectly! Thanks –  Daniele Jan 27 '12 at 14:41
    
I just found that if I also use the \cftpagenumbersoff{part} command (so that the page number where the part starts does not appear in the ToC) the two lines will be shorter! Is it possible to let them go until the end of the line, even when \cftpagenumbersoff{part} is used? –  Daniele Jan 27 '12 at 15:09

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.