通过在整个文档的右下角保留页码来生成章节标题

通过在整个文档的右下角保留页码来生成章节标题

我在用简单的论文模板来写我的论文。

我希望页码位于所有页面的右下角,包括、、\frontmatter\mainmatter\backmatter(也是章节标题页)

因此,经过互联网上的一番搜索后,我使用了下面的代码:

\pagestyle{fancy}
% Clear the header and footer
\fancyhead{}
\fancyfoot{}
% Set the right side of the footer to be the page number
\fancyfoot[R]{\thepage}

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[RO,RE]{\thepage} %RO=right odd, RE=right even
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

在序言中输入上述代码后,我 \pagestyle{plain}在每一章的开头都添加了代码。

通过这些步骤,我得到了位于右下角的页码。

因为我使用的是单页(一列)格式,所以我希望\section将标题打印在每一页的左上角。

我尝试使用各种选项来获取页眉,但页码位置不知为何却偏离了方向。

有人能帮忙解决这个问题吗?

答案1

这段代码似乎可以完成您想要的操作:

\documentclass[12pt, a4paper]{Thesis}%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{lipsum}

\renewcommand{\chaptermark}[1]{}%
\renewcommand{\sectionmark}[1]{\markboth{\thesection\enspace #1}{\thesection\enspace#1}}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\rfoot{\thepage}
\rhead{\rightmark}
\renewcommand\headrulewidth{0pt}
}
\pagestyle{plain}
\usepackage{etoolbox}
\pretocmd{\chapter}{\protect\thispagestyle{plain}}{}{}

\begin{document}
\chapter{Introduction}

\section{Motivation}
\lipsum[1-4]

\section{Another section}
\lipsum[5-8]

\section{Still another section}
\lipsum[9-12]

\end{document} 

在此处输入图片描述

相关内容