[Tex/LaTex] Use \captionof in conjunction with \subfigure

captionskoma-scriptsubfloats

I'm using the KOMA scrreprt class. I have a large figure with 6 subfigures, and a lengthy (but necessary!) caption explaining the figure that doesn't fit on the same page. I'm trying to use the \captionof command in a centering environment to produce a caption that will automatically wrap to the next page; something like

\begin{center}
  \begin{figure} [h!]
    \subfigure[ ]{ \includegraphics{picture1.pdf} }
    \subfigure[ ]{ \includegraphics{picture2.pdf} }
    ...
    \subfigure[ ]{ \includegraphics{picture3.pdf} }
  \end{figure}
  \captionof{figure}[Short caption]{Long caption explaining the whole figure}
\end{center}

The figure is getting repositioned to the end of the section (even with the h! float specifier), and the caption ends up dissociating from the figure so that they appear in completely different parts of the document. I assume this is because I am still using the figure environment? But I need this for subfigure to work. Using the H specifier from the float package helps – I get the caption and the figure on consecutive pages – but the caption still doesn't wrap the way I'd like, the figure is on its own page with no label, and the KOMA scrreprt class throws an error.

Is there either a) an alternative to subfigure that will handle labels in the same way, or b) a way to make \captionof play nicely with the figure float?


Edit:

Werner's answer below is excellent, but it has two small problems:

1) The figure itself now splits over two pages, so that the first two images are on a page with some other material. Is there a way to prevent this? (easily fixed with a \newpage command just above the figure)

2) Although the ToF entry is perfect, the reference numbering in the text is broken. I suspect that the figure is getting numbered as a table. Werner to the rescue again: \def\@currentlabel{\thefigure}\label{<label>} works with a slight quirk. I have assigned labels to each subfigure, and they all end up appearing the same in the compiled document, so subfigure specifiers – e.g. (a) – have to be added manually. The label redefinition can be added to the after page argument instead.

Best Answer

Since this seems like an out-of-the-ordinary setting for a figure, it may require some manual fiddling. The following example sets a list-like environment containing the "figure", and it allows your caption to break across the page boundary.

enter image description here

\documentclass{scrartcl}
\usepackage{graphicx,lipsum,afterpage,subcaption}
\usepackage{enumitem}
\begin{document}

\lipsum[1-5]

\makeatletter
\afterpage{\begin{center}
    \def\@captype{figure}% Fake a figure environment
    \subcaptionbox{Sub1}{\includegraphics[width=.2\linewidth]{example-image-a}} \qquad
    \subcaptionbox{Sub2}{\includegraphics[width=.2\linewidth]{example-image-a}} \qquad
    \subcaptionbox{Sub3}{\includegraphics[width=.2\linewidth]{example-image-a}} \par\bigskip
    \subcaptionbox{Sub4}{\includegraphics[width=.2\linewidth]{example-image-a}} \qquad
    \subcaptionbox{Sub5}{\includegraphics[width=.2\linewidth]{example-image-a}} \qquad
    \subcaptionbox{Sub6}{\includegraphics[width=.2\linewidth]{example-image-a}}
  \end{center}
  \addcontentsline{lof}{figure}{\protect\numberline{\thefigure}A length figure}% LoF entry
  \settowidth{\@tempdima}{Figure~\thefigure: }%
  \begin{itemize}[labelindent=\parindent,labelwidth=\@tempdima,rightmargin=\parindent,leftmargin=\dimexpr\@tempdima+\parindent]
    \item[Figure~\thefigure:]
    \lipsum[6-10]
  \end{itemize}
}
\makeatother

\lipsum[6-12]

\end{document}

The sub-figures are set using subcaption using the regular interface inside a center environment. A faked figure is initiated by defining the caption type \@captype. Setting of the caption is inside a regular list itemize with appropriate width settings (to match your other figures).

A short LoF-entry is set manually via \addcontentsline{lof}{figure}{<short entry>}. This is displayed with the inclusion of \listoffigures.

All of the above is passed to \afterpage (supplied by afterpage) in order to provide a seemless transition from page-to-page. One may play around with the spacing following the "figure". For example, adding something like \addvspace{\textfloatsep}.

The page layout was added via \usepackage{showframe} in the preamble; removed in the above code.