[Tex/LaTex] Subfigure labelling for a single figure with REVTeX 4.2

cross-referencingfloats

Look at this piece of paper from an APS journal:

enter image description here

as you can see there is a single image (called figure 3) with already embedded the (a), (b), etc.. letters indicating different parts of the same figure.
If you look above it you can see they are able to reference the single parts of the figure (e.g. fig. 3(b)), but how is possible to do that since they don't have subfigures? My guessing was they were using phantom captions from the subcaption package, but this is not possible since this latter is not compatible with REVTeX 4.2 (that is the standard document package for APS journals). My question is: how can I obtain the same result?

Here you can find a Minimal Working Example of my attempt:

\documentclass{revtex4-2}
\usepackage[colorlinks,linkcolor=red,citecolor=red,urlcolor=red]{hyperref}
\usepackage[demo]{graphicx}

\begin{document}
    \begin{figure}
    \centering
    \includegraphics[width=\textwidth]{example-image-a}
\caption{Main caption here}
\label{fig:main}
\end{figure}

Suppose that figure \ref{fig:main} is already divided in part (a) and part (b). I want to reference part \ref{fig:main}a and part \ref{fig:main}b, 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}

enter image description here

Best Answer

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}

Example

Related Question