0

In a previous question, TKO successfully formatted memoir \frontmatter \chapters (in this case Foreword and Abstract) differently to \mainmatter items in a \tableofcontents:

\documentclass{memoir}

\setlength{\cftbeforechapterskip}{4pt}
\renewcommand*{\cftchapterfont}{\itshape}

\cftinsertcode{SPECIALTOC}{%
  \renewcommand*{\cftchapterfont}{\bfseries}%
  \setlength{\cftbeforechapterskip}{16pt}%
}
\begin{document}

\tableofcontents

\chapter*{Foreword}
\addcontentsline{toc}{chapter}{Foreword}
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}

\cftinserthook{toc}{SPECIALTOC}

\chapter{Chapter One}
\section{Section One One}
\section{Section One Two}

\chapter{Chapter Two}
\section{Section Two One}

\chapter{Chapter Three}
\section{Section Three One}
\section{Section Three Two}
\section{Section Three Three}

\end{document}

But how can we apply this to other \frontmatter items (such as \tableofcontents, \listoffigures or \listoftables) and to \backmatter items (such as \printpagenotes, \printbibliography or \printindex)?

\documentclass{memoir}

\setlength{\cftbeforechapterskip}{4pt}
\renewcommand*{\cftchapterfont}{\itshape}

\cftinsertcode{SPECIALTOC}{%
  \renewcommand*{\cftchapterfont}{\bfseries}%
  \setlength{\cftbeforechapterskip}{16pt}%
}
\begin{document}

\tableofcontents

\frontmatter
\tableofcontents % apply to this toc entry
\listoffigures % apply to this toc entry
\listoftables % apply to this toc entry
\chapter*{Foreword} % apply to this toc entry
\addcontentsline{toc}{chapter}{Foreword}
\chapter*{Abstract} % apply to this toc entry
\addcontentsline{toc}{chapter}{Abstract}

\cftinserthook{toc}{SPECIALTOC}

\mainmatter
\chapter{Chapter One}
\section{Section One One}
\section{Section One Two}

\chapter{Chapter Two}
\section{Section Two One}

\chapter{Chapter Three}
\section{Section Three One}
\section{Section Three Two}
\section{Section Three Three}

\backmatter
\printpagenotes % apply to this toc entry
\printbibliography % apply to this toc entry
\printindex % apply to this toc entry

\end{document}
  • There are some issues with your sample doc. Under \frontmatter there is no need for the \chapter* + \addcontentsline combo, as that it de default for \chapter under \frontmatter. You just need more \cftinserthook{toc}{NAME}'s have a look in the .toc file then you'll have a better idea of what it is doing. Also, are you sure you want the toc in the toc? I'd just use \tableofcontents* – daleif Mar 31 at 11:10
  • Very true, thanks @daleif. The combo slipped my mind when copying in TKO's original MWE. I have now incorporated your comments in my answer below. – TeXomat Mar 31 at 11:39
0

Turns out you just have to define another hook for \backmatter:

\documentclass{memoir}

\setlength{\cftbeforechapterskip}{4pt}
\renewcommand*{\cftchapterfont}{\itshape}
\cftinsertcode{mainmattertoc}{%
    \renewcommand*{\cftchapterfont}{\normalsize\normalfont}%
    \setlength{\cftbeforechapterskip}{8pt}%
}
\cftinsertcode{backmattertoc}{%
    \renewcommand*{\cftchapterfont}{\itshape}%
    \setlength{\cftbeforechapterskip}{4pt}
}
\begin{document}

\frontmatter
\listoffigures % apply to this toc entry
\listoftables % apply to this toc entry
\chapter{Foreword} % apply to this toc entry
\chapter{Abstract} % apply to this toc entry

\cftinserthook{toc}{mainmattertoc}

\mainmatter
\chapter{Chapter One}
\chapter{Chapter Two}
\chapter{Chapter Three}

\cftinserthook{toc}{backmattertoc}

\backmatter
\printpagenotes % apply to this toc entry
\printbibliography % apply to this toc entry
\printindex % apply to this toc entry

\end{document}
| improve this answer | |
  • BTW: I hardly ever use the \backmatter command, I see no need to disable numbering once again. But wanting to change the things you want to change there is quite common – daleif Mar 31 at 11:41

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.