0

I'm using the Memoir class and I'm trying to format the table of contents for a document I'm working on. Currently, the ToC arranges entries in the following way:

<<chapter name>> <<chapter number>> <<chapter title>>

E.g.

Chapter 1 Introduction
Appendix A Specifications

I'd prefer if chapter entries were formatted like this:

<<chapter name>> <<chapter number>>
<<chapter title>>

E.g.

Chapter 1
Introduction

Appendix A
Specifications

I've looked through the Memoir manual but haven't managed to find anything that's proved helpful yet.

EDIT

Added MWE and image:

\documentclass[openany]{memoir}
\usepackage{memsty}

\renewcommand*{\cftchaptername}{\chaptername\space}
\renewcommand*{\cftappendixname}{Appendix\space}

\begin{document}
\tableofcontents

\chapter{Foo}

\section{Bar}

\chapter{Baz}

\appendix
\chapter{Misc}

\end{document}

  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Aug 4 '14 at 9:08
  • Sure thing, added. – Tagc Aug 4 '14 at 9:19
  • You should not be using memsty, it is only for building the memoir manual. – daleif Aug 4 '14 at 9:55
1

It is not in the manual as it might not be that common, plus it is not that easy to do with a simple configuration. Here is a suggestion

\makeatletter
\renewcommand*{\l@chapapp}[3]{%
  \ifnum \c@tocdepth >\m@ne
    \cftchapterbreak
    \vskip \cftbeforechapterskip
    {%\leftskip \cftchapterindent\relax
     \memRTLleftskip \cftchapterindent\relax
%%%     \rightskip \@tocrmarg
     \memRTLrightskip \@tocrmarg
%%%     \parfillskip -\rightskip
     \parfillskip -\memRTLrightskip
     \parindent \cftchapterindent\relax
     \@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \let\@cftbsnum \cftchapterpresnum
     \let\@cftasnum \cftchapteraftersnum
     \let\@cftasnumb \cftchapteraftersnumb
     \def\@chapapp@head{#3}%
     \settowidth{\@tempdima}{\cftchapterfont\@chapapp@head}%
     \addtolength{\@tempdima}{\cftchapternumwidth}%
     %% this line have to be out commented
     %\advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
     {\cftchapterfont {#1}}\nobreak
     \cftchapterfillnum{#2}}
  \fi}
\makeatother
\renewcommand\cftchapteraftersnumb{\par}

We basically need \l@chapapp (which typesets chapters and appendices in the ToC) to stop increasing the left margin


Addition:

You can add \nopagebreak, but IMO the best solution is to make the length \cftbeforechapterskip more flexible. By default \cftbeforechapterskip is not that flexible. So I usually use something similar to

\setlength{\cftbeforechapterskip}{1.0em plus 0.2em minus 0.3em}

i.e., it can stretch some and shrink some. That leads to better results.

BTW: you might also want to use

\setlength\parskip{0pt}

in order to kill of any stretch between paragraphs over all in the document.

  • Thanks, that seems to work pretty well. A lot of it is over my head so I have to ask how I could modify that to change the space between the two lines, if that's possible. – Tagc Aug 4 '14 at 10:23
  • Got it, nevermind. Changed {\cftchapterfont {#1}}\nobreak to {\vspace{<<X>>}\cftchapterfont {#1}}\nobreak Thanks again for the help. – Tagc Aug 4 '14 at 10:33
  • Why, you can just add that to \cftchapteraftersnumb – daleif Aug 4 '14 at 11:06
  • I'm not sure how you mean. I tried adding \renewcommand\cftchapteraftersnumb{\vspace{<<X>>}} immediately before the code you provided and that didn't seem to have an effect on the spacing. – Tagc Aug 4 '14 at 11:31
  • \renewcommand\cftchapteraftersnumb{\par\vspace{1em}} – daleif Aug 4 '14 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.