\frontmatter 阻止了 \titleformat 从序言传播到第一章。 有办法避免这种情况吗?
\documentclass[11pt,A4]{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\bfseries}{Title Above}{20pt}{\Huge}[\vspace{2ex}\titlerule\vspace{0.2ex}\titlerule]
\begin{document}
\chapter{Preface (before frontmatter)}
\frontmatter% blocks the propagation of the titleformat to the first chapter
\chapter{Chapter 1 (after frontmatter)}
\end{document}
仅当不存在 \frontmatter 时,才会显示第 1 章的上部标题。
答案1
这是更正后的代码,感谢以上所有评论。
\documentclass[11pt,A4]{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{Title Above}{20pt}{\Huge}[\vspace{2ex}\titlerule\vspace{0.2ex}\titlerule]
\begin{document}
\frontmatter
\chapter{Preface (after frontmatter)}
\mainmatter
\chapter{Chapter 1 (with ``mainmatter")}
\backmatter
\chapter{Chapter after ``backmatter")}
\end{document}