使用 memoir + titlesec 时在 ToC 中格式化“内容”

使用 memoir + titlesec 时在 ToC 中格式化“内容”

在以下 MWE 中,目录的标题不像其他章节那样使用 titlesec 的格式。

\documentclass{memoir}
\usepackage{titlesec}
\titleformat{name=\chapter}%
  [display]% shape
  {}% format applied to label+text
  {\vspace{-60pt}\upshape\fontsize{72pt}{96pt}\selectfont\thechapter}% label
  {-10pt}% horizontal separation between label and title body
  {\huge\rmfamily\itshape}% before the title body
  [\vspace{5pt}\titlerule]% after the title body

\titleformat{name=\chapter,numberless}
  [display]
  {}% format applied to label+text
  {}% label
  {-10pt}% horizontal separation between label and title body
  {\huge\rmfamily\itshape}% before the title body
  [\vspace{5pt}\titlerule]% after the title body

\begin{document}
\tableofcontents*
\chapter{Numbered Test}
\chapter*{Unnumbered Test}
\end{document}

这似乎是 memoir 和 titlesec 结合时出现的问题。有人能告诉我,memoir 与 book 等相比有何不同吗?上面的代码可以按预期运行。

答案1

正如评论中所讨论的,不titlesec一起使用memoir可以解决这个问题。 就 的宏而言,上述章节样式的代码memoir是:

\documentclass{memoir}

%%% Chapter Style %%%
\setlength{\beforechapskip}{0pt}
\renewcommand{\chapnumfont}{\fontsize{72pt}{96pt}\selectfont}
\renewcommand{\chaptitlefont}{\huge\rmfamily\itshape\color{darkgray}}
\renewcommand*{\printchaptername}{\chapnumfont}
\renewcommand*{\afterchaptertitle}{\par\nobreak\vspace*{-10pt}\hrulefill\vskip\afterchapskip}
\setlength{\afterchapskip}{\baselineskip}

%%% ToC Style %%%
\newlength{\aftertocskip}
\setlength{\aftertocskip}{-15pt}
\renewcommand*{\aftertoctitle}{\par\nobreak\vspace*{-10pt}\hrulefill\vskip\aftertocskip}

\begin{document}
\tableofcontents*
\chapter{Numbered Test}
\chapter*{Unnumbered Test}
\end{document}

相关内容