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'm trying to get chapters and sections to line up in a memoir ToC as:

Chapter one        Chapter title
                   Section title
                   Another section
                   A third section

Chapter two        Second chapter title 
                   Another etc.

I really can't fathom the pseudo code on p.158 of the manual but I've tried setting widths for \cftpartnumwidth and \cftchapternumwidth but I can't get these boxes to work. My code:

% part
\cftpagenumbersoff{part}
\setlength{\cftpartnumwidth}{4.0cm}

% chapter
\setlength{\cftchapternumwidth}{4.0cm}
\renewcommand*{\cftchaptername}{Chapter\space}
\renewcommand*{\cftchapteraftersnum}{\hfill}
\renewcommand*{\chapternumberline}[1]{\cftchaptername \numtoname #1  \cftchapteraftersnum}

% section
\setlength{\cftsectionnumwidth}{4.0cm}

I can control the section title placement, but something is breaking the chapter title placement (I presume the renewal definition of \cftchapteraftersnum.

Can anyone give me the spell? thanks

============================== UPDATE:

I modified the code with Gonzalo's suggestion to:

\newlength\mylen
\settowidth\mylen{\bfseries\chaptername\hspace{3em}}

% part
\cftpagenumbersoff{part}
\addtolength\cftpartnumwidth{\mylen}

% chapter
\addtolength\cftchapternumwidth{\mylen}
\renewcommand\cftchapterpresnum{\chaptername~} 

% section
\renewcommand\cftsectionindent{\dimexpr\mylen+1.5em\relax}

But it gives this: enter image description here

The "Sections" are not lining up with the "Chapters"...

share|improve this question
    
Does your diagram mean that sectional unit numbering must be suppressed? –  Gonzalo Medina May 12 '12 at 22:29
    
Yes. And I alsop need to add "Part" –  Richard May 13 '12 at 0:50
    
please see my updated answer. –  Gonzalo Medina May 13 '12 at 1:37
add comment

1 Answer

up vote 6 down vote accepted

The following code does what you want (change the value of the length \chapind according to your needs):

\documentclass{memoir}

\newlength\chapind
\setlength\chapind{2.8cm}% change according to your needs

\cftpagenumbersoff{part}
\setlength{\cftpartnumwidth}{\chapind}

\renewcommand*{\chapternumberline}[1]{%
\parbox[t]{\chapind}{\chaptername~\numtoname#1\cftchapteraftersnum}%
}

\renewcommand\cftsectionindent{\dimexpr\chapind-2.1em\relax}
\makeatletter
\def\cftsectionpresnum #1\@cftasnum{}
\makeatother

\begin{document}

\tableofcontents*

\part{Test Part One}
\chapter{Test Chapter One}
\section{Section One One}
\section{Section One Two}
\section{Section One Three}

\part{Test Part Two}
\chapter{Test Chapter Two}
\section{Section Two One}
\section{Section Two Two}
\section{Section Two Three}

\end{document}

enter image description here

share|improve this answer
    
Thanks Gonzalo but I don't quite understand why it's still not working. I omitted to point out I need "Parts" as well, with the Part number aligning on the left margin and the part titles aligning with the chapter and section titles. I don't know how to post my code and the resulting file on here - I apologise. –  Richard May 13 '12 at 0:48
    
@Richard: simply saying "it's not working" is useless. Please edit your original question with a minimal document showing the current settings relevant to this issue and perhaps including my code and illustrating the problems you are having. –  Gonzalo Medina May 13 '12 at 0:50
    
I'm doing my best. I have never used this facility before and the editing process is confusing. I tried to enter it in this box and it only gave me 500 characters, which wasn't enough to post the code, and nowhere to put a screenshot. –  Richard May 13 '12 at 1:02
    
@Richard: that's why I said that you should add an edit to your original question. –  Gonzalo Medina May 13 '12 at 1:04
    
Well I was busy editing the original question while you were saying it. Anyway, I appreciate your help - thank you. –  Richard May 13 '12 at 1:09
show 3 more comments

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.