# pdfTeX warning (ext4): destination with the same identifier (name{figure.1}) ha s been already used, duplicate ignored

% !TeX TS-program = pdflatex
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage{float}
\usepackage{graphicx}
\counterwithin{figure}{section}
\usepackage{hyperref}
%\counterwithin{figure}{section}
%\usepackage[all]{hypcap}
\begin{document}

\section{one}
\begin{figure}[H]
\centerline{\includegraphics[width=10cm]{example-image}}
\caption{example-image}
\end{figure}

\clearpage
\section{two}
\begin{figure}[htb]
\centerline{\includegraphics[width=11cm]{example-image-a}}
\caption{example-image-a}
\end{figure}

\end{document}


(pdftex.def) Requested size: 312.9803pt x 234.74237pt.
pdfTeX warning (ext4): destination with the same identifier (name{figure.1}) ha
s been already used, duplicate ignored
\relax
l.23 \caption{example-image-a}

and the Problem persist

hyperref patches \counterwithin but you use it before hyperref got the change of patching it. So use \counterwithin after loading the hyperref package and the problem should be gone.

The answer from Ulrike is just a work-around, trying to correct the damage done by the wrong package load and usage order. IMHO this is the wrong approach.

Means in this case: Load the package which provides \counterwithin first (not necessary here since it is offered by recent LaTeX kernels), load hyperref afterwards (so it can patch \counterwithin, and then (and only then) use \counterwithin.

Redefine \theHfigure so that it gives an unique identifier for the destination anchor:

\documentclass{article}
\usepackage{float}
\usepackage{graphicx}
\counterwithin{figure}{section}
\usepackage{hyperref}
%\counterwithin{figure}{section}
%\usepackage[all]{hypcap}
\renewcommand\theHfigure{\thesection.\arabic{figure}}
\begin{document}

\section{one}
\begin{figure}[H]
\centerline{\includegraphics[width=10cm]{example-image}}
\caption{example-image}
\end{figure}

\clearpage
\section{two}
\begin{figure}[htb]
\centerline{\includegraphics[width=11cm]{example-image-a}}
\caption{example-image-a}
\end{figure}

\end{document}

\counterwithin{figure}{section}
\usepackage[all]{hypcap}


in the preamble after the hyperref-package. In this case \counterwithin{figure}{section} aswell \usepackage[all]{hypcap} is enough, but sometimes you need both, also \usepackage{caption} often helps.

This question uses