(书)新章节的页码居中,但不应该如此

(书)新章节的页码居中,但不应该如此

我有以下问题:

\documentclass[a4paper]{book}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx} 
\usepackage{dsfont}
\usepackage{tikz}
\usepackage{braket}
\usepackage[figurename=Fig., font={footnotesize}]{caption}
\usepackage{float}
\usepackage{placeins}
\usepackage{epstopdf}
\usepackage[a4paper,left=40mm, right=40mm ,top=35mm,bottom=35mm]{geometry}
\usepackage{subfig}
\usepackage{tabularx}
\epstopdfsetup{outdir=./}
\usepackage{tikz-feynman, contour}
\usepackage[toc,title]{appendix}
\usepackage[nottoc]{tocbibind}
\usepackage[parfill]{parskip}
\usepackage{mathtools}
\usepackage[square, numbers, comma, sort&compress]{natbib} 
\captionsetup[figure]{labelfont=bf}
\usepackage{hyperref}

\makeatletter
\@addtoreset{footnote}{section}
\makeatother

\renewcommand\vec{\boldsymbol}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LO]{{\rightmark}}
\fancyhead[RE]{{\leftmark}}
\fancyfoot[RO,LE]{\thepage}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}

这是我开始文档之前的所有东西。我现在遇到的问题是:每次我开始新的章节时,页码都会出现在页面底部的中央,但我设置的方式(并且希望它是这样)是它应该出现在左侧或右侧(取决于偶数/奇数页码)。我找不到错误。以前,这不是一本书,而是一篇文章,它按照我想要的方式工作。现在我把它改成了书,其余部分保持原样。其他一切都很好,它只是每个章节的起始页。

我希望我提供的信息足以帮助您发现错误。

此外,如果我可以保留页脚,即使这一页开始了新的章节,那就太好了(页眉会随着新章节的开始而消失)。

编辑:现在这很奇怪。我以为命令会排成一行,但事实并非如此。真的很抱歉,我会看看能否修复它。

答案1

问题出在这样一个事实:在类中book,章节的第一页使用了 样式plain。解决方案是使用 重新定义普通样式fancyhdr。以下是改编自文档的代码:

\fancypagestyle{plain}{%
\fancyhf{}% clears all header and footer fields
\fancyhead[LE,RO]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.4pt}}

相关内容