latexhyperref

LaTeX - two pages "1" with package hyperref


When compiling a LaTeX document, I get two pages numbered at "1": the front page and the first of the table of contents. Here's a MWE:

\documentclass[12pt,a4paper]{report}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\title{Title}

\begin{document}
\maketitle
\tableofcontents
\chapter{Chapter one}
\end{document}

When compiling this (using simply pdflatex file.tex), I get this:

enter image description here But when I remove the line \usepackage{hyperref}, page numbers are fine. Note that I need this package to have links to pages in my table of contents, but maybe there's a better way to do so. What is happening here ? How do I get normal page numbers ?

Thanks in advance.


Solution

  • \maketitle under the report class sets the page number to 1 on the title page, but also restarts it from 1 for the following page. That's why you achieve a virtual page number 1 for the title, followed by an actual page number one for the ToC. I emphasize virtual here because \maketitle sets the title on an empty page style so that nothing is printed in the header/footer. However, these page numbers still appear in the toolbar when viewed in Adobe Acrobat.

    One way around it would be to manually change the page display to something more appropriate just for the title page. For example, let's make the title page be called T:

    enter image description here

    \documentclass{report}
    
    \usepackage{hyperref}
    
    \title{Title}
    \author{Author}
    
    \begin{document}
    
    \begingroup
    \renewcommand{\thepage}{T}
    \maketitle % Page T
    \endgroup
    
    \tableofcontents % Page 1
    
    \chapter{A chapter} % Page 2
    
    \end{document}