子图设置图形计数器错误

子图设置图形计数器错误

如果我进入一个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}

在此处输入图片描述

相关内容