![对我的子浮点的引用总是参考图 1a、1b 或 1c](https://linux22.com/image/264972/%E5%AF%B9%E6%88%91%E7%9A%84%E5%AD%90%E6%B5%AE%E7%82%B9%E7%9A%84%E5%BC%95%E7%94%A8%E6%80%BB%E6%98%AF%E5%8F%82%E8%80%83%E5%9B%BE%201a%E3%80%811b%20%E6%88%96%201c.png)
我有一份文件多种的包括带有子浮点数的图形,如下所示:
\documentclass[pdftex, a4paper, oneside]{scrartcl}
\usepackage[lofdepth,lotdepth]{subfig}
\usepackage{graphicx}
\begin{document}
test
\ref{fig:2ref1}
\ref{fig:1ref1}
\section{test}
\begin{figure}[h]
\subfloat[][caption1]{
\includegraphics[width=0.45\textwidth]{pictures/1.pdf}
\label{fig:1ref1}
}
\subfloat[][caption]{
\includegraphics{pictures/2.pdf}
\label{fig:1ref2}
}
\end{figure}
\section{test2}
\begin{figure}[h]
\subfloat[][caption]{
\includegraphics[]{pictures/1.pdf}
\label{fig:2ref1}
}
\subfloat[][captio]{
\includegraphics{pictures/2.pdf}
\label{fig:2ref2}
}
\end{figure}
\end{document}
现在的问题是和都 \ref{fig:2ref1}
作为 图片参考\ref{fig:1ref1}
返回1a
,即使它们是不同的图片并且应该是1a
和2a
。
答案1
正如我在评论中提到的,问题在于计数器没有增加,因为环境中figure
没有。如果您在每个图形内部、子浮点数之外添加标题,则可以获得所需的结果。\caption
figure
\documentclass[a4paper, oneside]{scrartcl}
\usepackage[lofdepth,lotdepth]{subfig}
\begin{document}
\ref{fig:1ref1}
\ref{fig:1ref2}
\ref{fig:2ref1}
\ref{fig:2ref2}
\begin{figure}[h]
\centering
\subfloat[][caption1]{
FIGURE 1A
\label{fig:1ref1}
}
\subfloat[][caption]{
FIGURE 1B
\label{fig:1ref2}
}
\caption{First figure}
\end{figure}
\begin{figure}[h]
\centering
\subfloat[][caption]{
FIGURE 2A
\label{fig:2ref1}
}
\subfloat[][captio]{
FIGURE 2B
\label{fig:2ref2}
}
\caption{Second figure}
\end{figure}
\end{document}
答案2
软件包subfig
文档指出,该命令\p@subfigure
被添加到参考文本的前面,并且默认为\thefigure
。由于您没有为图表添加标题,因此该命令始终为 1。在 MWE 中,您可能希望改为将其添加到前面\thesection
。因此这应该会有所帮助:
\makeatletter
\renewcommand{\p@subfigure}{\thesection}
\makeatother