# Modify a \part entry in ToC with memoir

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}{}{}{}

\begin{document}
\tableofcontents

\chapter{Introduction}
\lipsum

\part{Basics}

\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?

-

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
\makeatother
\renewcommand{\cftpartafterpnum}{\par\vspace{-1.5ex}\hskip -\memRTLleftskip\hrulefill}


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


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

-
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