如何正确且稳定的引用subfigure中的label?

发布于 2024-12-04 18:00:58

代码如下

\documentclass[%
 reprint,
 amsmath,amssymb,
 aps,
]{revtex4-2}

\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage{caption}    % For controlling captions
\usepackage{subcaption} % For subfigure
\usepackage{float}
\usepackage{hyperref}% add hypertext capabilities
\usepackage[mathlines]{lineno}% Enable numbering of text and display math
\usepackage{mwe}  % For example images
\begin{document}

\begin{figure*}[htbp]
    \centering
    % First row of images (subfigure 1 and subfigure 2)
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-a}
        \caption*{}\label{a}
    \end{subfigure}%
    \hspace{0.1cm}
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-b}
        \caption*{}\label{b}
    \end{subfigure}
    % Second row of images (subfigure 3 and subfigure 4)
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-c}
        \caption*{}\label{c}
    \end{subfigure}%
    \hspace{0.1cm}
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image}
        \caption*{}\label{d}
    \end{subfigure}
    \caption{Overall caption for the entire figure.}
    \label{fig2:mainfig}
\end{figure*}

In Fig.~\ref{fig2:mainfig}~(\ref{a}), (\ref{b}), and (\ref{c}), we show ...

\end{document}

编译之后无法正常显示In Fig. 1 (??), (??), and (??), we show ...

查看更多

关注者
0
被浏览
35
Sagittarius Rover
Sagittarius Rover 15小时前
我要成为TikZ糕手/(ㄒoㄒ)/~~

个人认为你这个问题的本质是revtex4-2的双栏布局和单栏的figure之间的冲突。当你使用article文档类时代码并没有什么问题;而使用revtex4-2出错,说明是revtex4-2的问题。好的问题题目会方便其他人检索到。

\caption*用法说明

image.png

要想引用必须有内容
(我不是太理解为什么你一定要藏起来subcaption的(a)(b)(c)(d)?这样读者很难快速定位到Fig.4(d)和Fig.8(e)指的是哪个吧)

https://www.latexstudio.net/index/details/index/mid/3922.html

源代码中的 \onecolumngrid\twocolumngrid 进行切换 (但我不是太懂revtex4-2...)

\documentclass[reprint,aps,amsmath,amssymb,]{revtex4-2}
\usepackage{graphicx}% Include figure files
\usepackage{subcaption} % For subfigure
\usepackage{float}
\usepackage{lipsum}
\usepackage{hyperref}% add hypertext capabilities
\begin{document}

\lipsum[1-9]

\onecolumngrid

\begin{figure*}[htbp]
    \centering
    % First row of images (subfigure 1 and subfigure 2)
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-a}
        \caption{}\label{a}
    \end{subfigure}%
    \hspace{0.1cm}
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-b}
        \caption{}\label{b}
    \end{subfigure}
    % Second row of images (subfigure 3 and subfigure 4)
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-c}
        \caption{}\label{c}
    \end{subfigure}%
    \hspace{0.1cm}
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image}
        \caption{}\label{d}
    \end{subfigure}
    \caption{Overall caption for the entire figure.}
    \label{fig2:mainfig}
\end{figure*}

\twocolumngrid

In Fig.~\ref{fig2:mainfig}~(\ref{a}), (\ref{b}), and (\ref{c}), we show ...

\lipsum[10-12]

\end{document}

image.png

1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览