删除页眉,并将页脚保留在左侧,即使章节末尾有空白页

删除页眉,并将页脚保留在左侧,即使章节末尾有空白页

我想删除论文章节末尾空白页的页眉,但不删除页脚(页码)。我使用了:

\documentclass[10pt,b5paper,openright,twoside]{book}
\usepackage{graphicx}
\usepackage[width=170.00mm, height=240.00mm, left=2.0cm, right=2.00cm, top=2.2 cm, bottom=1.80cm]{geometry}
\usepackage[utf8]{inputenc}

\usepackage{fancyhdr} %necessary to set your own header and footer style
\pagestyle{fancy} %necessary to set your own header and footer style
\fancyhf{} %clear the header and the footer before you define your own
\fancyfoot[RO]{\thepage} %footer in odd pages on the right
\fancyfoot[LE]{\thepage} %footer in even pages on the left

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\vspace{\fill}
\thispagestyle{plain}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

\begin{document}

some text here

\end{document}

答案1

在 的重新定义中,\cleardoublepage您将这些页面的页面样式设置为plain,这与章节第一页的页面样式相同。在下面的代码中,我创建了一个新的页面样式,并在 的重新定义中使用它\cleardoublepage

\documentclass[10pt,b5paper,openright,twoside]{book}
\usepackage{graphicx}
\usepackage[width=170.00mm, height=240.00mm, left=2.0cm, right=2.00cm, top=2.2 cm, bottom=1.80cm]{geometry}
\usepackage[utf8]{inputenc}

\usepackage{fancyhdr} %necessary to set your own header and footer style
\pagestyle{fancy} %necessary to set your own header and footer style
\fancyhf{} %clear the header and the footer before you define your own
\fancyfoot[RO]{\thepage} %footer in odd pages on the right
\fancyfoot[LE]{\thepage} %footer in even pages on the left

\fancypagestyle{endofchapter}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{0pt}
}

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\vspace{\fill}
\thispagestyle{endofchapter}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

\begin{document}

\chapter{A}
\chapter{B}


\end{document}

答案2

您可以修补emptypage以使用不同于以下页面样式empty

\documentclass[10pt,b5paper,openright,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage[
  width=170.00mm,
  height=240.00mm,
  left=2.0cm,
  right=2.00cm,
  top=2.2cm,
  bottom=1.80cm
]{geometry}

\usepackage{graphicx}
\usepackage{etoolbox}
\usepackage{emptypage}

\usepackage{fancyhdr} %necessary to set your own header and footer style
\pagestyle{fancy} %necessary to set your own header and footer style
\fancyhf{} %clear the header and the footer before you define your own
\fancyfoot[RO]{\thepage} %footer in odd pages on the right
\fancyfoot[LE]{\thepage} %footer in even pages on the left
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}

\fancypagestyle{almostempty}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
  \fancyfoot[LE]{\thepage}% footer in even pages on the left
}

\makeatletter
\patchcmd{\emptypage@emptypage}{empty}{almostempty}{}{}
\makeatother

\begin{document}

\mainmatter
\chapter{One}

Some text to have a page

\chapter{Two}
\section{Section title}

Some text to have a page

\newpage

And another one to see the header and footer

\newpage

And another one to see the header and footer

\end{document}

如果您希望空白页面中的页码居中显示,只需删除almostempty页面样式的代码并在代码中almostempty替换即可。plain\patchcmd

在此处输入图片描述

相关内容