I'm trying to put a conditional inside \cfoot from the fancyhdr package like this:
- if the document contains a one-page there will be no footer.
- if there are more pages the footer takes the format " \thepage of number of pages".
To set the number of pages i have used the lastpage package which provide the label LastPage allowing the user to refer to the last page of a document via \pageref{LastPage}.
When using \ifthenelse there is no problem
\documentclass{article}
\usepackage{lastpage}
\usepackage{ifthen}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{1pt}
\cfoot{\ifthenelse{\pageref{LastPage}>1}
{Page \thepage\ of \pageref{LastPage}}{}}
\begin{document}
\lipsum
\end{document}
But with the use of \ifnum produces an error:
!Missing = inserted for \ifnum
\documentclass{article}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{1pt}
\newcommand{\foo}{\pageref{LastPage}}
\cfoot{\ifnum\foo>1 Page \thepage\ of \pageref{LastPage}\fi}
\begin{document}
\lipsum
\end{document}
Where is the problem , with \ifnum and how to solve it ?
\getpagerefnumber{LastPage}(with\usepackage{refcount}) and not\pageref{LastPage}. With\ifthenelseit should work the same. – egreg Apr 01 '15 at 12:09