## LaTeX forum ⇒ General ⇒ Basic problem with frontmatter/backmatter and the hyperref package Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
Cham
Posts: 826
Joined: Sat Apr 02, 2011 4:06 pm

### Basic problem with frontmatter/backmatter and the hyperref package

Arrgh ! I thought that I was understanding this basic thing with the book class. Apparently, I'm doing something obviously wrong. The following MWE code reproduce my issue (the console isn't clear about the cause of the problem) :

\RequirePackage[l2tabu,orthodox]{nag}\documentclass[11pt,twoside]{book}\usepackage[]{hyperref} \begin{document} \title{Title}\author{Thyrion Lanister}\date{1472}\maketitle\thispagestyle{empty} \cleardoublepage\pagestyle{plain} \frontmatter \section*{\centering Introduction} % Probably the wrong way to add an introduction (preface). Some introduction. \tableofcontents \mainmatter \chapter{A funny title} Some boring text in the first chapter. \end{document}

The error stops the compilation, and is clearly related to the hyperref package and is about referencing items. I have seen this problem a long time ago, but don't remember how it was fixed.

I'm getting this error message in the console :
pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignored
\relax
l.28 \end{document}

So what is wrong with the code above?

And what is the proper way in defining a "preface" (or "foreword"), which should be a centered title, without a chapter style?

Cham
Posts: 826
Joined: Sat Apr 02, 2011 4:06 pm
Argh again! Pretty obvious in a way : I had to put the \frontmatter command just after the \begin{document}, not later in the code. Appears to solve the issue. I was obviously forgetting things!

Still not sure of the way I should define the introduction (preface), though.
Last edited by Cham on Mon Dec 04, 2017 9:59 pm, edited 1 time in total.

Johannes_B
Site Moderator
Posts: 3600
Joined: Thu Nov 01, 2012 4:08 pm
Your titlepage is part of the document. It is, in case, the very first page. Page number one.
But later, there is another page numbered one, so package hyperref gets confused where to put the links.

Either, except that the titlepage is a physical page and has a number and that the introduction is on paage 5 (or whatever), or use a differet numbering screen, such as alph. The pages have no (visible) page number anyway.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 826
Joined: Sat Apr 02, 2011 4:06 pm
Thanks Johannes. But I solved the issue : as you said, the title page is a physical page number 1 in the document, so \frontmatter should be declared before it.

I'm wondering : How would you define a "foreword" (or preface) in a book class ? The way I've done it feels like a hack!