我使用的是 \documentclass{book},并且还重新定义了 \chapter 和 \part 标题样式。但是,这些样式不适用于致谢页的标题(“致谢”一词)或其他类似页面。有没有办法重新定义样式,以便我可以避免使用\chapter*{}
。这是一个 MWE。请查看致谢的标题。我希望它们具有与章节标题相同的样式,但不包括编号!
\documentclass[draft]{book}
\usepackage[table]{xcolor}
\usepackage{epigraph}
\usepackage[explicit]{titlesec}
\usepackage{type1cm}
\setlength\epigraphwidth{.6\textwidth}
\titleformat{\chapter}[display]
{\normalfont\Large\rmfamily}
{\sffamily\flushright\fontsize{100}{0}\textbf{\textcolor{black!25}{\thechapter\vskip-10pt}}}{-10pt}
{\flushright\fontsize{25}{0}{#1}\vskip60pt}
\titlespacing*{\chapter}
{0pt}{-40pt}{0pt}
\titleformat{\part}[display]
{\normalfont\Large\rmfamily}
{\sffamily\flushright\fontsize{100}{0}\textbf{\textcolor{black!25}{\thepart\vskip-10pt}}}{-10pt}
{\flushright\fontsize{25}{0}{#1}\vskip60pt}
\titlespacing*{\part}
{0pt}{-40pt}{0pt}
\begin{document}
\chapter*{Acknowledgments}
\addcontentsline{toc}{chapter}{Acknowledgments}
Let's acknowledge those who answer this question!
\tableofcontents
\cleardoublepage
\chapter{A Test Chapter Title}
\end{document}
答案1
您必须使用numberless
titlesec 中的密钥来格式化\chapter*
。我使用 titlesec 的工具改进并简化了您的代码。我添加了 geometry 包,其中包含选项,showframe
以更精确地可视化生成的布局。
\documentclass[draft]{book}
\usepackage[table]{xcolor}
\usepackage{epigraph}
\usepackage[explicit]{titlesec}
%\usepackage{fix-cm}
\usepackage{lmodern}
\usepackage[nomarginpar, showframe]{geometry}
\setlength\epigraphwidth{.6\textwidth}
\titleformat{\chapter}[display]
{\filleft}
{\sffamily\fontsize{100}{0}\selectfont\bfseries\color{black!25}\thechapter}{10pt}
{\Huge#1}
\titlespacing*{\chapter}
{0pt}{-8.6pt}{60pt}
\titleformat{name=\chapter, numberless}[display]
{\filleft}
{}{68.5pt}
{\Huge#1\vskip60pt}
\titlespacing*{name=\chapter, numberless}
{0pt}{-8.6pt}{-30pt}
\titleformat{\part}[display]
{\filleft}
{\sffamily\fontsize{100}{0}\selectfont\bfseries\color{black!25}\thechapter}{10pt}
{\Huge#1}
\titlespacing*{\part}
{0pt}{-8.6pt}{60pt}
\begin{document}
\chapter*{Acknowledgments}
\addcontentsline{toc}{chapter}{Acknowledgments}
Let's acknowledge those who answer this question!
\tableofcontents
\cleardoublepage
\chapter{A Test Chapter Title}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\end{document}