Page LayoutMemoir Class, toc formatting part II

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
twesslen
Posts: 6
Joined: Thu Feb 03, 2011 9:17 pm

Memoir Class, toc formatting part II

Post by twesslen »

I am still trying to tweak my table of contents in my memoir class formatted thesis and am running into a peculiar problem. I have added

Code: Select all

\renewcommand{\cftchaptername}{\hspace{1.5em}}
to shift the chapters over and center the chapter number under the heading Contents as in the "Centered" picture that is attached. I want the same spacing for my appendix sections as well, but somehow it does not get passed down to the \chapter{...} lines in the appendix. Without the line above, the body chapter lines are left aligned as in the picture "Left Aligned".
Centered
Centered
Centered.jpg (45.79 KiB) Viewed 4677 times
Left Aligned
Left Aligned
Left Aligned.jpg (42.99 KiB) Viewed 4677 times

A MWE is

Code: Select all


\documentclass{memoir}


\renewcommand{\cftchaptername}{\hspace{1.5em}}


\begin{document}
\maxtocdepth{subsubsection}
\tableofcontents

\chapter{Chapter One}
\section{Section A}
\section{Section B}
\subsection{Subsection a}
\subsection{Subsection b}

\chapter{Chapter Two}
\section{Section A}
\section{Section B}
\section{Section C}

\appendix
\chapter{First Appendix Chapter}


\end{document}

Seems like there should be something simple to do in order to get this to work for the appendices as well. Anyone know how to do it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Memoir Class, toc formatting part II

Post by meho_r »

I wouldn't use cftchaptername for that. Instead, try something like this (might seem like an overkill, but hopefully will help you in your further work).

Code: Select all

\documentclass{memoir}

\newlength{\mylen}% New length to use when setting indentation

\settowidth{\mylen}{\large\bfseries Contents}% Sets mylen to width of word “Contents”, large and bold

\cftsetindents{chapter}{0pt}{\mylen}% Sets indent and numwidth for chapters
\renewcommand{\cftchapterpresnum}{\hfill}% Typesets \hfill before the chapter number
\renewcommand{\cftchapteraftersnum}{\hfill}% Typesets \hfill after the chapter number
\renewcommand{\cftchapteraftersnumb}{\hspace{-1em}}% Typesets negative horizontal space before the title

\cftsetindents{section}{0pt}{\mylen}% Sets indent and numwidth for sections
\renewcommand{\cftsectionpresnum}{\hfill}
\renewcommand{\cftsectionaftersnum}{\hfill}
\renewcommand{\cftsectionaftersnumb}{\hspace{-1em}}

\newlength{\subseclen}% We’ll define a new length for subsections, so that we don’t have to change mylen

\setlength{\subseclen}{\mylen}% Sets subseclen to the same width as mylen
\addtolength{\subseclen}{-1em}% To align subsections with sections, use the value of \hspace from \cftsectionaftersnumb above, i.e., in this case it’s -1em to subtract it from subseclen
\cftsetindents{subsection}{\subseclen}{\mylen}% Sets indent and numwidth for subsections

\begin{document}

\maxtocdepth{subsubsection}

\tableofcontents

\chapter{Chapter One}
\section{Section A}
\section{Section B}
\subsection{Subsection a}
\subsection{Subsection b}

\chapter{Chapter Two}
\section{Section A}
\section{Section B}
\section{Section C}

\appendix

\chapter{First Appendix Chapter}

\end{document}

Post Reply