带节号的图形编号,子图问题

带节号的图形编号,子图问题

我将论文中的图形编号改为章节样式编号:

\numberwithin{figure}{section}

这很好,但以下 MWE 中仍然存在唯一的问题:

\documentclass[english,12pt]{article}
\usepackage{float}
\usepackage{subfigure}

\begin{document} 

\begin{figure}[H]
\centering
\subfigure[First temperature cycle. We measured additionally at +1$^{\circ}$C.]{
\includegraphics[width=0.98\textwidth]{./figures/mu_vs_v_1st.pdf}
\label{fig:mu_vs_v_1st}
}\\
\subfigure[Second temperature cycle. Note the difference to the first cycle of     1$^{\circ}$C in the highest temperature measured.]{
\includegraphics[width=0.98\textwidth]{./figures/mu_vs_v_2nd.pdf}
\label{fig:mu_vs_v_2nd}
}
\label{fig:mu_vs_v}
\end{figure}

\end{document}

在这里我得到了整个图形的章节样式编号(图 5.3 - 该图是第 5 节中的第三个图形),但我得到了图 7(a)和 7(b)以便直接参考子图(该图是整个论文中的第七个)。

我应该如何更改才能使子图也获得图 5.3(a) 和 5.3(b)?提前致谢!

答案1

您可以重新定义\p@subfigure哪些控件用于对子图的交叉引用的前缀:

\documentclass[english,12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{float}
\usepackage{amsmath}
\usepackage{subfigure}

\numberwithin{figure}{section}

\makeatletter
\renewcommand\p@subfigure{\thefigure}
\makeatother

\begin{document} 

\section{Test Section}

A reference to subfigures~\ref{fig:mu_vs_v_1st} and~\ref{fig:mu_vs_v_2nd}

\begin{figure}[H]
\centering
\subfigure[First temperature cycle. We measured additionally at +1$^{\circ}$C.]{%
\includegraphics[width=0.98\textwidth]{./figures/mu_vs_v_1st.pdf}
\label{fig:mu_vs_v_1st}%
}\\
\subfigure[Second temperature cycle. Note the difference to the first cycle of     1$^{\circ}$C in the highest temperature measured.]{%
\includegraphics[width=0.98\textwidth]{./figures/mu_vs_v_2nd.pdf}
\label{fig:mu_vs_v_2nd}
}
\caption{test figure with subfigures}
\label{fig:mu_vs_v}
\end{figure}

\end{document}

在此处输入图片描述

选项demo只是graphicx用黑色矩形替换实际图形;不是在实际文档中使用该选项。

顺便说一句,subfigure这是一个过时的软件包。你应该考虑使用subfig或者subcaption反而。

使用该subfig包还有一个额外的好处:您不需要重新定义,\p@subfigure因为包内部已经为您完成了这项工作:

在此处输入图片描述

\documentclass[english,12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{float}
\usepackage{amsmath}
\usepackage[listofformat=subparens]{subfig}

\numberwithin{figure}{section}

\begin{document} 

\section{Test Section}

A reference to subfigures~\ref{fig:mu_vs_v_1st} and~\ref{fig:mu_vs_v_2nd}. And another reference to subfigures~\ref{fig:mu_vs_v}\subref{fig:mu_vs_v_1st} and~\ref{fig:mu_vs_v}\subref{fig:mu_vs_v_2nd}

\begin{figure}[H]
\centering
\subfloat[First temperature cycle. We measured additionally at +1$^{\circ}$C.\label{fig:mu_vs_v_1st}]{%
\includegraphics[width=0.98\textwidth]{./figures/mu_vs_v_1st.pdf}}\\
\subfloat[Second temperature cycle. Note the difference to the first cycle of $1^{\circ}$C in the highest temperature measured.\label{fig:mu_vs_v_2nd}]{%
\includegraphics[width=0.98\textwidth]{./figures/mu_vs_v_2nd.pdf}}
\caption{test figure with subfigures}
\label{fig:mu_vs_v}
\end{figure}

\end{document}

相关内容