1

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?

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

1 Answers1

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 08 '14 at 10:13
  • @user3551644: Yes? I did not enable it for the titlepage, as this would awful! –  Sep 08 '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 08 '14 at 10:25
  • @user3551644: I'll try –  Sep 08 '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 08 '14 at 10:33
  • @user3551644: See the update –  Sep 08 '14 at 10:51
  • @user3551644: Ok... In general, I am not fond of \maketitle at all, as it is too restrictive –  Sep 08 '14 at 11:02
  • Then what do you use as an alternative? – Repmat Sep 08 '14 at 12:31
  • @user3551644: I usually do it manually –  Sep 08 '14 at 12:54