1

I am trying to place multiple subfigures into 3 columns. I have large no. of figures to display. Naturally, keeping the figures visible for readers in an article, I am trying to fit 9 or 12 figures in a page. But using subfigures, the figures are entering footer zone and in the margin area. How to overcome this such that it does not happen. Suggest a way to arrange the figures such that they are presented beautifully throughout multiple pages.

My Code is given below: (for 12 images) The float, subcaption, caption, graphicx all the packages are there in preamble.

\begin{figure}[H]
\centering
\begin{subfigure}{0.3\textwidth}
    \centering
    \includegraphics[height=1.8in]{images/bfly-primary/2.png}
    \caption{2 by 2}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
    \centering
    \includegraphics[height=1.8in]{images/bfly-primary/3.png}
    \caption{3 by 3}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
    \centering
    \includegraphics[height=1.8in]{images/bfly-primary/4.png}
    \caption{4 by 4}
\end{subfigure}

\begin{subfigure}{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/5.png} \caption{5 by 5} \end{subfigure} \hfill \begin{subfigure}{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/6.png} \caption{6 by 6} \end{subfigure} \hfill \begin{subfigure}{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/7.png} \caption{7 by 7} \end{subfigure}

\begin{subfigure}{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/8.png} \caption{8 by 8} \end{subfigure} \hfill \begin{subfigure}{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/9.png} \caption{9 by 9} \end{subfigure} \hfill \begin{subfigure}{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/10.png} \caption{10 by 10} \end{subfigure}

\begin{subfigure}[hb]{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/11.png} \caption{11 by 11} \end{subfigure} \hfill \begin{subfigure}[hb]{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/12.png} \caption{12 by 12} \end{subfigure} \hfill \begin{subfigure}[hb]{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/15p.png} \caption{15 by 15} \end{subfigure}

\begin{subfigure}[t]{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/20p.png} \caption{20 by 20} \end{subfigure} \hfill \begin{subfigure}[t]{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/25p.png} \caption{25 by 25} \end{subfigure} \hfill \begin{subfigure}[t]{0.3\textwidth} \centering \includegraphics[height=1.8in]{images/bfly-primary/30p.png} \caption{30 by 30} \end{subfigure} \end{figure}

This is the output I am getting

  • 1
    Welcome to TeX.SE! See, if https://tex.stackexchange.com/questions/278727/split-subfigures-over-multiple-pages/278748#278748 can help you. – Zarko Jun 29 '23 at 05:00
  • 1
    Please post code we can compile to reproduce the problem. You can use, for example, example-image in place of 1.png etc. (If necessary, you can specify both the width and height since it doesn't matter if the example image gets distorted.) – cfr Jun 29 '23 at 05:28
  • Off-topic: None of the 16 [!] \centering directives to anything useful. Delete them. – Mico Jun 29 '23 at 05:28

2 Answers2

0

But using subfigures, the figures are entering footer zone and in the margin area.

You need to specify a target width for the graphs. I suggest you choose \linewidth as the target width, stated in the optional argument of \includegraphics. And, unless your paper size is unusually tall, there's no way that 5 rows of graphs will fit on a single page. I suggest you place 4 rows of graphs on one page, and 1 more row of graphs on the next page, using a \ContinuedFloat directive at the beginning of the second figure environment, to continue both the figure and the subfigure numbering.

enter image description here

Be sure to omit the demo document class option in your real document.

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage[letterpaper,margin=1in]{geometry}
% or maybe \usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{subcaption,graphicx}
\usepackage{lipsum} % filler text

\begin{document}

\begin{figure}[p!] \setkeys{Gin}{width=\linewidth,height=1.8in} % global placement options

\caption{Some graphics} \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/2.png} \caption{2 by 2} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/3.png} \caption{3 by 3} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/4.png} \caption{4 by 4} \end{subfigure}

