Page Layout ⇒ pdflatex duplicate problem with hyperref package
pdflatex duplicate problem with hyperref package
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
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 255 times
-
- ch2.tex
- (673 Bytes) Downloaded 211 times
-
- ch1.tex
- (683 Bytes) Downloaded 222 times
NEW: TikZ book now 40% off at Amazon.com for a short time.

pdflatex duplicate problem with hyperref package
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:
Try:
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.
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}
Code: Select all
\label{eq:ch-one-first-eq}
Re: pdflatex duplicate problem with hyperref package
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.
I will keep searching for an answer. Thanks for your time.
pdflatex duplicate problem with hyperref package
All,
After playing with the code more, I found a workaround for myself regarding the pdflatex warning 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.
After playing with the code more, I found a workaround for myself regarding the pdflatex warning
I placed! pdfTeX warning (ext4): destination with the same identifier (name{equation.1} ) has been already used, duplicate ignored <to be read again>
Code: Select all
\renewcommand{\theequation}{\thechapter.\arabic{equation}}
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 230 times
-
- ch2.tex
- (694 Bytes) Downloaded 202 times
-
- ch1.tex
- (704 Bytes) Downloaded 211 times
Re: pdflatex duplicate problem with hyperref package
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.
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 228 times
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
Re: pdflatex duplicate problem with hyperref package
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.
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.
pdflatex duplicate problem with hyperref package
Thanks to finding a similar issue on this forum, I solved my problem using
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.
Code: Select all
Code, edit and compile here:
\renewcommand{\thetable}{\thechapter.\arabic{table}}\renewcommand{\theHtable}{\thechapter.\arabic{table}}\renewcommand{\thefigure}{\thechapter.\arabic{figure}}\renewcommand{\theHfigure}{\thechapter.\arabic{figure}}