# fancyhdr and lastpage: do not count last page

I am using fancyhdr and lastpage. I want to write a Bachlorthesis and the last page must be the statutory declaration wich should not be part of the page count. But this page is counted in LastPage. How can i get lastpage to not count this page ?

\setcounter{page}{\pageref*{LastPage}-1} is what i am looking for

\documentclass[a4paper]{report}

\usepackage{fancyhdr}
\usepackage{lastpage}

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

\begin{document}

% much content

% now the last page:
\thispagestyle{empty}
% content of the declaration

• just put your own \label{zzz} on to the last page you want to count, and use \pageref{zzz} – David Carlisle Jul 13 '15 at 11:19

You can use the zref package and decrease the generated number by 1.

\documentclass[a4paper,twoside]{report}

\usepackage{fancyhdr}
\usepackage[lastpage]{zref}

\usepackage{kantlipsum}

\makeatletter
\newcommand{\reallastpage}{%
\the\numexpr\zref@extractdefault{LastPage}{page}{0}-1\relax
}
\makeatother
\pagestyle{fancy}
\fancypagestyle{plain}{}

\begin{document}

\kant

% now the last page:

\clearpage
\thispagestyle{empty}

{\Large Declaration}

\kant[1]

\end{document}


As you can see, the declaration page is number 4.