这是我当前的代码:
\documentclass[11pt]{book}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{color}
\usepackage{CJK}
\usepackage{draftwatermark}
\usepackage{fancyhdr}
\usepackage[colorlinks]{hyperref}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{ulem}
\usepackage{siunitx}
\usepackage{xcolor}
%----------------------------------------------------------------------
\geometry{a4paper,hmargin=1.25in,vmargin=1in}
\graphicspath{{Figures/}}
\setlength{\fboxrule}{1.6pt}
\pdfstringdefDisableCommands{\let \bm=\relax}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}{}}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[LO]{\textit{\rightmark}}
\fancyhead[RE]{\textit{\leftmark}}
\fancyhead[LE,RO]{\thepage}
\fancyfoot{}
\fancyfoot[L]{\textit{Eureka! Journal Entry}}
\fancyfoot[C]{March 10, 2024}
\fancyfoot[R]{\textit{Some Rights Reserved.}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\SetWatermarkText{\shortstack{\textsc{Eureka!}}}
\SetWatermarkLightness{0.75}
\SetWatermarkScale{7.5}
%----------------------------------------------------------------------
\begin{document}
%----------------------------------------------------------------------
\frontmatter
\chapter*{\Huge \center Eureka!}
\newpage
%----------------------------------------------------------------------
\chapter*{Preface}
Preface...
%----------------------------------------------------------------------
\tableofcontents
\mainmatter
%----------------------------------------------------------------------
\chapter{Topics in Elementary Mathematics}
Introduction to Topics in Elementary Mathematics...
\newpage
Currently, there are no submissions in this section.
%----------------------------------------------------------------------
\end{document}
问题就在这里,在那些带有章节号的页面中,页脚无法正常工作。我希望页脚可以在这些页面上工作,但页眉不行。我不知道该怎么做,请帮帮我。
另外还有一个小问题,页眉正常情况下是“第二章 初等数学竞赛”的样式,但是内容页还是默认的样式,是“内容”,请问如何改成“内容”呢?
答案1
在起始章节页面中,该类book
使用plain
页面样式,因此您只需重新定义它,即可fancyhdr
通过\fancypagestyle
。
\documentclass[11pt]{book}
\usepackage{geometry}
\usepackage{fancyhdr}
\geometry{
a4paper,
hmargin=1.25in,
vmargin=1in,
headheight=13.6pt, % as suggested by fancyhdr
}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}{}}
\pagestyle{fancy}
\fancyhf{}% clear all fields
\fancyhead[LO]{\textit{\rightmark}}
\fancyhead[RE]{\textit{\leftmark}}
\fancyhead[LE,RO]{\thepage}
\fancyfoot[L]{\textit{Eureka! Journal Entry}}
\fancyfoot[C]{March 10, 2024}
\fancyfoot[R]{\textit{Some Rights Reserved.}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[L]{\textit{Eureka! Journal Entry}}%
\fancyfoot[C]{March 10, 2024}%
\fancyfoot[R]{\textit{Some Rights Reserved.}}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.4pt}%
}
\begin{document}
\frontmatter
\chapter{Eureka!}
\chapter{Preface}
Preface...
\tableofcontents
\mainmatter
\chapter{Topics in Elementary Mathematics}
Introduction to Topics in Elementary Mathematics...
\newpage
Currently, there are no submissions in this section.
\end{document}
我删除了示例中所有不必要的包,但为了geometry
指出您需要设置的包除外headheight
。
我也在前言中使用了\chapter
“与不” \chapter*
,这样您可以在目录中看到这些章节。不要使用章节标题中的格式声明,除非你还想\Huge
在目录中使用(我不认为你会这么做)。如果你真的需要\Huge
章节标题,请执行
\chapter[Eureka!]{\Huge Eureka!}