I want to simply add page numbers to my document in the format: #page out of #pages. I find this:

   % This is based on the LLNCS.DEM the demonstration file of
% the LaTeX macro package from Springer-Verlag
% for Lecture Notes in Computer Science,
% version 2.4 for LaTeX2e as of 16. April 2010
%
% See http://www.springer.com/computer/lncs/lncs+authors?SGWID=0-40209-0-0-0
% for the full guidelines.
%

\documentclass{llncs}

\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy}

\begin{document}
\cfoot{page \thepage\ of \pageref{LastPage}}
\title{Title}
\author{Author}
\institute{Institute\\
\email{email}}

\maketitle

\begin{abstract}

\end{abstract}

\section{Section1}

\end{document}


But it adds a line at the header. Also, it does not add number for the first page in my document. How can I solve these two issues?

• Removing the header line: \renewcommand{\headrulewidth}{0pt} ;-) The first page is most often a \pagestyle{empty}, this depends on the documentclass or how the \maketitle etc. commands are defined. Without seeing real code, this is difficult to say. Reading the manual is definitely a way to Enlightenment ;-) – user31729 Jul 21 '16 at 18:01
• @Christian Hupfer I am using llncs.cls – user2192774 Jul 21 '16 at 18:04
• @user2192774: Provide a compilable document then, not just fragments. My 'I'll do the work for others and glue their fragments together' -inclination is very low today ;-) – user31729 Jul 21 '16 at 18:05
• @Christian Hupfer provided. Appreciate your help. – user2192774 Jul 21 '16 at 18:12

First of all: If this should be submitted to Springer, they will not accept the page number on the first page, most likely, but here you go...

\maketitle uses \thispagestyle{empty} (many document classes do so!), so either

• \renewcommand{\maketitle} → tedious
• Trick \ps@empty to be \ps@fancy → has to be undone later on!
• Use \xpatchcmd from xpatch package and replace \thispagestyle{empty} by nothing or by \thispagestyle{fancy}.

The next issue is the page header rule → use \renewcommand{\headrulewidth}{0pt} to get rid off it.

The special formatting can be achieved with lastpage package and \number\value{page} of \pageref{LastPage} pages} in \cfoot. The lastpage package places the label LastPage (sic!!!) on -- you guess it already -- the last page!

\documentclass{llncs}

\usepackage{blindtext}
\usepackage{xpatch}
\usepackage{lastpage}

\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\number\value{page} of \pageref{LastPage} pages}
\pagestyle{fancy}

\xpatchcmd{\maketitle}{\thispagestyle{empty}}{}{}{}

\begin{document}
\title{Title}
\author{Author}
\institute{Institute\\
\email{email}}

\maketitle

\begin{abstract}

\end{abstract}

\section{Section1}
\blindtext[10]

\end{document}


• gives error: MiKTeX 2.9\tex\latex\fp\fp-basic.sty(57): Error: Undefined control sequence. – user2192774 Jul 21 '16 at 18:23
• It worked. Just noticed the packages you add. Thanks. – user2192774 Jul 21 '16 at 18:26

It can work with fancyhdr:

\documentclass{llncs}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
%
\pagestyle{fancy}
\cfoot{page \thepage\ of \pageref{LastPage}}
\title{Title}
\author{Author}
\institute{Institute\\
\email{email}}

\begin{document}
\maketitle
\thispagestyle{fancy}

\begin{abstract}
\lipsum[2]
\end{abstract}

\section{Section1}
\lipsum[1-12]

\end{document}