我想在页面右侧添加页脚“第 1 页,共 3 页”。我从另一篇文章中获取了此代码,但页码在右侧显示为“第 2 页,共 3 页”,在中间显示为“2”。
我该如何修复它?
\documentclass[11pt,a4paper,hidelinks,fleqn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\chead{\textbf{FE5116}}
\rfoot{Page \thepage\ of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\title{Dummy empty page, so that I get the first page with number 2}
\date{}
\begin{document}
\maketitle
\newpage
\section*{Question 1 [25 marks]}
this is a question
\newpage
\section*{Question 1 [25 marks]}
this is a question
\bigskip
%dummy use of math, to center the next line
$$
\text{\textbf{END OF PAPER}}
$$
\end{document}
答案1
您需要先实际删除页脚的中心部分,使用\cfoot{}
或\fancyhf{}
(删除页眉和页脚)。
\documentclass[11pt,a4paper,hidelinks,fleqn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clears the header and footer
\fancyhead[C]{\textbf{FE5116}}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\title{Dummy empty page, so that I get the first page with number 2}
\date{}
\begin{document}
\maketitle
\newpage
\section*{Question 1 [25 marks]}
this is a question
\newpage
\section*{Question 1 [25 marks]}
this is a question
\bigskip
\begin{center}
\textbf{END OF PAPER}
\end{center}
\end{document}