0

For some reasons, I need to define the captions before the tables with the help of the capt-of package. When I am trying to use the hyperref package, a conflict occurs with \addtocounter and the following warning is issued (but no obvious problem can be observed in the generated PDF file):

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

My sample code is the following:

\documentclass[a4paper,pra,aps,11pt]{revtex4-2}

\usepackage{float}
\usepackage{hyperref}
\usepackage{amsmath,amssymb}
\usepackage[english]{babel}
\usepackage{longtable}
\usepackage{capt-of}

\begin{document}

\captionof{table}{test A}
\begin{longtable}{l}
\end{longtable}
\addtocounter{table}{-1}
\makeatletter\def\@currentlabel{\thetable}\label{table:testA}

\captionof{table}{test B}
\begin{longtable}{l}
\end{longtable}
\addtocounter{table}{-1}
\makeatletter\def\@currentlabel{\thetable}\label{table:testB}

table~\ref{table:testA} and table~\ref{table:testB}

\end{document}

Could you please help me how to avoid this warning? Please don't suggest that I remove the capt-of package(..).

2

Use an additional counter:

\documentclass[a4paper,pra,aps,11pt]{revtex4-2}

\usepackage{float}
\usepackage{hyperref}
\usepackage{amsmath,amssymb}
\usepackage[english]{babel}
\usepackage{longtable}
\usepackage{capt-of}
\newcounter{abstable}
\renewcommand\theHtable{\arabic{abstable}.\thetable}
\begin{document}

\captionof{table}{test A}
\begin{longtable}{l}
\end{longtable}
\stepcounter{abstable}\addtocounter{table}{-1}
\makeatletter\def\@currentlabel{\thetable}\label{table:testA}

\captionof{table}{test B}
\begin{longtable}{l}
\end{longtable}
\stepcounter{abstable}\addtocounter{table}{-1}
\makeatletter\def\@currentlabel{\thetable}\label{table:testB}

table~\ref{table:testA} and table~\ref{table:testB}

\end{document}
  • It works! Thank you! – TobiR Oct 8 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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