Here's one possibility using a temporal counter. For me it wasn't clear why you used
\addtocounter{subfigure}{1}
but I respected this in my example codes below.
\documentclass{article}
\usepackage{subfigure}
\usepackage[demo]{graphicx}
\newcounter{tmp}
\begin{document}
\begin{figure}
\centering
\subfigure[a]{\includegraphics[width=0.31\linewidth]{fig1.pdf}}\hfill
\subfigure[b]{\includegraphics[width=0.31\linewidth]{fig2.pdf}}\hfill
\subfigure[c]{\includegraphics[width=0.31\linewidth]{fig3.pdf}}\\
\subfigure[d]{\includegraphics[width=0.31\linewidth]{fig4.pdf}}\hfill
\subfigure[e]{\includegraphics[width=0.31\linewidth]{fig5.pdf}}\hfill
\subfigure[f]{\includegraphics[width=0.31\linewidth]{fig6.pdf}}\\
\refstepcounter{tmp}
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\caption{title}
\label{fig:11}
\end{figure}
\begin{figure}
\centering
\refstepcounter{tmp}
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\addtocounter{figure}{-1}
\addtocounter{subfigure}{1}
\subfigure[g]{\includegraphics[width=0.31\linewidth]{fig7.pdf}}\hfill
\subfigure[h]{\includegraphics[width=0.31\linewidth]{fig8.pdf}}\hfill
\subfigure[i]{\includegraphics[width=0.31\linewidth]{fig9.pdf}}
\caption{title}
\label{fig:12}
\end{figure}
\end{document}
subfigure
is an obsolete package which shouldn't be used anymore; in its stead you should use subfig
or subcaption
. Here's the above approach, but using subfig
:
\documentclass{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\newcounter{tmp}
\begin{document}
\begin{figure}
\centering
\subfloat[a]{\includegraphics[width=0.31\linewidth]{fig1.pdf}}\hfill
\subfloat[b]{\includegraphics[width=0.31\linewidth]{fig2.pdf}}\hfill
\subfloat[c]{\includegraphics[width=0.31\linewidth]{fig3.pdf}}\\
\subfloat[d]{\includegraphics[width=0.31\linewidth]{fig4.pdf}}\hfill
\subfloat[e]{\includegraphics[width=0.31\linewidth]{fig5.pdf}}\hfill
\subfloat[f]{\includegraphics[width=0.31\linewidth]{fig6.pdf}}\\
\refstepcounter{tmp}
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\caption{title}
\label{fig:11}
\end{figure}
\begin{figure}
\centering
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\refstepcounter{tmp}
\addtocounter{figure}{-1}
\addtocounter{subfigure}{1}
\subfloat[g]{\includegraphics[width=0.31\linewidth]{fig7.pdf}}\hfill
\subfloat[h]{\includegraphics[width=0.31\linewidth]{fig8.pdf}}\hfill
\subfloat[i]{\includegraphics[width=0.31\linewidth]{fig9.pdf}}
\caption{title}
\label{fig:12}
\end{figure}
\end{document}
The demo
option for graphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.
Note that I only have REVTex4-1, I however assume the solution works also for REVTex4-2.
I achieved the results using a hacky tikz solution.
We use tikz to draw over the original plot. As subcaption is not available for REVTex, we use an empty subfig.
We first make an environment:
\newenvironment{captivy}[1]{%SETUP
\begin{tikzpicture}[every node/.style={inner sep=0}]
\node[anchor=south west,inner sep=0] (image) at (0,0) {#1};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
}%
{%TEARDOWN
\end{scope}%
\pgfresetboundingbox
\path[use as bounding box] (image.south west) rectangle (image.north east);
\end{tikzpicture}%
}
This includes our figure given as argument #1
on a tikz picture.
The last two lines in tikzpicture
are about the bounding box, that we don't create additional whitespace.
Next we create a command to creat captions within this environment:
\newcommand*{\oversubcaption}[3]{%
\draw (#1) node[fill=white,inner sep=0pt, opacity=0.2, above, yscale=1.1, xscale=1.1] {\phantom{(a)#2}};
\draw (#1) node[inner sep=0pt, above]{%
\subfloat[#2\label{#3}]{\phantom{(a)}}
% % \subcaption{#2}\label{#3}
};
}
As we cannot use \subcaption
, we replaced it by \subfloat
. We put the empty image \phantom(a)
, and add the label argument #3
. Addtionally we can provide a caption #2
. The first argument #1
specifies the position of the caption and label.
(The first line adds a transparent background, you can omit it if you don't like it.)
The rest of the document would then be
\documentclass{revtex4-1}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage[caption=false]{subfig}
\usepackage[colorlinks,linkcolor=red,citecolor=red,urlcolor=red]{hyperref}
\begin{document}
\begin{figure}
\centering
\begin{captivy}{\includegraphics[width=.5\textwidth]{example-image-a}}
\oversubcaption{0.2, 0.9}{}{fig:suba}
\oversubcaption{0.7, 0.9}{}{fig:subb}
\end{captivy}
\caption{Main caption here}
\label{fig:main}
\end{figure}
Suppose that figure \ref{fig:main} is already divided in part \subref{fig:suba} and part \subref{fig:subb}.
I want to reference part \ref{fig:suba} and part \ref{fig:subb}, but if I do like this only the number is \textit{clickable}, not the letter.
Moreover I have to write manually the letter.
A workaround I have found is \hyperref[fig:main]{\ref{fig:main}a}, but I am still not satisfied because I still have to write the letter manually.
\end{document}
Best Answer
Seems that when you have the
\caption
inside and the\label
outside thecenter
environment, the\label
doesn't "see" the\caption
, and instead attaches itself to something else, likely a\section
. But it's recommended to use\centering
instead of thecenter
environment anyways (see Should I use center or centering for figures and tables?), so do that and it works fine. Or put the label inside the environment.