1

If I go into a figure environment, set the \caption first and then the subfigures, the figure-counter is increased by two. If i put the subfigures first and the \caption below, it is correctly increased by one.

It seems like \caption checks if the figure-counter was increased in the own environment, for subfigure it seems to not be that way.

As a workaround I found\addtocounter{figure}{-1}.

Is there an option to fix it with an optional argument?

\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}
2

1 Answer 1

0

This is a problem about the way scrartcl deals with captions. See tex.stackexchange.com/a/338685/113546. Use \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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .