2

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}{}
\fancyhead[RO,RE]{Page \thepage\ of \pageref*{LastPage}}
\fancyhead[LO,LE]{\leftmark}

\begin{document}

% much content

% now the last page:
\thispagestyle{empty}
% content of the declaration
1
  • 3
    just put your own \label{zzz} on to the last page you want to count, and use \pageref{zzz} Jul 13, 2015 at 11:19

1 Answer 1

3

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}{}
\fancyhead[RO,RE]{Page \thepage\ of \reallastpage}
\fancyhead[LO,LE]{\leftmark}

\begin{document}

\kant

% now the last page:

\clearpage
\thispagestyle{empty}

{\Large Declaration}

\kant[1]

\end{document}

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .