2

When using the scrbook document class in combination with the subcaption package, the numbering of subfigures seems broken. Consider:

\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{subcaption}
\captionsetup{%
  format=hang,%
  font=small,%
  labelfont={sf,bf},%
  aboveskip=0.2\normalbaselineskip,%
  position=top
}
\pagestyle{empty}

\begin{document}
\begin{figure}
  \caption{Black}
  \label{fig1}
  \centering
\rule{2cm}{2cm}
\end{figure}

\begin{figure}
  \caption{More figures}
  \label{fig2}
  \centering
  \begin{subfigure}{.3\textwidth}
    \centering
    \caption{Blue}
    \label{fig2a}
    \color{red}\rule{2cm}{2cm}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
    \centering
    \caption{Green}
    \label{fig2b}
    \color{green}\rule{2cm}{2cm}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
    \centering
    \caption{Blue}
    \label{fig2c}
    \color{blue}\rule{2cm}{2cm}
  \end{subfigure}
\end{figure}

Figure \ref{fig1} shows a black box. Figure \ref{fig2} shows colored
boxes, where Figure \ref{fig2a} shows a red box, Figure \ref{fig2b}
shows a green box, and Figure \ref{fig2c} shows a blue box.
\end{document}

This results in the following display: broken

Clearly, the figure numbering in the text references is off by one for the subfigures. Instead, if I change the document class to article, it looks fine:

fixed

Why does this happen, and how can I prevent it?

carsten
  • 2,966

1 Answers1

3

When using KOMA-Script the default setting is "captions are below figures". To change this, specify captions=figureheading, e.g.:

\documentclass[captions=figureheading]{scrbook}

What effect does this option have for KOMA-Script?

KOMA-Script needs this option to give you the correct vertical spacing between caption and figure.

What effect does this option have for the subcaption package?

The subcaption package needs to know when a figure starts and when a figure ends. Since one can place multiple captions inside one figure environment, "when a figure+caption starts" is not equal \begin{figure} and "when a figure+caption ends" is not equal \end{figure}.

See also:

https://tex.stackexchange.com/a/115632/2574 (Same problem, but with tables)

https://tex.stackexchange.com/a/98331/2574 (Same problem, but using subfig package)