在一个上一个问题,TKO 成功格式化memoir
\frontmatter
\chapters
(在本例中Foreword
为 和),与中的项目Abstract
不同:\mainmatter
\tableofcontents
\documentclass{memoir}
\setlength{\cftbeforechapterskip}{4pt}
\renewcommand*{\cftchapterfont}{\itshape}
\cftinsertcode{SPECIALTOC}{%
\renewcommand*{\cftchapterfont}{\bfseries}%
\setlength{\cftbeforechapterskip}{16pt}%
}
\begin{document}
\tableofcontents
\chapter*{Foreword}
\addcontentsline{toc}{chapter}{Foreword}
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\cftinserthook{toc}{SPECIALTOC}
\chapter{Chapter One}
\section{Section One One}
\section{Section One Two}
\chapter{Chapter Two}
\section{Section Two One}
\chapter{Chapter Three}
\section{Section Three One}
\section{Section Three Two}
\section{Section Three Three}
\end{document}
但是,我们如何将其应用于其他\frontmatter
项目(例如\tableofcontents
,\listoffigures
或\listoftables
)以及\backmatter
项目(例如\printpagenotes
,\printbibliography
或\printindex
)?
\documentclass{memoir}
\setlength{\cftbeforechapterskip}{4pt}
\renewcommand*{\cftchapterfont}{\itshape}
\cftinsertcode{SPECIALTOC}{%
\renewcommand*{\cftchapterfont}{\bfseries}%
\setlength{\cftbeforechapterskip}{16pt}%
}
\begin{document}
\tableofcontents
\frontmatter
\tableofcontents % apply to this toc entry
\listoffigures % apply to this toc entry
\listoftables % apply to this toc entry
\chapter*{Foreword} % apply to this toc entry
\addcontentsline{toc}{chapter}{Foreword}
\chapter*{Abstract} % apply to this toc entry
\addcontentsline{toc}{chapter}{Abstract}
\cftinserthook{toc}{SPECIALTOC}
\mainmatter
\chapter{Chapter One}
\section{Section One One}
\section{Section One Two}
\chapter{Chapter Two}
\section{Section Two One}
\chapter{Chapter Three}
\section{Section Three One}
\section{Section Three Two}
\section{Section Three Three}
\backmatter
\printpagenotes % apply to this toc entry
\printbibliography % apply to this toc entry
\printindex % apply to this toc entry
\end{document}
答案1
事实证明你只需要定义另一个钩子\backmatter
:
\documentclass{memoir}
\setlength{\cftbeforechapterskip}{4pt}
\renewcommand*{\cftchapterfont}{\itshape}
\cftinsertcode{mainmattertoc}{%
\renewcommand*{\cftchapterfont}{\normalsize\normalfont}%
\setlength{\cftbeforechapterskip}{8pt}%
}
\cftinsertcode{backmattertoc}{%
\renewcommand*{\cftchapterfont}{\itshape}%
\setlength{\cftbeforechapterskip}{4pt}
}
\begin{document}
\frontmatter
\listoffigures % apply to this toc entry
\listoftables % apply to this toc entry
\chapter{Foreword} % apply to this toc entry
\chapter{Abstract} % apply to this toc entry
\cftinserthook{toc}{mainmattertoc}
\mainmatter
\chapter{Chapter One}
\chapter{Chapter Two}
\chapter{Chapter Three}
\cftinserthook{toc}{backmattertoc}
\backmatter
\printpagenotes % apply to this toc entry
\printbibliography % apply to this toc entry
\printindex % apply to this toc entry
\end{document}