\subcaptionbox 中被抑制的数字仍然会增加数字计数器

\subcaptionbox 中被抑制的数字仍然会增加数字计数器

我想抑制某些图形的编号。在单个图形中,使用\caption*效果很好 - 参见下面 MWE 中的前两张图片。但是,当我在图形环境中有两个子图(使用 设置\subcaptionbox)时,使用\caption*\subcaptionbox*确实会抑制图形编号,但图形计数器会更新,导致图形编号“丢失”。在下面的 MWE 中,我希望最后一个图形是数字 2 - 因为它是第二个编号的图形,但它的编号是 3。有人能帮我解决这个问题吗?

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}

\begin{figure}[h] %first figure - nonnumbered
\centering
\includegraphics[width=4cm]{chick}
\caption*{Non-numbered single chick}
\end{figure}

\begin{figure}[h] %second figure, but first numbered figure - counter should be 1
\centering
\includegraphics[width=4cm]{chick}
\caption{Numbered single chick}
\end{figure}

\begin{figure}[h] %third figure, nonnumbered
\centering
\subcaptionbox*{chick}[4cm]{\includegraphics{chick}}\hspace{1cm}
\subcaptionbox*{chick}[4cm]{\includegraphics{chick}}
\caption*{Two non-numbered chicks}
\end{figure}

\begin{figure}[h] %fourth figure, numbered, counter should be 2, but is 3
\centering
\subcaptionbox{chick}[4cm]{\includegraphics{chick}}\hspace{1cm}
\subcaptionbox{chick}[4cm]{\includegraphics{chick}}
\caption{Two numbered chicks}
\end{figure}
\end{document}

答案1

\subcaption*命令无条件增加父计数器。正如 John Kormylo 所建议的,一种解决方法是添加

\addtocounter{figure}{-1}

就在之前\caption*

示例输出

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}[ht]
\centering
\includegraphics[width=4cm]{chick}
\caption*{Non-numbered single chick}
\end{figure}

\begin{figure}[ht]
\centering
\includegraphics[width=4cm]{chick}
\caption{Numbered single chick}
\end{figure}

\begin{figure}[ht]
\centering
\subcaptionbox*{chick}[4cm]{\includegraphics{chick}}\hspace{1cm}
\subcaptionbox*{chick}[4cm]{\includegraphics{chick}}
\addtocounter{figure}{-1}
\caption*{Two non-numbered chicks}
\end{figure}

\begin{figure}[ht]
\centering
\subcaptionbox{chick}[4cm]{\includegraphics{chick}}\hspace{1cm}
\subcaptionbox{chick}[4cm]{\includegraphics{chick}}
\caption{Two numbered chicks}
\end{figure}

\end{document}

在包中纠正这个问题subcaption似乎并不容易。

相关内容