删除空白页的页眉但不删除页码

删除空白页的页眉但不删除页码

我在论文中使用双面 openright 报告模板,并尝试仅从自动生成的空白页中删除页眉(由于偶数/奇数页码交互)并保留页码。我尝试包括空页包但无济于事,因为它还会删除新章节开头的页码。下面是生成页眉和页码的代码。

% Header and footer settings (Select TWOSIDE or ONESIDE layout below)
\usepackage{fancyhdr}                               
\pagestyle{fancy}  
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\space#1}{}} 


% Select one-sided (1) or two-sided (2) page numbering
\def\layout{2}  % Choose 1 for one-sided or 2 for two-sided layout
% Conditional expression based on the layout choice
\ifnum\layout=2 % Two-sided
    \fancyhf{}                                  
    \fancyhead[LE,RO]{\nouppercase{ \leftmark}}
    \fancyfoot[LE,RO]{\thepage}
    \fancypagestyle{plain}{         % Redefine the plain page style
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}} 
    \fancyfoot[LE,RO]{\thepage}
\else           % One-sided     
    \fancyhf{}                  
    \fancyhead[C]{\nouppercase{ \leftmark}}
    \fancyfoot[C]{\thepage}
\fi

我该如何继续?

答案1

如果页码应出现在章节页面上,则必须\fancyfoot[LE,RO]{\thepage}在花式页面样式的参数中包含该参数。plain

如果空白页要使用纯文本页面样式,则可以scrextend使用以下选项加载包cleardoublepage=plain

\documentclass[twoside,openright]{report}

\usepackage[cleardoublepage=plain]{scrextend}

% Header and footer settings (Select TWOSIDE or ONESIDE layout below)
\usepackage{fancyhdr}                               
\pagestyle{fancy}  
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\space#1}{}} 


% Select one-sided (1) or two-sided (2) page numbering
\def\layout{2}  % Choose 1 for one-sided or 2 for two-sided layout
% Conditional expression based on the layout choice
\ifnum\layout=2 % Two-sided
    \fancyhf{}                                  
    \fancyhead[LE,RO]{\nouppercase{ \leftmark}}
    \fancyfoot[LE,RO]{\thepage}
    \fancypagestyle{plain}{         % Redefine the plain page style
      \fancyhf{}
      \renewcommand{\headrulewidth}{0pt}
      \fancyfoot[LE,RO]{\thepage}
    }
\else           % One-sided     
    \fancyhf{}                  
    \fancyhead[C]{\nouppercase{ \leftmark}}
    \fancyfoot[C]{\thepage}
\fi

\usepackage{blindtext}% only for dummy text

\begin{document}
\tableofcontents
\Blinddocument
\Blinddocument
\end{document}

在此处输入图片描述

相关内容