1

I have 4 subfigures that I want to be presented across two pages, with 2 on each page. (Each set of two subfigs is large enough to take the entire page). I followed the suggestions here: Split subfigures over multiple pages I went through the comments, but there were no solutions there.

However, whatever I try, LaTeX always inserts content between the first set of two subfigures and the last set (i.e. text and tables). Is there a way to force the subfigures to be shown after one another, please?

My code:

    \begin{figure}[!b]
    \centering
    \begin{subfigure}{0.85\textwidth}
        \includegraphics[width=\linewidth]{path}
        \subcaption{}
        \label{fig:label}
    \end{subfigure}
\medskip
\begin{subfigure}{0.85\textwidth}
    \includegraphics[width=\linewidth]{path}
    \subcaption{}
    \label{fig:label2}
\end{subfigure}

\end{figure}%

% Add a page break here %\clearpage

\begin{figure}[ht]\ContinuedFloat \centering \begin{subfigure}{0.85\textwidth} \includegraphics[width=\linewidth]{path} \subcaption{} \label{fig:label3} \end{subfigure}

\medskip
\begin{subfigure}{0.85\textwidth}
    \includegraphics[width=\linewidth]{path}
    \subcaption{}
    \label{fig:label4}
\end{subfigure}
\caption[]{Caption text }
\label{fig:figlabel}

\end{figure}

Thanks :)

Edit:

After the figure, I have a new subsection and then a table definition (this table is showing up in between the subfigs:

\renewcommand{\arraystretch}{2}
    \begin{longtable}[htp]{ >{\centering\arraybackslash}m{0.15\textwidth} >{
                \arraybackslash}m{0.325\textwidth} >{\arraybackslash}m{0.325\textwidth} }
        \caption{caption } \\
        \label{tab:label}
        \textbf{Text} & \textbf{Text} & \textbf{Text}\\ \midrule 
        \endfirsthead
        \textbf{Text} & \textbf{Text} & \textbf{Text}\\ \midrule
         \endhead
    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\ 

    \midrule

    Text & Text & Text \\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \bottomrule
\end{longtable}

It's text heavy.

  • 1
    If your figures are really large enough to take up an entier page, you should use [p] floats. – John Kormylo Jan 25 '24 at 17:09
  • I was able to reproduce the problem by starting the longtable before the first page float was printed. That is, not enough text was provided to fill the first page. The first float was already moved to \@botlist while the second float was still in \@deferlist. Add \newpage before the longtable. – John Kormylo Jan 25 '24 at 17:32
  • @JohnKormylo this seemed to fix the issue. Thanks! – wiltabone Jan 28 '24 at 17:29

2 Answers2

1

It should suffice to replace \begin{figure}[ht] with \begin{figure}[t!].

Incidentally, there's no need to write \subcaption inside a subfigure environment; \caption will do just fine.

enter image description here

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{subcaption,graphicx,lipsum}

\begin{document}

\lipsum[1] % a paragraph of filler text

\begin{figure}[!b] \centering \begin{subfigure}{0.85\textwidth} \includegraphics[width=\linewidth]{patha} \caption{abcdef} \label{fig:labela} \end{subfigure}

\medskip
\begin{subfigure}{0.85\textwidth}
    \includegraphics[width=\linewidth]{pathb}
    \caption{ghijkl}
    \label{fig:labelb}
\end{subfigure}

\caption{Stuff}
\label{fig:label}

\end{figure}

\begin{figure}[t!] \ContinuedFloat \centering \begin{subfigure}{0.85\textwidth} \includegraphics[width=\linewidth]{pathc} \caption{mnopqr} \label{fig:labelc} \end{subfigure}

\medskip
\begin{subfigure}{0.85\textwidth}
    \includegraphics[width=\linewidth]{pathd}
    \caption{stuvwx}
    \label{fig:labeld}
\end{subfigure}

\caption{Stuff, continued}

\end{figure}

\lipsum[2-5] % four more paragraphs of filler text

\end{document}

Mico
  • 506,678
  • Unfortunately, I still have the same issue, with the next set showing up two pages down the line after the table. Could it be because the table is declared as such? \begin{longtable}[htp] – wiltabone Jan 25 '24 at 12:06
  • @wiltabone - Sadly (but maybe not surprisingly), my psychic divination skills are utterly worthless. If you want to improve the odds of somebody figuring out how to help you with a complex document setup, do please edit your posting to provide all relevant, but so far missing, information. E.g., have you queued up a table float before starting the figure floats? – Mico Jan 25 '24 at 12:23
  • The command \begin{longtable}[htp] contains at least one syntax error and one meaningless element. First, a longtable environment takes a mandatory argument, which you don't appear to provide: The list of column types. E.g., \begin{longtable}{|lcccc|}, for a five-column table bounded on both sides by vertical rules. Second, the positioning specifier [htp] does nothing at all here, since longtable environments aren't floats (in the LaTeX-specific sense of the term). – Mico Jan 25 '24 at 15:17
  • There is no table queued before the figure. Following that is a block of text and the start of a new subsection. Then the long table argument is created: {\renewcommand{\arraystretch}{2} \begin{longtable}[htp]{ >{\centering\arraybackslash}m{0.2\textwidth} | >{ \arraybackslash}m{0.4\textwidth} >{\arraybackslash}m{0.4\textwidth} } – wiltabone Jan 25 '24 at 16:15
  • I have amended my question above with the declaration in full. – wiltabone Jan 25 '24 at 16:27
0

Here is the full MWE I used to replicate the problem.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{lipsum}
\usepackage{duckuments}% don't ask
\begin{document}

\begin{figure}[!b] \begin{subfigure}{\textwidth} \centering \includegraphics{example-image-duck} \caption{} \label{fig:label} \end{subfigure}

\medskip
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics{example-image-duck}
    \caption{}
    \label{fig:label2}
\end{subfigure}

\end{figure}%

\begin{figure}[t!]\ContinuedFloat \begin{subfigure}{\textwidth} \centering \includegraphics{example-image-duck} \caption{} \label{fig:label3} \end{subfigure}

\medskip
\begin{subfigure}{\textwidth}
    \centering
    \includegraphics{example-image-duck}
    \caption{}
    \label{fig:label4}
\end{subfigure}
\caption[]{Caption text }
\label{fig:figlabel}

\end{figure}

\lipsum[1]

%\newpage \renewcommand{\arraystretch}{2} \begin{longtable}[htp]{ >{\centering\arraybackslash}m{0.15\textwidth} >{ \arraybackslash}m{0.325\textwidth} >{\arraybackslash}m{0.325\textwidth} } \caption{caption } \ \label{tab:label} \textbf{Text} & \textbf{Text} & \textbf{Text}\ \midrule \endfirsthead \textbf{Text} & \textbf{Text} & \textbf{Text}\ \midrule \endhead

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\ 

    \midrule

    Text & Text & Text \\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \midrule

    Text & Text & Text\\

    \bottomrule
\end{longtable}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120