The code below is used to generate two side-by-side algorithms that float to the top of the page.
\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{caption}
\usepackage{hyperref}
\begin{document}
\begin{figure}[!t]
\begin{minipage}[t]{.475\linewidth}
\begin{algorithm}[H]
\caption{Foo}
\label{alg:foo}
\begin{algorithmic}
\State Hi
\end{algorithmic}
\end{algorithm}
\end{minipage}\hfill
\begin{minipage}[t]{.475\linewidth}
\begin{algorithm}[H]
\caption{Bar}
\label{alg:bar}
\begin{algorithmic}
\State Hi
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{figure}
\end{document}
The program works as expected except that hyperref generates warning
pdfTeX warning (ext4): destination with the same identifier (name{figure.caption.1}) has been already used, duplicate ignored
The warning still occurs even if there is only one minipage instead of two side-by-side, so I imagine it is from nesting algorithm[H] within figure.
How can the warning hyperref be fixed?
I have read this thread and all references therein but could not find the solution.
We are also happy to explore alternative ways to create side-by-side algorithms that avoid this issue altogether.
– jII Jun 14 '22 at 19:02\labelin the sample, so no way to use\cref. Thecleverefpackage is not loaded.\creflists a number, but there are no numbers here. There's also no list of figures in the sample. Should these have different numbers/LoF entries? As is, I don't see the problem. These will be on the same page, so what metadata are you worried about? Clicked links typically scroll the content so that the target is at the top of the screen. These start in the same place vertically, so clicking on a link to one will have identical effects to clicking a link to the other, no? – frabjous Jun 14 '22 at 21:01labelin the sample are\label{alg:foo}and\label{alg:bar}. At the highest level my question can be interpreted as an educational curiosity about how to fix the warnings by assigning different identifiers than {figure.caption.1}, leaving aside the downstream issues it causes in the end of application. – jII Jun 14 '22 at 21:06