6

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"...

3
  • Does your diagram mean that sectional unit numbering must be suppressed? May 12, 2012 at 22:29
  • Yes. And I alsop need to add "Part"
    – Richard
    May 13, 2012 at 0:50
  • please see my updated answer. May 13, 2012 at 1:37

1 Answer 1

6

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

8
  • 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, 2012 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. May 13, 2012 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, 2012 at 1:02
  • @Richard: that's why I said that you should add an edit to your original question. May 13, 2012 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, 2012 at 1:09

You must log in to answer this question.

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