5

I am using the memoir class to generate a book manuscript. The table of contents entry for Part VIII overlaps with the part title which is Examinations. The result is shown below:

TOC overlap

Is there a way to avoid or correct this?

Note that there is no problem on the actual page itself denoting that part; only in the TOC.

memoir seems to use Roman numerals as default for parts. I have not found a way to change part numbering to alphabetic, which might be a sensible workaround.

1

4 Answers 4

7

You can change the width of the number in the TOC using the \cftpartnumwidth length. See Chapter 9 of the memoir manual. Alternatively, you can redefine \thepart to use uppercase alphabetic numbering (as in Werner's answer).

\documentclass{memoir}
\setlength{\cftpartnumwidth}{4em} % change the width of the part number
%\renewcommand{\thepart}{\Alph{part}} % change part numbering to Alphabetic
\begin{document}
\tableofcontents
\setcounter{part}{21}

\part{A part}
\chapter{A chapter}
\part{Another part}
\chapter{A chapter}
\end{document}

output of code

5

Teaser: In current memoir, there is some undocumented hooks into the TOC macros, such that it is able to record the widest chapter, section etc. number part in the TOC. (Cannot remember if I added a hook for part as well). If used correctly this can be used to automatically adjust the sizes of the number boxes in the TOC such that manual intervention is not needed (just a few extra compilations). I've used it successfully in a few projects. In the future I may add some features to utilize these hooks. (problem is that their use depend on the design of the TOC, so a general solution may be a bit difficult))

4

If changing to (uppercase) alphabetic numbering for parts solves your problem, then the following is all you need in your document preamble:

\renewcommand{\thepart}{\Alph{part}}
0
1

By default, the box that contains the part number has fixed width, but we can change that. Using a dynamic box with prescribed minimum width, like the one provided in this answer, we can automatically move the part title to the right if the part number doesn't fit in the designated space.

The following code puts the part number inside a box whose size is either the default size (which aligns with other entries in the ToC) or the size needed to typeset the part number and a single space, whichever is larger.

\newcommand*{\minwidthbox}[2]{\makebox[{\ifdim#1<\width\width\else#1\fi}][l]{#2}}
\renewcommand*{\partnumberlinebox}[2]{\minwidthbox{#1}{#2\space}}

(\space is a basic LaTeX macro which expands to a single space. You may replace it with some other horizontal space as you see fit.)

The resulting ToC will look something like this (vertical line added in GIMP for clarity):

example ToC

To reproduce this example:

\documentclass{memoir}

\chapterstyle{crosshead}
\newcommand*{\minwidthbox}[2]{\makebox[{\ifdim#1<\width\width\else#1\fi}][l]{#2}}
\renewcommand*{\partnumberlinebox}[2]{\minwidthbox{#1}{#2\space}}

\begin{document}
\vspace*{-2cm}
\tableofcontents*
\part{Narrow Roman numeral -- title aligned with chapters}
\chapter{Chapter}
\section{Section}
\chapter{Chapter}

\part{Narrow Roman numeral -- title aligned with chapters}
\chapter{Chapter}
\section{Section}
\chapter{Chapter}

\part{Wider Roman numeral -- title separated by space}
\chapter{Chapter}
\section{Section}
\chapter{Chapter}

\part{Wider Roman numeral -- title separated by space}
\chapter{Chapter}
\section{Section}
\chapter{Chapter}

\part{Narrow Roman numeral -- title aligned with chapters}
\chapter{Chapter}
\section{Section}
\chapter{Chapter}

\setcounter{part}{7}
\part{Very wide Roman numeral -- title separated by space}
\chapter{Chapter}
\section{Section}
\chapter{Chapter}

\end{document}

You must log in to answer this question.

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