构建于这例如,在每个章节标题中添加了章节,我该如何修改代码来实现这一点除了用于介绍和最后的章节/结论章节(但仍保留编号以用于目录目的)?
\documentclass{tufte-book}
\usepackage{lipsum}
\makeatletter
\titleformat{\chapter}%
[display]% shape
{\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
{\itshape\huge\chaptertitlename~\thechapter}% label
{0pt}% horizontal separation between label and title body
{\huge\rmfamily\itshape}% before the title body
[\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
\makeatother
\setcounter{secnumdepth}{1}
\begin{document}
\chapter{Introduction}
\lipsum[1]
\chapter{A substantive chapter}
\lipsum[2]
\end{document}
编辑:我对一个灵活的解决方案感兴趣 - 允许我将介绍和结论保持与其他章节相同的编号 - 允许我对介绍和结论不进行编号,但仍然出现在目录中。
答案1
只要在组内进行更改,它们只会影响您想要的章节,您可以灵活地更改其他章节。
\documentclass{tufte-book}
\usepackage{lipsum}
\makeatletter
\newcommand{\mychap}{%
\titleformat{\chapter}%
[display]% shape
{\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
{\itshape\huge\chaptertitlename~\thechapter}% label
{0pt}% horizontal separation between label and title body
{\huge\rmfamily\itshape}% before the title body
[\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body
}
\makeatother
\setcounter{secnumdepth}{1}
\begin{document}
\chapter{Introduction}
\lipsum[1]
\begingroup
\mychap%
\chapter{A substantive chapter}
\lipsum[2]
\chapter{Another chapter}
\lipsum[1]
\endgroup
\chapter{Conclusions}
\lipsum[1]
\end{document}