文本中交叉引用的图表给出了错误的标签

文本中交叉引用的图表给出了错误的标签

我正在尝试使用类似“Figure”的代码交叉引用文本中的图形\ref{Fig. 1.1}。在我的文档末尾,我有以下内容:

\section{Figures}

\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.6]{figures/Miech2021.png}
    \textbf{\caption{Prevalence of nicotine vaping among US $10\textsuperscript{th}$- and $12\textsuperscript{th}$-grade students, by year in grades 10, and 12 from 2017-2020 (from Miech et al., 2021)}}
    \label{Fig. 1.1}
\end{figure}
\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.5]{figures/Miech2019cannabis.png}
    \textbf{\caption{Trends in 30-day cannabis use prevalence in grades 8, 10, and 12 from 2015-2019 (from Miech et al., 2019: based on Table 5-5c)}}
    \label{Fig. 1.2}
\end{figure}
\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.7]{figures/Miech2019cigarettes.png}
    \textbf{\caption{Trends in 30-day prevalence in grades 8, 10, and 12 from 1975-2019 (from Miech et al., 2019: Figure 5-4q CIGARETTES)}}
    \label{Fig. 1.3}
\end{figure}

文内交叉引用显示为“图 1.3”。知道为什么当我引用图 1.1 时,文内显示为“图 1.3”吗?

答案1

正如大卫卡莱尔 (David Carlisle) 在评论中所指出的,你不应该包括\caption内部\textbf{…}(在这种情况下,你很可能会引用第 1.3 节,而不是图,因为\caption组内无法定义\label该组外部的引用)。

我建议改用\bfseries

\section{Figures}

\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.6]{figures/Miech2021.png}
    \bfseries \caption{Prevalence of nicotine vaping among US $10\textsuperscript{th}$- and $12\textsuperscript{th}$-grade students, by year in grades 10, and 12 from 2017-2020 (from Miech et al., 2021)}
    \label{Fig. 1.1}
\end{figure}
\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.5]{figures/Miech2019cannabis.png}
    \bfseries \caption{Trends in 30-day cannabis use prevalence in grades 8, 10, and 12 from 2015-2019 (from Miech et al., 2019: based on Table 5-5c)}
    \label{Fig. 1.2}
\end{figure}
\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.7]{figures/Miech2019cigarettes.png}
    \bfseries \caption{Trends in 30-day prevalence in grades 8, 10, and 12 from 1975-2019 (from Miech et al., 2019: Figure 5-4q CIGARETTES)}
    \label{Fig. 1.3}
\end{figure}

答案2

我建议您加载caption带有选项的包font=bf以便将标题加粗。

顺便说一句,我看不出在数学模式下进行处理的正当理由10\textsuperscript{th}12\textsuperscript{th}文本模式就很好。

在此处输入图片描述

\documentclass{article}
\usepackage[demo]{graphicx} % remove 'demo' option in real document
\usepackage[font=bf]{caption} % <-- new
\begin{document}

\section{Figures}

\begin{figure}[!ht]
\centering

    \includegraphics[scale=.6]{figures/Miech2021.png}
    \caption{Prevalence of nicotine vaping among US 10\textsuperscript{th}- and 12\textsuperscript{th}-grade students, by year in grades 10, and 12 from 2017--2020 (from Miech et al., 2021)}
    \label{Fig:1.1}

\bigskip\bigskip

    \includegraphics[scale=.5]{figures/Miech2019cannabis.png}
    \caption{Trends in 30-day cannabis use prevalence in grades 8, 10, and 12 from 2015--2019 (from Miech et al., 2019: based on Table 5-5c)}
    \label{Fig:1.2}

\bigskip\bigskip
    \includegraphics[scale=.7]{figures/Miech2019cigarettes.png}
    \caption{Trends in 30-day prevalence in grades 8, 10, and 12 from 1975--2019 (from Miech et al., 2019: Figure 5-4q CIGARETTES)}
    \label{Fig:1.3}
\end{figure}
\end{document}

相关内容