我正在尝试将目录格式化为使用两行居中条目,并使用序数表示部分和章节编号。条目也应该是超链接。我设法将Simon Dispa 的回答编辑章节daleif 的完全不同的作品编辑各部分以获得看起来相当不错的效果,但缺少序号和超链接。此外,最好删除各部分的页码。
当我尝试在 的重新定义中fmtcount
使用时,出现错误。当我加载部分的格式时,条目会崩溃。\Ordinalstringnum
\partnumberline
hyperref
\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}
答案1
据我理解,这似乎可以完成部分工作,我必须将自己的罗马数字转换为文本,因为fmtcounter
期望的是数字而不是字母。
(编辑:更简单的助手)
\ExplSyntaxOn
\NewDocumentCommand\RomanToText{m}{\Ordinalstringnum{\int_from_roman:n {#1}}}
\ExplSyntaxOff
\makeatletter
\renewcommand\partnumberline[1]{\RomanToText{#1}~part\par}
\renewcommand\cftpartfont{\par\centering}% the starting \par is needed
\cftpagenumbersoff{part}
\usepackage{etoolbox}
\patchcmd\l@part{%
\cftpartfont {#1}%
}{%
\cftpartfont #1\par%
}{\typeout{l@part patched}}{\typeout{l@part patch failed}}
\makeatother