I'm trying to format my table of contents to use two-line, centered entries with ordinal numbers for part and chapter numbers. The entries should also be hyperlinks. I have managed to string together an answer by Simon Dispa that edits the chapters with an altogether different one by daleif that edits the parts to achieve something that looks pretty nice, but lacks the ordinal part numbers and the hyperlinks. Also, it would be nice to get rid of the page numbers for the parts.
When I try to use fmtcount's \Ordinalstringnum in the redefinition of \partnumberline, I get an error. And when I load hyperref the formatting of the part entries fall apart.
\documentclass[oneside,11pt]{memoir}
\usepackage{fmtcount}
% \usepackage{hyperref}% Messes up the formatting
\renewcommand{\cftchapterfont}{}
\renewcommand{\cftchapterpagefont}{\cftchapterfont}
\renewcommand{\cftchapteraftersnum}{\ }
\renewcommand{\cftchapteraftersnumb}{\newline\normalfont}
\renewcommand{\cftchapterleader}{}
\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\renewcommand{\cftchapterleader}{\space—\space}
\renewcommand{\cftchapterfillnum}[1]{%
{\cftchapterleader}\nobreak%
{#1}%
\cftchapterafterpnum\par%
}
\makeatletter
\renewcommand*{\l@chapapp}[3]{%
\ifnum \c@tocdepth >\m@ne
\cftchapterbreak
\vskip\cftbeforechapterskip%
\centering%
{\memRTLrightskip0pt%
@afterindenttrue%
\interlinepenalty@M%
\leavevmode%
\let@cftbsnum\cftchapterpresnum
\let@cftasnum\cftchapteraftersnum%
\let@cftasnumb\cftchapteraftersnumb%
\def@chapapp@head{}%
{\cftchapterfont#1}\nobreak%
\cftchapterfillnum{#2}}%
\fi}
\renewcommand{\chapternumberline}[1]{%
\chapternumberlinehook{#1}%
\hb@xt@@tempdima{\hfil@chapapp@head@cftbsnum {\itshape\MakeLowercase{\Ordinalstringnum{#1} chapter}}@cftasnum\hfil}%
@cftasnumb}
\makeatother
\makeatletter
\renewcommand{\cftpartleader}{\space—\space}
\renewcommand{\cftpartfillnum}[1]{%
{\cftpartleader}\nobreak%
{#1}%
\cftpartafterpnum\par%
}
\setlength{\cftpartnumwidth}{0em}
\setlength{\cftpartindent}{0em}
\renewcommand\partnumberline[1]{%
\centering
\normalsize\bfseries Part~#1
\normalfont\bfseries
\par
}
\renewcommand*{\cftpartformatpnum}[1]{\enspace\textperiodcentered\enspace#1}
\usepackage{etoolbox}
% patch \l@part to remove some grouping
\patchcmd\l@part{%
{\cftpartfont {#1}}\cftpartfillnum{#2}%
}{%
#1\cftpartfillnum{#2}%
}{\typeout{patched}}{\FAILED}
\makeatother
\begin{document}
\frontmatter
\tableofcontents*
\chapter{Introduction}
\chapter{Preface}
\mainmatter
\part{The Beginning}
\chapter{Where It All Began}
\chapter{Some More Beginning}
\part{The Climax}
\chapter{Some Drawn-Out Diatribe}
\part{The End}
\chapter{Starting to Wrap Up}
\chapter{The Insightful Conclusion}
\backmatter
\chapter{Some notes}
\end{document}


\Ordinalstringnumfails as the arg is not a number it is a roman numerial – daleif Aug 08 '23 at 12:19hyperref– daleif Aug 08 '23 at 14:01