如果我进入一个figure
环境,设置第一个,\caption
然后设置subfigures
數字計數器增加了两个。如果我把subfigures
第一个和\caption
下面的都放上去,它就会正确地增加一个。
似乎\caption
检查數字計數器在自己的环境中有所增加,因为subfigure
事实似乎并非如此。
我发现了一种解决方法\addtocounter{figure}{-1}
。
是否有一个选项可以用可选参数来修复它?
\documentclass{scrartcl}
\usepackage{float}
\floatplacement{figure}{htbp}
\usepackage[labelfont=bf, font=small]{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
Nr.\ of figures (in figure): \arabic{figure}. \\
Start a \texttt{subfigure}
\begin{subfigure}{\textwidth}
\centering
Nr.\ of figures (in subfigure): \arabic{figure}.
\end{subfigure}
\caption{Nr.\ of figures: \arabic{figure}.}
\end{figure}
Nr.\ of figures: \arabic{figure}. \\
Counter \texttt{figure} increased by one.
\begin{figure}
\centering
\caption{Nr.\ of figures: \arabic{figure}.}
\begin{subfigure}{\textwidth}
\centering
Nr.\ of figures (in subfigure): \arabic{figure}
\end{subfigure}
\end{figure}
Nr.\ of figures: \arabic{figure}. \\
Counter \texttt{figure} increased by \textbf{two!}
\end{document}
答案1
scrartcl
这是处理字幕的方式的问题。请参阅tex.stackexchange.com/a/338685/113546。 使用\documentclass[captions=figureheading]{scrartcl}
。
\documentclass[captions=figureheading]{scrartcl}
\usepackage{float}
\floatplacement{figure}{htbp}
\usepackage[labelfont=bf, font=small]{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
Nr.\ of figures (in figure): \arabic{figure}. \\
Start a \texttt{subfigure}
\begin{subfigure}{\textwidth}
\centering
Nr.\ of figures (in subfigure): \arabic{figure}.
\end{subfigure}
\caption{Nr.\ of figures: \arabic{figure}.}
\end{figure}
Nr.\ of figures: \arabic{figure}. \\
Counter \texttt{figure} increased by one.
\begin{figure}
\centering
\caption{Nr.\ of figures: \arabic{figure}.}
\begin{subfigure}{\textwidth}
\centering
Nr.\ of figures (in subfigure): \arabic{figure}
\end{subfigure}
\end{figure}
Nr.\ of figures: \arabic{figure}. \\
Counter \texttt{figure} increased by \textbf{two!}
\end{document}