如何仅在章节开始的位置将页码放置在页脚中

如何仅在章节开始的位置将页码放置在页脚中

到目前为止,我已在页眉中对所有页面进行了页码编排(这符合要求),但章节开始的页面除外 - 它们留空,没有页码。

我想获取章节开始页面的页脚中的页码。可以吗?

到目前为止,我已经获得了这个功能,它可以很好地用于页眉中的页码,但是章节页面的页码缺失:

\pagestyle{fancy}                       % Sets fancy header and footer
\fancyfoot{}                            % Delete current footer settings


\fancyhf{}

\fancyhead[LE,RO]{\bfseries\thepage}    % Page number (boldface) in left on even
% pages and right on odd pages
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}

\fancyhead[RE]{\bfseries\nouppercase{\leftmark}}      % Chapter in the right on even pages
\fancyhead[LO]{\bfseries\nouppercase{\rightmark}\chaptermark}     % Section in the left on odd pages

\fancypagestyle{plain}{
\fancyhf{}
  \fancyhead{}
  \fancyfoot{}
    \renewcommand{\headrulewidth}{0pt}
}

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

答案1

假设您使用的是标准类(问题中没有 MWE),则可以删除 fancypagestyle 的定义plain。然后,标准类提供的默认plain样式将用于章节页面。并且此默认plain样式似乎是所需的样式。

例子:

\documentclass{book}
\usepackage{blindtext}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[RE]{\bfseries\nouppercase{\leftmark}}
\fancyhead[LO]{\bfseries\nouppercase{\rightmark}}
\begin{document}
\blinddocument
\end{document}

结果:

在此处输入图片描述

答案2

您可以在序言中添加此代码:

\let\oldchapter\chapter
\makeatletter
\def\chapter{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}      
\def\@StarredWith[#1]#2{%
\oldchapter*{#2}%
\thispagestyle{plain}
}
\def\@StarredWithout#1{
\oldchapter*{#1}%
\thispagestyle{plain}
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldchapter[#1]{#2}%
\thispagestyle{plain}
}
\def\@nonStarredWithout#1{%
\oldchapter{#1}%
\thispagestyle{plain}
}
\makeatother

这将改变章节的默认行为(包括pagestyle{empty}命令)

相关内容