建立在這例如,將章節新增到每個章節標題,我如何修改程式碼來做到這一點除了引言和最後/結論章節(但仍保留目錄編號)?
\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}