2

I would like to just have a footer with "Page X of Y", but the following only works half the way for me:

\documentclass[a4paper]{article}

\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}

\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead{}
\cfoot{Page \thepage\ of \pageref{LastPage}}

\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\usepackage{lipsum}

\title{\bfseries \Huge Nothing Else Matters}
\author{my name \thanks{myname@mail.com} \\ { \vspace{-10pt} \normalsize \scshape Institute for Nothing, No University} \vspace*{10pt} }
\date{\today}

\begin{document}
\thispagestyle{fancy}
\maketitle
\lipsum[1-100]
\end{document}

Trouble

I would like to have the "Page X of Y" on the first page, which currently it only prints "1". And "Page X+1 of Y" to "Page Y of Y" are in the middle of the page, but not centered. It's like we have the page middle and it just write the footer to the left.

Werner
  • 603,163
Amelie B. Blackstone
  • 1,502
  • 1
  • 13
  • 26

2 Answers2

2

You need to load fancyhdr and the setting of page styles after geometry. As reference, see geometry, fancyhdr: \fancyfoot[C]{\thepage} is not really centered.

The page on which \maketitle is issued necessarily also issues \thispagestyle{plain}. While you do set \thispagestyle{fancy}, it's reset by \maketitle. Again, placing \thispagestyle{fancy} after \maketitle fixes this. Alternatively, you can issue

\fancypagestyle{plain}{\pagestyle{fancy}}

in your preamble. See Non-special first page in \documenclass{article}.

\documentclass{article}

\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}

\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead{}
\cfoot{Page \thepage\ of \pageref{LastPage}}

\usepackage{lipsum}

\title{\bfseries \Huge Nothing Else Matters}
\author{my name \thanks{myname@mail.com} \\ { \vspace{-10pt} \normalsize \scshape Institute for Nothing, No University} \vspace*{10pt} }
\date{\today}

\begin{document}
\maketitle
\thispagestyle{fancy}
\lipsum[1-100]
\end{document}
Werner
  • 603,163
1

Move command \thispagestyle after \maketitle:

%\thispagestyle{fancy}
\maketitle
\thispagestyle{fancy}

After creating the titel the moved command can work and change the footer as you want.

Mensch
  • 65,388