References to subfigures which appear more than once in the document not in right order

by Hessu   Last Updated July 12, 2019 13:23 PM - source

I have two figures A and B consisting of subfigures. Some subfigures appear in both of these figures. When I try to refer to the subfigures, the references appear in wrong order. For example:

\begin{document}

Figures \ref{fig:sub1}-\ref{fig:sub3} ...

\begin{figure}[H]
  \centering
  \begin{subfigure}{.5\textwidth}
    \includegraphics[width=\linewidth]{sub1.png}
    \caption{Sub 1.}
    \label{fig:sub1}
  \end{subfigure}
\begin{subfigure}{.5\textwidth}
    \includegraphics[width=\linewidth]{sub2.png}
    \caption{Sub 2.}
    \label{fig:sub2}
  \end{subfigure}
\begin{subfigure}{.5\textwidth}
    \includegraphics[width=\linewidth]{sub3.png}
    \caption{Sub 3.}
    \label{fig:sub3}
  \end{subfigure}
\end{figure}

\begin{figure}[H]
  \begin{subfigure}{.5\textwidth}
    \includegraphics[width=\linewidth]{sub4.png}
    \caption{Sub 4.}
    \label{fig:sub4}
  \end{subfigure}
\begin{subfigure}{.5\textwidth}
    \includegraphics[width=\linewidth]{sub1.png}  % <- appears second time
    \caption{Sub 1.}
    \label{fig:sub1}
  \end{subfigure}
\begin{subfigure}{.5\textwidth}
    \includegraphics[width=\linewidth]{sub5.png}
    \caption{Sub 5.}
    \label{fig:sub5}
  \end{subfigure}
\end{figure}

\end{document}

produces "Figures 2b-1c ..."

How can I get the reference of sub1 to stay as Figure 1a, and not 2b?



Related Questions




figref with subfigure and paratheses

Updated March 06, 2019 03:23 AM

Backreferences for equations

Updated June 16, 2017 17:23 PM