花式标题和附录

花式标题和附录

我在将 fancyhdr 与附录结合时遇到了一些麻烦。有两个问题。第一个问题是,页眉在附录之前的页面上没有显示正确的信息(正文的最后一页)。

它看起来应该是这样的:

correct header

但我得到的是:

bad header

第二,附录中的标题显示:

appendix header

我希望“章节”为“附录”。我尝试了建议这里,但这些似乎不起作用。相关代码:

\documentclass[11pt]{report}

\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}

\usepackage{parskip}
\setlength\parindent{0pt}
\setlength{\headheight}{15pt}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{Entanglement Entropy}
\fancyhead[C]{Chapter \thechapter}
\fancyhead[R]{Section \thesection}

\renewcommand{\headrulewidth}{0.4pt}

\begin{document}

\chapter{title}
\input{chapters/chapter05}

\appendix
\chapter{another title}
\input{chapters/appendix}

\printbibliography

\end{document}

答案1

第一个问题是切换到附录会影响最后一章最后一页的页眉。要解决这个问题,您可以使用\clearpage预先设置。

第二个原因是您已告诉 TeX 使用Chapter \thechapter中央标题,因此它会继续这样做。解决此问题的一种方法是告诉它您希望它做什么。我刚刚在适当的位置重新定义了中央标题,这可能是最简单的解决方案。

\documentclass[11pt]{report}

\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{biblatex,kantlipsum}

\usepackage{parskip}
\setlength\parindent{0pt}
\setlength{\headheight}{15pt}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{Entanglement Entropy}
\fancyhead[C]{Chapter \thechapter}
\fancyhead[R]{Section \thesection}

\renewcommand{\headrulewidth}{0.4pt}

\begin{document}

  \chapter{title}
  \kant[1-6]
  \clearpage

  \appendix
  \fancyhead[C]{Appendix \thechapter}
  \chapter{another title}
  \kant[7-10]

  \printbibliography

\end{document}

Last page before appendix Appendix header

相关内容