Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a document with two sets of tables. The first set, numbered 1 to 5, are in the main body of the text. The second, numbered 1 to 3, are in an appendix.

When I use \ref to link to one of the tables in the appendix, the hyperlink in the PDF file links to the corresponding table in the main section (so a link to appendix table 1 links to main table 1). This warning message is provided:

pdfTeX warning (ext4): destination with the same identifier (name{table.1}) 
   has been already used, duplicate ignored

Clearly this is a counter problem: when I reset the table counter in the appendix, there are two tables with a counter of 1 and hyperref just points to the first one.

Related problems have been discussed on this forum, and a number of discussions can be found online, but I haven't been able to figure out a solution to this particular problem. (It seems more straightforward to fix the problem for page numbers.) Also, I get the sense that the aliascnt package could work here, but I can't figure out how to make it work.

share|improve this question
    
What documentclass are you using, book? –  Werner Aug 25 '11 at 1:46
    
No, just article class. –  itzy Aug 25 '11 at 13:44
add comment

1 Answer

up vote 7 down vote accepted

Indeed, the problem comes from link anchors not having unique names. To provide those unique names, you can appropriately redefine \theHtable to guarantee that it will expand to a unique value (despite the counter resetting); for example:

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\section{test}
\renewcommand*{\theHtable}{\arabic{table}} 
\begin{table}
  \centering Test
  \caption{test1}\label{fig:test1}
\end{table}

\begin{table}
  \centering Test
  \caption{test2}\label{fig:test2}
\end{table}

\begin{table}
  \centering Test
  \caption{test3}\label{fig:test3}
\end{table}

\appendix

\setcounter{table}{0}
\renewcommand*{\theHtable}{\arabic{section}.\arabic{table}} 

\begin{table}
  \centering Test
  \caption{test4}\label{fig:test4}
\end{table}

\begin{table}
  \centering Test
  \caption{test5}\label{fig:test5}
\end{table}

\ref{fig:test1}\ref{fig:test2}\ref{fig:test3}\ref{fig:test4}\ref{fig:test5}

\end{document}
share|improve this answer
    
Great, thanks so much! –  itzy Aug 25 '11 at 13:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.