1

I would like to place 8 images in a single page, as following:

2 blocks of 4 images, where the name of each image is placed under it, and one general title for all of the four.

I tried the following code to make 4 images. However, it worked for me only with 2 next to each other.

\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{figure}[htbp]
    \centering
    \subfloat[1]{{\includegraphics[width=5cm]{fig1}}}
    \qquad
    \subfloat[2]{{\includegraphics[width=5cm]{fig2}}}
    \\
    \subfloat[3]{{\includegraphics[width=5cm]{fig3}}}
    \qquad
    \subfloat[4]{{\includegraphics[width=5cm]{fig4}}}    
    \caption{graphs}%
\end{figure}

Thank you.

3
  • Related tex.stackexchange.com/questions/202649/…
    – user30471
    Oct 6, 2017 at 8:56
  • Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. A MWE should compile and be as small as possible to demonstrate your problem. it's much easier to help you if we have full working code to start from.
    – user30471
    Oct 6, 2017 at 8:56
  • The width of all the figures and spaces between them adds up to more than 20 cm, which is definitely wider than the textwidth of an a4 paper. You should therefor reduce the specified widths. Secondly, there is a `\` which indicates a linebreak after the second and third image.
    – leandriis
    Oct 6, 2017 at 9:15

2 Answers 2

2

Using the subfig package, I would personally suggest the following example:

\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure}[htbp]
    \centering
    \subfloat[1]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
    \hfill
    \subfloat[2]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
    \hfill
    \subfloat[3]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
    \hfill
    \subfloat[4]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}

    \subfloat[1]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
    \hfill
    \subfloat[2]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
    \hfill
    \subfloat[3]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
    \hfill
    \subfloat[4]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}    
    \caption{graphs}%
\end{figure}
\end{document}

I have specified the width of every image to be 22% of the textwidth. That way the images still fit even if the margins are changed. \hfill between neighbouring images ensures, that the images are horizontally evenly spread over the whole textwidth.

update

As requested in the comments, this update includes a MWE showing the images in 2 columns with 4 rows each (instead of 4 columns with 2 rows).

\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure}[htbp]
    \centering
    \subfloat[1]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
    \hfill
    \subfloat[2]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}

    \subfloat[3]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
    \hfill
    \subfloat[4]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}

    \subfloat[1]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
    \hfill
    \subfloat[2]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}

    \subfloat[3]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
    \hfill
    \subfloat[4]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}    
    \caption{graphs}%
\end{figure}
\end{document}
2
  • I have tried those, however all solutions limit me in width of the paper. im trying to fit 8 images where there are 4 rows and 2 columns. is there any height to make it work? because I see pretty much empty space there.
    – Ben
    Oct 6, 2017 at 11:16
  • @ben: I have misunderstood your initial question and have now edited my answer according to your comment.
    – leandriis
    Oct 6, 2017 at 12:42
0

Try the below mentioned code.

\documentclass[10pt,a4paper,twoside,onecolumn]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure*}
\mbox{\subfloat[]{\label{subfig:1} \includegraphics[height=2.3cm]{example-image-a}}}
\mbox{\subfloat[]{\label{subfig:2} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{subfig:3} \includegraphics[height=2.3cm]{example-image-c}}}
\mbox{\subfloat[]{\label{subfig:4} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{5} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{6} \includegraphics[height=2.3cm]{example-image-c}}}
\mbox{\subfloat[]{\label{7} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{8} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{9} \includegraphics[height=2.3cm]{example-image-a}}}
\mbox{\subfloat[]{\label{10} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{11} \includegraphics[height=2.3cm]{example-image-c}}}
\mbox{\subfloat[]{\label{12} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{13} \includegraphics[height=2.3cm]{example-image-b}}}


\caption{Normal Models. \protect\subref{subfig:1} SLR. \protect\subref{subfig:2} MLR. \protect\subref{subfig:3} SWR. \protect\subref{subfig:4} OLS. \protect\subref{5} OLS. \protect\subref{6} OS. \protect\subref{7} Ok. \protect\subref{8} hi. \protect\subref{9} hey. \protect\subref{10} MSD. \protect\subref{11} LPY. \protect\subref{12} MSY. \protect\subref{13} Hello.}
\label{f45}
\end{figure*}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .