我正在使用此代码来定制我的章节标题:
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{%
\par
\needspace{10\onelineskip}
\vspace{\beforechapskip}
\mbox{}\\\mbox{}\rule[0pt]{\textwidth}{0.4pt}\par}
\setlength{\beforechapskip}{0pt}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\itshape\large}
\settoheight{\midchapskip}{\chapnumfont 1}
\renewcommand*{\printchapternum}{\centering \chapnumfont Chapter \thechapter}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 0.5\onelineskip}
\renewcommand*{\printchapternonum}{\centering \vphantom{\chapnumfont 1}\afterchapternum}
\renewcommand*{\chaptitlefont}{\scshape\Large}
\renewcommand*{\printchaptertitle}[1]{\centering \chaptitlefont #1
\\\mbox{}\rule[5pt]{\textwidth}{0.4pt}}
\setlength{\afterchapskip}{1\onelineskip}
对于普通章节来说,这给了我这个良好的结果:
但对于我的目录标题,它给了我这个:
我如何定制此代码以便它只对目录执行一些额外的操作?
答案1
这取决于您的实际意图。如果如问题评论中所述,所需的更改是为使用\chapter*
(例如 ToC、LoF、LoT)生成的未编号章节获得不同的垂直对齐方式,则可以使用\printchapternonum
。
一个小的完整的例子,我改变了原来的
\renewcommand*{\printchapternonum}{\centering \vphantom{\chapnumfont 1}\afterchapternum}
到
\renewcommand*{\printchapternonum}{\vskip0.75ex}
代码:
\documentclass{memoir}
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{%
\par
\needspace{10\onelineskip}
\vspace{\beforechapskip}
\mbox{}\\\mbox{}\rule[0pt]{\textwidth}{0.4pt}\par}
\setlength{\beforechapskip}{0pt}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\itshape\large}
\settoheight{\midchapskip}{\chapnumfont 1}
\renewcommand*{\printchapternum}{\centering \chapnumfont Chapter \thechapter}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 0.5\onelineskip}
\renewcommand*{\printchapternonum}{\vskip0.75ex}
\renewcommand*{\chaptitlefont}{\scshape\Large}
\renewcommand*{\printchaptertitle}[1]{\centering \chaptitlefont #1
\\\mbox{}\rule[5pt]{\textwidth}{0.4pt}}
\setlength{\afterchapskip}{1\onelineskip}
\def\clearforchapter{}
\begin{document}
\tableofcontents
\chapter{A test numbered chapter}
\chapter*{Another test unnumbered chapter}
\end{document}
结果: