帶有 \thechapter 的花哨標題在 \appendix 之後仍然顯示“Chapter”。應顯示“附錄”

帶有 \thechapter 的花哨標題在 \appendix 之後仍然顯示“Chapter”。應顯示“附錄”

我有章節和附錄。我沒有使用\part.我的標題定義為

\fancyhead[RO,LE]{\textsf{\footnotesize \thechapter--\thepage}}

當我從章節轉到附錄後(在 後\appendix),附錄標題沒問題,但標題顯示“Chapter A: blah”而不是“Appendix A: blah”。

答案1

這是一個解決方案。

該命令\@chapapp首先擴展到章節,使用後擴展到附錄,\appendix我們可以在這裡使用它 \renewcommand{\chaptermark}[1]{\markboth{\@chapapp{} \thechapter:\ #1}{}}

\documentclass{book}
\usepackage{blindtext}


\usepackage{fancyhdr}
\renewcommand{\chaptermark}[1]{% 
\markboth{\@chapapp{} \thechapter:\ #1}{}} 
\fancyhead{} 
\makeatletter
\fancyhead[RO,LE]{\textsf{\footnotesize \thechapter--\thepage}} 
\fancyhead[LO,RE]{\textsf{\footnotesize \leftmark}}
\makeatother
\pagestyle{fancy}

\begin{document}
\blinddocument
\appendix 
\blinddocument 
\end{document}

相關內容