0

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)

Image of result I'm looking for

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:

enter image description here

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?

  • Removing the even/odd requirement allows one to use normal floats. The only thing you really needed was \renewcommand{\bottomfraction}{0.5}. – John Kormylo Sep 19 at 20:54
0

Just to show how to make the code work for your example. Note that the subcaption package requires a width argument for subfigure (and \def\@captype{figure}). OTOH, one no longer needs to use the caption package (no \captionof).

Also, the short caption is intended for the \listoffigures.

\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[english]{babel}
\usepackage{subcaption}
\usepackage{afterpage}
\usepackage{environ}
\usepackage{mwe}

\newsavebox{\doublepagecaption}
\newsavebox{\doublepageimage}
\makeatletter
\NewEnviron{doublepagefigure}[2][]% #1=short caption (optional), #2=caption
{\def\@captype{figure}%
 \global\setbox\doublepagecaption=\vbox{\caption[#1]{#2}}%
 \global\setbox\doublepageimage=\vbox{\BODY}%
 \afterpage{%
 \ifodd\value{page}%
   \afterpage{%
    \vspace*{\fill}\vspace{-\baselineskip}%
    \noindent\usebox{\doublepageimage}\vfill\pagebreak
    \begin{figure}[t]\usebox{\doublepagecaption}\end{figure}}%
 \else
   \vspace*{\fill}\vspace{-\baselineskip}%
   \noindent\usebox{\doublepageimage}\vfill\pagebreak
   \begin{figure}[t]\usebox{\doublepagecaption}\end{figure}%
 \fi}}
\makeatother

\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}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig1}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig2}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig3}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig4}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig5}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig6}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig7}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig8}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
    \caption{vero eos et accusamus et}\label{subfig9}
    \includegraphics[width=\linewidth]{example-image}
\end{subfigure}
\end{doublepagefigure}


\lipsum[4-7]

\section{Section 2}

\lipsum[8-10]

\end{document}
  • It works thanks!! Comprehension question: why did you have to switch from horizontal to vertical box? And also: how can I get (1) some text above the figure, (2) "Figure X: (Caption next page)" below the figure, as in my example? – Elsa Sep 20 at 0:52
  • I actually reposted as a proper question here: tex.stackexchange.com/questions/509019/… to be clearer. – Elsa Sep 20 at 2:41
  • That was just a simplification and style improvement. I plan to go back and fix up the original answer as well. You can put text or captions into the body of the environment, although you might need to back up the back up the caption counter or use \ContinuedFloat (caption package). – John Kormylo Sep 20 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.