Page Layoutpdflatex duplicate problem with hyperref package

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
bethes
Posts: 8
Joined: Mon Jan 11, 2010 7:33 pm

pdflatex duplicate problem with hyperref package

Post by bethes »

Hello everyone.

I have done some research into the particular problem I'm having, but so far I haven't been able to solve it. I have an 11 chapter Master document with equations, figures, tables, etc. in each chapter. All equations, tables, and figures are reset for each chapter. However, the resulting pdf using pdflatex and the hyperref package have problems when an equation, as one example, is linked (it happens with tables and figures as well, but sections and chapters are linked correctly). For example, Equation 1 in Chapter 5 will link to Equation 1 in Chapter 4.

I've made an MWE trying to show you my problem. I searched the error I receive and a solution was to use \pagenumbering and \setcounter{page} to ensure the page is unique. However, this does not seem to solve my problem.

I've attached my MWE files. I look forward to hopefully hearing some replies.

-Beth
Attachments
master.tex
(3.85 KiB) Downloaded 254 times
ch2.tex
(673 Bytes) Downloaded 211 times
ch1.tex
(683 Bytes) Downloaded 222 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

pdflatex duplicate problem with hyperref package

Post by frabjous »

Please review the Board Rules and the Post on Avoidable Mistakes; in particular with regard to the construction of minimal working examples. In particular your examples contain a lot of stuff, packages, etc., that are unrelated to the problem and it becomes difficult to sort it out. Many of us, also, do not use packages like psfig which are not part of a typical texlive distribution, and installing it just so I can compile your sample, where the problem most likely has nothing to do with that package, is kind of obnoxious. (I actually just deleted that line instead.)

Moreover, and more significantly, your sample code, at least for me, does not duplicate the problem. I compiled the document and opened it in both evince and Adobe Reader, and as far as I could, both the equation links worked just as one would expect.

It's generally considered good practice to avoid numbers in labels, so instead of:

Code: Select all

\label{eq:ch1-first-eq}
Try:

Code: Select all

\label{eq:ch-one-first-eq}
Or better yet, use a purely descriptive label. (And of course, change the \ref's appropriately.) I don't know whether or not that's the cause of your error, but at the moment, I can't tell what is causing your error, since I cannot duplicate it.
bethes
Posts: 8
Joined: Mon Jan 11, 2010 7:33 pm

Re: pdflatex duplicate problem with hyperref package

Post by bethes »

I am sorry for coming across as obnoxious. Those packages are used in my real document, and I should have removed them for the MWE. In the real document, descriptive names are used, and yet the problem of incorrect linking still occurs.

I will keep searching for an answer. Thanks for your time.
bethes
Posts: 8
Joined: Mon Jan 11, 2010 7:33 pm

pdflatex duplicate problem with hyperref package

Post by bethes »

All,

After playing with the code more, I found a workaround for myself regarding the pdflatex warning
! pdfTeX warning (ext4): destination with the same identifier (name{equation.1} ) has been already used, duplicate ignored <to be read again>
I placed

Code: Select all

\renewcommand{\theequation}{\thechapter.\arabic{equation}}
in ch1.tex and ch2.tex. This ensures that the equations are unique to each chapter (since I have the equation numbers reset at the start of each new chapter). I have redone the files for the MWE and have attached them.

I am not completely satisfied my solution is the best one, and as was already pointed out, the problem cannot be duplicated. Has anyone encountered an issue like this? I am using pdfTeX 3.14159... on a Redhat Enterprise Linux system.
Attachments
master.tex
(434 Bytes) Downloaded 229 times
ch2.tex
(694 Bytes) Downloaded 201 times
ch1.tex
(704 Bytes) Downloaded 210 times
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Re: pdflatex duplicate problem with hyperref package

Post by Montag »

Hm, I always use one of the KOMa classes and if I load hyperref, I also use \autoref instead of \ref.
But how come you play around with \setcounter and all these counters?
Maybe you should also use the Koma class report, meaning in the end your master file could look like in the attachments.

When one uses the article-class, the numbering does not have the form "section.equation" by default, but that is editable.
Attachments
master.tex
(407 Bytes) Downloaded 224 times
ch1.tex
(361 Bytes) Downloaded 226 times
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
bethes
Posts: 8
Joined: Mon Jan 11, 2010 7:33 pm

Re: pdflatex duplicate problem with hyperref package

Post by bethes »

Hi Enrico,

I think article class was chosen for a reason, and since I am working on the document with others, I cannot change it to be a report. I get the name or page duplication warning from pdfTeX for tables and figures, but not equations now. I am not sure if \autoref will solve that problem.

I am inclined to not use \hyperref at all since it is causing too many problems. Thanks for offering some help.
bethes
Posts: 8
Joined: Mon Jan 11, 2010 7:33 pm

pdflatex duplicate problem with hyperref package

Post by bethes »

Thanks to finding a similar issue on this forum, I solved my problem using

Code: Select all

\renewcommand{\thetable}{\thechapter.\arabic{table}}
\renewcommand{\theHtable}{\thechapter.\arabic{table}}
\renewcommand{\thefigure}{\thechapter.\arabic{figure}}
\renewcommand{\theHfigure}{\thechapter.\arabic{figure}}
The hypertext table and figure had to be renewed as well. Enrico asked why I was using \setcounter so much. Each new chapter was to start at the beginning for equations, tables, and figures.
Post Reply