\medskip \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/5.png} \caption{5 by 5} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/6.png}` \caption{6 by 6} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/7.png} \caption{7 by 7} \end{subfigure}

\medskip \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/8.png} \caption{8 by 8} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/9.png} \caption{9 by 9} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/10.png} \caption{10 by 10} \end{subfigure}

\medskip \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/11.png} \caption{11 by 11} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/12.png} \caption{12 by 12} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/15p.png} \caption{15 by 15} \end{subfigure}

\end{figure} \clearpage

\begin{figure}[ht!] \ContinuedFloat \setkeys{Gin}{width=\linewidth,height=1.8in} % global placement options

\caption{Some graphics, cont'd}

\begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/20p.png} \caption{20 by 20} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/25p.png} \caption{25 by 25} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/30p.png} \caption{30 by 30} \end{subfigure}

\end{figure}

\lipsum[1-2] % filler text \end{document}

Mico
  • 506,678
  • There is a section heading, but when compiled the entire pages after the section heading is left blank. What should I do to make the set up flexible, so that if there is space to fit only 6 or 9 or even 3, it only places 3 or 6 or 9 images only and continue to next page for the remaining images ? – aminitindas Jun 29 '23 at 06:01
  • @aminitindas - Try placing just three rows in the first rows in the first figure, and change [p] to [h]. – Mico Jun 29 '23 at 06:03
  • Thanks. And can they be flexible depending upon the space left in the page? They can't, right ? Or is there any way ? – aminitindas Jun 29 '23 at 06:05
  • @aminitindas - Since you've provided exactly zero information about your document setup (e.g., paper size? margin widths?, font size?), I'm not in a position to give advice of the variety you appear to be seeking. Sorry. – Mico Jun 29 '23 at 06:24
0

Using \ContinuedFloat (caption package) one can place each row into a separate float. Insetad of \medskip the rows will be separated by \floatsep. This offers a bit more flexibility in placement.

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage[letterpaper,margin=1in]{geometry}
% or maybe \usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{subcaption,graphicx}
\usepackage{lipsum} % filler text

\begin{document}

\begin{figure}[bp] \caption{Some graphics} \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/2.png} \caption{2 by 2} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/3.png} \caption{3 by 3} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/4.png} \caption{4 by 4} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/5.png} \caption{5 by 5} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/6.png}` \caption{6 by 6} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/7.png} \caption{7 by 7} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/8.png} \caption{8 by 8} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/9.png} \caption{9 by 9} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/10.png} \caption{10 by 10} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/11.png} \caption{11 by 11} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/12.png} \caption{12 by 12} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/15p.png} \caption{15 by 15} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat

\begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/20p.png} \caption{20 by 20} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/25p.png} \caption{25 by 25} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/30p.png} \caption{30 by 30} \end{subfigure} \end{figure}

\lipsum[1-3]

\end{document}


This version uses \label and \pageref to automate a "Continue from page ..." notice. It takes two runs to work (aux file).

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage[letterpaper,margin=1in]{geometry}
% or maybe \usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{subcaption,graphicx}
\usepackage{lipsum} % filler text

\usepackage{refcount}% or hyperref \newcounter{figurerow}[figure]

\newcommand{\ContinuedNotice}{% \edef\lastpage{\getpagerefnumber{fig.\thefigure.\thefigurerow}}% \refstepcounter{figurerow}% \label{fig.\thefigure.\thefigurerow}% \edef\thispage{\getpagerefnumber{fig.\thefigure.\thefigurerow}}% \ifnum\getpagerefnumber{fig.\thefigure.1}=\thispage\relax \else \ifnum\lastpage=\thispage\relax \else \centerline{Continued from page \lastpage} \par\medskip \fi \fi}

\begin{document}

\begin{figure}[bp] \caption{Some graphics} \ContinuedNotice% setup \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/2.png} \caption{2 by 2} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/3.png} \caption{3 by 3} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/4.png} \caption{4 by 4} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \ContinuedNotice \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/5.png} \caption{5 by 5} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/6.png}` \caption{6 by 6} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/7.png} \caption{7 by 7} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \ContinuedNotice \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/8.png} \caption{8 by 8} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/9.png} \caption{9 by 9} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/10.png} \caption{10 by 10} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \ContinuedNotice \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/11.png} \caption{11 by 11} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/12.png} \caption{12 by 12} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/15p.png} \caption{15 by 15} \end{subfigure} \end{figure}

\begin{figure}[tbp!] \ContinuedFloat \ContinuedNotice \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/20p.png} \caption{20 by 20} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/25p.png} \caption{25 by 25} \end{subfigure}% \hfill \begin{subfigure}{0.32\textwidth} \includegraphics{images/bfly-primary/30p.png} \caption{30 by 30} \end{subfigure} \end{figure}

\lipsum[1-3]

\end{document}

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