1

This question already has an answer here:

I would the page x of x in the right side (foot) of each page. I have the following code:

\documentclass[a4paper]{article} %sætter dansk standard, a4 papir.
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Some name}
\rhead{Some title}
\usepackage{lastpage}
\rfoot{\thepage\ af \pageref{LastPage} }

\begin{document}
\title{A title}
\date{Some date}
\author{some name}

\maketitle

\newpage 

hello world

\end{document}

I would like page X of Y on everypage (also title page). But when i compile the above it adds a pagenumber in the middel of the foot (as pr. standard article), but it also puts the page X of y in the right side. How can i fix this?

marked as duplicate by user31729, user13907, ChrisS, Stefan Kottwitz Sep 8 '14 at 8:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Couldn't you just use \cfoot{\thepage\ af \pageref{LastPage}} or \cfoot{} \rfoot{\thepage\ of \pageref{LastPage}}? – moewe Sep 8 '14 at 10:31
2

If you want to clear the center of the footer, then you have to use \cfoot{}, clearing the center footer.

If the center pagenumber on the title page should vanish, too, then use \thispagestyle{empty} after \maketitle

\documentclass[a4paper]{article} %sætter dansk standard, a4 papir.
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Some name}
\rhead{Some title}
\usepackage{lastpage}
\usepackage{etoolbox}%
\rfoot{\thepage\ af \pageref{LastPage} }
\cfoot{}%

% Remove the `plain` - pagestyle and replace it by `fancy`
\patchcmd{\maketitle}{\thispagestyle{plain}}{\pagestyle{fancy}}{}{}%

\begin{document}
\title{A title}
\date{Some date}
\author{some name}

\maketitle
\thispagestyle{empty}%

\newpage 

hello world

\end{document}

enter image description here

Improved version

\documentclass[a4paper]{article} %sætter dansk standard, a4 papir.
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}%


\fancypagestyle{titlepage}{%
\fancyhf{}% Clear all the fields first
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%
\rfoot{\thepage\ af \pageref{LastPage}}%
}%




\patchcmd{\maketitle}{\thispagestyle{plain}}{
  \pagestyle{titlepage}%
  \clearpage%
}{}{}

\begin{document}
\title{A title}
\date{Some date}
\author{some name}


\maketitle

\newpage 


\pagestyle{fancy}%

\lhead{Some name}
\rhead{Some title}
\rfoot{\thepage\ af \pageref{LastPage} }
\cfoot{}%


hello world
\end{document}
  • The \cfoot{} works for every other page, other than title page. But I would like the "Page X of Y" to also be included on the title page. – Repmat Sep 8 '14 at 10:13
  • @user3551644: Yes? I did not enable it for the titlepage, as this would awful! – user31729 Sep 8 '14 at 10:14
  • Ok... I need for a paper where "X of Y" must be on every page handed in. Surely there is some way to do this? – Repmat Sep 8 '14 at 10:25
  • @user3551644: I'll try – user31729 Sep 8 '14 at 10:26
  • I suppose one way to do it, is to just remove the title part, and type that manually. But then the header is included on the title page, which looks awfull. So perhaps a solution is to just disable the header on the first page... Can this be done? – Repmat Sep 8 '14 at 10:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.