I have a figure caption that is too long to fit in the same page of the image. I would like to precede the image with a little bit of text and start the next page by the caption, then followed by text as in this picture:
(I'm using sections because I need the figure to not be sent too far from Section 1)
Here is the code of the closest I could get to it:
\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[english]{babel}
\usepackage{caption}
\usepackage{afterpage}
\usepackage{environ}
\usepackage{mwe}
\newsavebox{\doublepagecaption}
\newsavebox{\doublepageimage}
\NewEnviron{doublepagefigure}[2][]% #1=short caption (optional), #2=caption
{\global\setbox\doublepagecaption=\hbox{%
\parbox{\textwidth}{\captionof{figure}[#1]{#2}}}%
\global\setbox\doublepageimage=\hbox{\parbox{\textwidth}{\BODY}}%
\afterpage{
\ifodd\value{page}%
\afterpage{%
\vspace*{\fill}\vspace{-\baselineskip}%
\noindent\usebox{\doublepageimage}\vfill\pagebreak
\begin{figure}[b]\usebox{\doublepagecaption}\end{figure}}%
\else
\vspace*{\fill}\vspace{-\baselineskip}%
\noindent\usebox{\doublepageimage}\vfill\pagebreak
\begin{figure}[b]\usebox{\doublepagecaption}\end{figure}%
\fi}}
\renewcommand{\bottomfraction}{0.5}% fraction of page allowed for bottom floats
\begin{document}
\section{Section 1}
\lipsum[1]
\begin{doublepagefigure}[(Caption next page.)]{\textbf{\lipsum[2-3]}\label{fig:test1}}
\centering{
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig1}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig2}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig3}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig4}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig5}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig6}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig7}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig8}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}
\caption{vero eos et accusamus et}\label{subfig9}
\includegraphics[width=0.3\linewidth]{example-image}
\end{subfigure}
}
\end{doublepagefigure}
\lipsum[4-7]
\section{Section 2}
\lipsum[8-10]
\end{document}
using the code from John (Figure on an even page and caption on the following page), and here is what I get:
Problems I can't solve:
(1) the subfigures come out clustered,
(2) captions of the subfigures don't come out,
(3) the caption is at the bottom of the next page instead of top (comes from \renewcommand{\bottomfraction}{0.5}
but "topfraction" or a lower fraction will push the caption to a 4th page),
(4) there is no text above the figure,
(5) I don't necessarily need the figure to be on an even page.
How can it be done properly?
\renewcommand{\bottomfraction}{0.5}
.