1

Taking the following minimum working example:

\documentclass{memoir}
\begin{document}
\tableofcontents
\part{first part}
\chapter{first chapter}
\part{second part}
\chapter{second chapter}
\part{third part}
\chapter{third chapter}
\part{fourth part}
\chapter{fourth chapter}
\part{fifth part}
\chapter{fifth chapter}
\part{sixth part}
\chapter{sixth chapter}
\part{seventh part}
\chapter{seventh chapter}
\part{eighth part}
\chapter{eighth chapter}
\end{document}

we get very ugly output for the \part entries:

already quite bad

really bad

Of course it is possible to increase the size of the box for the part number by \renewcommand\cftpartnumwidth{1cm} or something like that, but I wonder if that should really be necessary?

  • 2
    This is a natural effect of using Roman numbers -- they are not really fitted to be used with 'large' numbers because the typeset representation gets too wide... Your way with \renewcommand{\cftpartnumwidth}{...} is one way to go or \addtolength{\cftpartnumwidth}{1cm} is perhaps even better, i.e. increasing it in addition to the length it already has. This behaviour is no bug, but by design – user31729 Dec 24 '18 at 14:31
  • 2
    As Christian explains this this the normal behavior. I do have code that can adjust this automatically, but that is not always what you want. Your method is the one generally recommended in menoir – daleif Dec 24 '18 at 14:35
  • So, your issue here is not with changing it, but as to why the default is so small? I guess if you change the default to accommodate VIII as the default, you'll have people wanting it narrower. The good thing is there's a hook that allows you to change it to suit your needs. – Werner Dec 24 '18 at 18:24
1

It could, with some unknown LaTeX coding, be done by, for instance measuring the width of each number before printing and then ensuring that there is enough space for the printed number. This would then mean that instead of the title texts being aligned vertically they would be ragged left depending on the particular number. You might be happy with this but I doubt that many others would be. With even more complicated coding involving a two-pass system the maximum number width could be determined and then applied to all entries to give aligned title texts.

Decide what you want your ToC to look like in the end, try some code and then ask again.

Remember, I'm a GOM (Grumpy Old Man).

| improve this answer | |
1

It depends on whether you want the part titles to be aligned or you just want the number be separated from the title by a normal space.

Aligned titles

\documentclass{memoir}
\usepackage{totcount}

\regtotcounter{part}
\newlength{\partnumberwidth}
\makeatletter
\AtBeginDocument{\measure@part@numbers}
\newcommand{\measure@part@numbers}{%
  \count@=0
  \loop\ifnum\count@<\totvalue{part}
    \advance\count@ by 1
    \settowidth{\dimen@}{\bfseries\@Roman{\count@}\ \ }%
    \ifdim\dimen@>\partnumberwidth
      \setlength{\partnumberwidth}{\dimen@}%
    \fi
  \repeat
}
\renewcommand\partnumberlinehook[1]{%
  \setlength{\@tempdima}{\partnumberwidth}%
}
\makeatother

\begin{document}
\tableofcontents
\part{first part}
\chapter{first chapter}
\part{second part}
\chapter{second chapter}
\part{third part}
\chapter{third chapter}
\part{fourth part}
\chapter{fourth chapter}
\part{fifth part}
\chapter{fifth chapter}
\part{sixth part}
\chapter{sixth chapter}
\part{seventh part}
\chapter{seventh chapter}
\part{eighth part}
\chapter{eighth chapter}
\end{document}

enter image description here

Normal space

\documentclass{memoir}

\makeatletter
\renewcommand\partnumberlinehook[1]{%
  \settowidth{\@tempdima}{\bfseries #1 }%
}
\makeatother

\begin{document}
\tableofcontents
\part{first part}
\chapter{first chapter}
\part{second part}
\chapter{second chapter}
\part{third part}
\chapter{third chapter}
\part{fourth part}
\chapter{fourth chapter}
\part{fifth part}
\chapter{fifth chapter}
\part{sixth part}
\chapter{sixth chapter}
\part{seventh part}
\chapter{seventh chapter}
\part{eighth part}
\chapter{eighth chapter}
\end{document}

enter image description here

| improve this answer | |

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.