I'm trying to use hyperref to enable clickable content in my toc.
My main file:
\documentclass[12pt]{report}
\usepackage{ragged2e}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{color}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\renewcommand{\thesection}{\arabic{section}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead{}
\fancyfoot[C]{\includegraphics[height=0.8cm,width=0.75\linewidth]{image/logo}}
\fancyfoot[R]{Page \thepage \ of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\title{Report}
\begin{document}
\maketitle
\pagestyle{fancy}
\include{PartA}
\end{document}
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.
etc...
If i comment the
\pageref{LastPage}
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?
Thanks
Best Answer
I had also problems using
hyperref
andlastpage
. 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}}
works!