LaTeX forum ⇒ GeneralBasic 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.
User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Basic problem with frontmatter/backmatter and the hyperref package

Postby Cham » Mon Dec 04, 2017 9:40 pm

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) :

  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[11pt,twoside]{book}
  3. \usepackage[]{hyperref}
  4.  
  5. \begin{document}
  6.  
  7. \title{Title}\author{Thyrion Lanister}\date{1472}
  8. \maketitle
  9. \thispagestyle{empty}
  10.  
  11. \cleardoublepage
  12. \pagestyle{plain}
  13.  
  14. \frontmatter
  15.  
  16. \section*{\centering Introduction} % Probably the wrong way to add an introduction (preface).
  17.  
  18. Some introduction.
  19.  
  20. \tableofcontents
  21.  
  22. \mainmatter
  23.  
  24. \chapter{A funny title}
  25.  
  26. Some boring text in the first chapter.
  27.  
  28. \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
<to be read again>
\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?

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Mon Dec 04, 2017 9:56 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! :oops:

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.

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Dec 04, 2017 9:59 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.

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Mon Dec 04, 2017 10:01 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! :oops:


Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests