\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhead[RO,LE]{\small\sf\color{black}\rightmark}
\fancyhead[LO,RE]{\small\tt\color{black}\leftmark}
或者
\renewcommand{\chaptermark}[1]{\markboth{\small\tt\color{black}\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\small\sf\color{black}\thesection\ #1}}
\fancyhead[RO,LE]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
?
答案1
使用第一个变体。第二个变体可能不考虑目录中的标题更改:
\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
% GOOD
% \renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
% \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
% \fancyhead[RO,LE]{\small\sffamily\rightmark}
% \fancyhead[LO,RE]{\small\ttfamily\leftmark}
% BAD
\renewcommand{\chaptermark}[1]{\markboth{\small\ttfamily\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\small\sffamily\thesection\ #1}}
\fancyhead[RO,LE]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\blinddocument
\end{document}
(这盲文包仅用于向示例添加一些虚拟文本。)
编辑:用\sf
和分别替换 LaTeX 2.09命令。\tt
\sffamily
\ttfamily