1

I have a memoir document with custom TOC spacing:

\documentclass[oneside]{memoir}

\renewcommand{\cftchapteraftersnum} {\quad}
\renewcommand{\cftchapterdotsep}    {\cftsectiondotsep}
\renewcommand{\cftchapterfont}      {\cftsectionfont}
\renewcommand{\cftchapterleader}    {\cftsectionleader}
\renewcommand{\cftchapterpagefont}  {\cftsectionpagefont}
\renewcommand{\cftchapterpresnum}   {\hfill}
\setlength   {\cftbeforechapterskip}{0.5em}
\setlength   {\cftchapternumwidth}  {10em}

\begin{document}
\frontmatter

\chapter{Preface}
\tableofcontents*

\mainmatter
\chapter{Alpha}
\chapter{Beta}
\end{document}

This generates a TOC like this:

enter image description here

I cannot find any memoir options to give non-numbered entries a space at the beginning so that I can line up the Preface entry with the numbered chapter names (i.e. Preface left-aligned with Alpha). Any way to do this?

1 Answer 1

0

Add the following lines after loading the memoir class.

\usepackage{xpatch}
\makeatletter
\xpatchcmd\@chapter
  {\addcontentsline{toc}{chapter}{\f@rtoc}}%
  {\addcontentsline{toc}{chapter}{\protect\chapternumberline{}\f@rtoc}}%
  {}%
  {}
\makeatother

This will handle only the preface. \chapter* headings in the main part are handled differently. For these, it is sufficient to add the line

\renewcommand\memchapstarinfo[2]{\addcontentsline{toc}{chapter}{\protect\chapternumberline{}#1}}

enter image description here

\documentclass[oneside]{memoir}
\usepackage{xpatch}
\makeatletter
\xpatchcmd\@chapter
  {\addcontentsline{toc}{chapter}{\f@rtoc}}%
  {\addcontentsline{toc}{chapter}{\protect\chapternumberline{}\f@rtoc}}%
  {}%
  {}
\makeatother
\renewcommand\memchapstarinfo[2]{\addcontentsline{toc}{chapter}{\protect\chapternumberline{}#1}}  
\renewcommand{\cftchapteraftersnum} {\quad}
\renewcommand{\cftchapterdotsep}    {\cftsectiondotsep}
\renewcommand{\cftchapterfont}      {\cftsectionfont}
\renewcommand{\cftchapterleader}    {\cftsectionleader}
\renewcommand{\cftchapterpagefont}  {\cftsectionpagefont}
\renewcommand{\cftchapterpresnum}   {\hfill}
\setlength   {\cftbeforechapterskip}{0.5em}
\setlength   {\cftchapternumwidth}  {10em}

\begin{document}
\frontmatter
\chapter{Preface}
\tableofcontents*

\mainmatter
\chapter{Alpha}
\section{Alpha 1}
\section{Alpha 2}
\chapter*{Beta}
\section{Beta 1}
\section{Beta 2}
\end{document}
3
  • Thanks. I guess memoir doesn't deal with this case specifically.
    – Roxy
    Jan 20, 2021 at 22:56
  • Actually, it turns out that this does not work for more than one entry. In my actual document, I have multiple non-numbered entries before and after the numbered entries. Could this solution be adapted for this more general situation?
    – Roxy
    Jan 21, 2021 at 6:52
  • @Roxy This is a different, easier story, see the extended answer.
    – gernot
    Jan 21, 2021 at 8:58

You must log in to answer this question.

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