92

I have the following code for a Figure with 4 subfigures:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}[b]
    \centering
    \begin{subfigure}[b]{\textwidth}
        \includegraphics[width=\textwidth]{./plots/arm1.pdf}
        \subcaption{$Q^{*}$ values for arm 1}
        \label{fig:arm1}
    \end{subfigure}
    ~
    \begin{subfigure}[b]{\textwidth}
        \includegraphics[width=\textwidth]{./plots/arm2.pdf}
        \subcaption{$Q^{*}$ values for arm 2}
        \label{fig:arm2}
    \end{subfigure} 
    ~
    \begin{subfigure}[b]{\textwidth}
        \includegraphics[width=\textwidth]{./plots/arm3.pdf}
        \subcaption{$Q^{*}$ values for arm 3}
        \label{fig:arm3}
    \end{subfigure} 
    ~
    \begin{subfigure}[b]{\textwidth}
        \includegraphics[width=\textwidth]{./plots/arm4.pdf}
        \subcaption{$Q^{*}$ values for arm 4}
        \label{fig:arm4}
    \end{subfigure} 
    \caption{$Q^{*}$ values for different arms}
    \label{fig:arms}
\end{figure}

\end{document}

This results in this page

But this way, the 4 subfigures are too large to fit on 1 page. I would like to split this over 2 pages, keeping the subcaptions a, b, ... How can I do this?

JNevens
  • 1,469

1 Answers1

136

Split your figure into two figures and than to the second one immediately after \begin{figure} add command \ContinuedFloat. With this both figures will have the same caption number, however the sub captions numbering is continued from the previous figure:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[skip=0.5ex]{subcaption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

    \begin{document}
    \lipsum[1]
\begin{figure}[!b]
    \centering
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\linewidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 1}
        \label{fig:arm1}
    \end{subfigure}

\medskip
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\linewidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 2}
        \label{fig:arm2}
    \end{subfigure}
    \caption{$Q^{*}$ values for different arms}
\end{figure}%
\begin{figure}[ht]\ContinuedFloat
    \centering
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\linewidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 3}
        \label{fig:arm3}
    \end{subfigure}

\medskip
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\linewidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 4}
        \label{fig:arm4}
    \end{subfigure}
    \caption[]{$Q^{*}$ values for different arms (cont.)}
    \label{fig:arms}
\end{figure}
    \lipsum[2-3]
    \end{document}

enter image description here

Zarko
  • 296,517
  • When I do this, I get LaTeX Error: too many unprocessed floats. – JNevens Nov 18 '15 at 08:04
  • I doubt that just this figure is cause for this. If you test my MWE, you will not receive this error. For test you (temporary) omit command \ContinuedFloat and then see, if error still persist. – Zarko Nov 18 '15 at 09:31
  • 5
    Is there a way to prevent that latex inserts something else (e.g. a table or a text page) between the first figure and the second "ContinuedFloat" figure? – Robert Sep 23 '19 at 11:18
  • @Robert, in suggested solution this should not happen. I edit my answer and add some text to document which demonstrate this. – Zarko Sep 23 '19 at 11:36
  • 1
    @Zarke: "It should not happen" - famous last words... It definitely happened in a large text containing multiple figures and tables. I had a complete text page between the two figures. – Robert Sep 23 '19 at 12:00
  • @Robert, please ask new question and provide an example, which will confirm your claims. – Zarko Sep 23 '19 at 14:12
  • @Zarko That is impossible, the document it happens in has ~200 pages with quite a few images. It is nearly impossible to derive a minimum compilable example from it. At the moment the figures are back together, but I don't know why. – Robert Sep 23 '19 at 14:44
  • 3
    @Robert, sorry, I haven't crystal ball, than I would be able to see, what is going on in your document. So I can only repeat my "famous" words; in normal circumstances between floats as they are organized in MWE in my answer, this should not happen. – Zarko Sep 23 '19 at 15:32
  • 1
    @Zarko, is it possible to have only 1 caption in this Figure? I posted the question https://tex.stackexchange.com/questions/522618/is-it-possible-to-have-subfigure-a-b-c-page-1-and-c-d-page-2-w – aan Jan 02 '20 at 02:02
  • I also got to a "should not happen" situation in a longer document. If you replace the \lipsum sections in this example with real, long text you will see it happening too. – Luís de Sousa Jul 03 '20 at 14:04
  • 2
    @LuísdeSousa, I doubt in your claim. I wrote text book 500 page long with 100 figures, some of them formatted as suggested in answer, 30 tables and about 400 equations and all works fine. Cause of your problems is not the use of solution suggested in my answer but something else. – Zarko Jul 03 '20 at 14:38
  • 1
    This also works fine for me. I don’t believe something in LaTeX is length dependent. It would be like \alpha stops working after ~100 pages. So without a MWE showing the problem in other comments is impossible to see what’s going on – Luis Turcio May 31 '21 at 11:55