I'm trying to use hyperref to enable clickable content in my toc.

My main file:



\fancyfoot[R]{Page \thepage \ of \pageref{LastPage}}






But i'm getting an error:

File        | Type   | Line   | Message

Report.tex  | Error | line 60 | !Argument of Hy@setref@link has an extra }. <inserted text>\par \include{PartA}

Report.tex  | Error | line 60 | !Paragraph ended before \Hy@setref@link was complete. <to be read again>\par \include{PartA}

Report.tex  | Error | line 60 | !Extra }, or forgotten \endgroup.


If i comment the


The report compiles and works ok.

\fancyfoot[R]{Page \thepage \ of } %\pageref{LastPage}}

So i don't know why lastpage doesn't work with hyperref. Can anyone help me?


  • 2
    Your posted code works for me. So perhaps something else in your PartA is triggering the problem. – Andrew Swann Apr 6 '17 at 10:31
  • 2
    Could you please use a package for blind text, such as lipsum or kantlipsum to produce several pages with text? (instead of \include{...}-ing something we don't have.) If I do so, your example works for me. – AlexG Apr 6 '17 at 10:32

I had also problems using hyperref and lastpage. The error

... LaTeX Warning: Reference `LastPage' on page 2 undefined on input line 12.

My rhead looked like this \rhead{\footnotesize \thepage/\pageref{LastPage}} I stumbled over this question Hyperref marks lastpage as a reference and the used the same solution, i.e. replacing \pageref with \pageref*.

\rhead{\footnotesize \thepage/\pageref*{LastPage}}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.