
我正在使用report
並且我需要將章節標題全部大寫(包括附錄),但不在目錄中。例如,它應該在論文內顯示為“APPENDIX A”,在目錄中顯示為“Appendix A”,而不是“附錄A”。我似乎已經修復了常規章節,但似乎不知道如何修復附錄。
我可以更改\appendixname
為附錄,但隨後它將在目錄中顯示為全部大寫(我不希望出現這種情況)。更改 for report 類別的定義\appendix
似乎具有相同的效果(我相信,因為它基本上只是重新定義\@chapapp
):
\renewcommand{\appendix}{\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\gdef\@chapapp{APPENDIX}% modified from \appendixname
\gdef\thechapter{\@Alph\c@chapter}}
我能夠透過保持\chaptername
原樣和硬編碼章節而不是\@chapapp
在下面使用(這是原始模板的一部分 - 我沒有創建它,所以我不完全理解這一切在做什麼)來解決常規章節問題):
\def\@chapter[#1]#2{
\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{CHAPTER\space\thechapter.} % originally used \@chapapp
\addcontentsline{toc}{chapter}%
{\@chapapp\space {\thechapter}: {#1}}
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi
}
老實說,我不明白為什麼\uppercase
在下面不起作用,但它沒有將“Chapter”大寫\@chapapp
(這也來自原始模板)並且仍然出現在樣式檔案中的上述內容之後(章節標題有總是出現在大寫字母中,只是不是“第 x 章:”前綴)。
\def\@makechapterhead#1{%
\vspace*{-20\p@}%
{\parindent \z@ \raggedright \normalfont
\interlinepenalty\@M
\ifnum \c@secnumdepth >\m@ne
\centering \large\bfseries
\uppercase{\@chapapp\space \thechapter: #1}
\fi
\vskip 20\p@
}
}
答案1
.cls
無需硬編碼或直接編輯文件的解決方案:
OP 的假設是正確的\@makechapterhead
:
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\@chapapp
確實印了該行Chapter
(或附錄),後面跟著章節號。
要獲得大寫,必須使用\MakeUppercase{\@chapapp}
,而不是\uppercase
。
report.cls
最好使用\xpatchcmd
,尋找該行\huge\bfseries\@chapapp..
並使用 相關程式碼替換它,而不是編輯程式碼\MakeUppercase
。
但是,這應該只在 之後完成\appendix
,因此請將此補丁附加到\appendix
using \xapptocmd{\appendix}{...}
(請參閱程式碼)
\documentclass{report}
\usepackage{xpatch}
\makeatletter
\xapptocmd{\appendix}{%
\xpatchcmd{\@makechapterhead}{%
\huge\bfseries \@chapapp\space \thechapter
}{%
\huge\bfseries \MakeUppercase{\@chapapp}\space \thechapter
}{\typeout{Patching \@makechapterhead succeeded}}{\typeout{Patching failed}}% Patching ends
}{\typeout{Appending succeeded}}{\typeout{Appending failed}}
\makeatother
\begin{document}
\chapter{First}
\appendix
\chapter{Appendix 1}
\end{document}
請注意,我的程式碼不適用於\chapter*
類似的附錄。