2

I want to have on the right side of the page a footer "Page 1 of 3". I took this code from another post, but the page number appears both on the right side "Page 2 of 3" and in the centre "2".

How can I fix it?

\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}
5
  • Please provide the source of the code. May 2, 2018 at 10:44
  • @Fabio See this answer: tex.stackexchange.com/a/394355/121944
    – AML
    May 2, 2018 at 11:43
  • 1
    You probably need to clear the center footer with something like \cfoot{}. Completely unrelated: don't use $$ ... $$ for displayed math, see Why is \[ … \] preferable to $$? May 2, 2018 at 11:55
  • Thanks for both suggestions. Both work. $$ is not preferable, I was just not aware of \[...\]
    – Fabio
    May 2, 2018 at 12:00
  • Do you want to change the page style of the title page as well? May 2, 2018 at 12:15

1 Answer 1

2

You need to actually remove the center part of the footer first, with \cfoot{} or \fancyhf{} (removes both header and footer).

enter image description here

\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}
2
  • I think he wants the first page to say "Page 1 of 3".
    – AML
    May 2, 2018 at 12:08
  • @AML Maybe, but it's not really clear from the question. The obvious thing that's being asked is to remove the page number from the center footer, Fabio will have to clarify if he wants to change the page style of the title page. May 2, 2018 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .