1

How can I quote a integrated figure without sub-figure and make the generated hyperlink show as

Fig. 1(a)

in a RevTex documentclass, just like other published papers:

enter image description here

My code is

\documentclass[preprint,prl,aps]{revtex4-2}
\usepackage{graphicx}
\usepackage[colorlinks=true, citecolor=blue, urlcolor=blue, linkcolor=blue]{hyperref}
\begin{document}
\begin{figure}
 \includegraphics[width=8cm]{1}
   \caption{ \label{fig:a}(a) is the first part of the figure. \label{fig:b}(b) is the second \dots}
\end{figure}
In Fig.~\ref{fig:a}(a) we \dots
In Fig.~\ref{fig:b}(b) we \dots
\end{document}

Compiled results

enter image description here

I want to "1(a)" be blue as a hyperlink, not just "1".

2

You can use \autoref.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{hyperref}
\begin{document}
\begin{figure}[htb]
\centering     
\begin{subfigure}[b]{0.48\linewidth}
\centering\includegraphics[width=4cm]{example-image-a}
        \caption{Caption a.}
        \label{fig:a}
    \end{subfigure} 
\begin{subfigure}[b]{0.48\linewidth}
\centering\includegraphics[width=4cm]{example-image-b}
        \caption{Caption a.}
        \label{fig:b}
\end{subfigure}     
\caption{Overall caption.}
\end{figure}

In \autoref{fig:a} we \dots
\end{document}

enter image description here

If you use cleveref, use the nameinlink option.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}
\begin{document}
\begin{figure}[htb]
\centering     
\begin{subfigure}[b]{0.48\linewidth}
\centering\includegraphics[width=4cm]{example-image-a}
        \caption{Caption a.}
        \label{fig:a}
    \end{subfigure} 
\begin{subfigure}[b]{0.48\linewidth}
\centering\includegraphics[width=4cm]{example-image-b}
        \caption{Caption a.}
        \label{fig:b}
\end{subfigure}     
\caption{Overall caption.}
\end{figure}

In \Cref{fig:a} we \dots
\end{document}
  • Please allow me to clarify my problem. I can only include one picture, not like 2 pictures in your sample. And there is only one caption, without sub-caption, in compiled pdf file. – K M Jun 12 at 7:11
  • @KM If you replace the figure by \begin{figure}[htb] \centering \begin{subfigure}[b]{0.48\linewidth} \centering\includegraphics[width=4cm]{example-image-a} \caption{~} \label{fig:a} \end{subfigure} \caption{Overall caption.} \end{figure} it still works. BTW, I feel that this is a bit inefficient. You do not provide any TeX code, but then tell me mine is not what you want. How about you post some TeX code that others can use as a basis for an answer? – marmot Jun 12 at 7:16
1

You need to add the sublabels by hand.

\documentclass[preprint,prl,aps]{revtex4-2}
\usepackage{graphicx}
\usepackage[colorlinks=true, citecolor=blue, urlcolor=blue, linkcolor=blue]{hyperref}

\begin{document}

\begin{figure}
\includegraphics[width=8cm]{example-image}

\caption{(a) is the first part of the figure.(b) is the second \dots}
\label{fig:global}
\makeatletter
\let\save@currentlabel\@currentlabel
\edef\@currentlabel{\save@currentlabel(a)}\label{fig:a}
\edef\@currentlabel{\save@currentlabel(b)}\label{fig:b}
\makeatother
\end{figure}

In Fig.~\ref{fig:a} we \dots

In Fig.~\ref{fig:b} we \dots

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.