80

I use the following code to include three images:

\begin{figure}[h]
\includegraphics{delete_gesture.png}
\caption{Awesome Image}
\label{fig:awesome_image}
\end{figure}

\begin{figure}[h]
\includegraphics{ok_gesture.png}
\caption{Awesome Image}
\label{fig:awesome_image}
\end{figure}

\begin{figure}[h]
\includegraphics{settings_gesture.png}
\caption{Awesome Image}
\label{fig:awesome_image}
\end{figure}

Now the images are ordered vertically. I want them horizontally. I tried to use columns or multicols but couldn't find a solution. Any hint?

3 Answers 3

98

put them all together in one figure environment and the three minipages without an empty line

\documentclass[english]{article}
\usepackage[demo]{graphicx}
\usepackage{babel,blindtext}

\begin{document}

\blindtext

\begin{figure}[!htb]
\minipage{0.32\textwidth}
  \includegraphics[width=\linewidth]{delete_gesture.png}
  \caption{A really Awesome Image}\label{fig:awesome_image1}
\endminipage\hfill
\minipage{0.32\textwidth}
  \includegraphics[width=\linewidth]{ok_gesture.png}
  \caption{A really Awesome Image}\label{fig:awesome_image2}
\endminipage\hfill
\minipage{0.32\textwidth}%
  \includegraphics[width=\linewidth]{settings_gesture.png}
  \caption{A really Awesome Image}\label{fig:awesome_image3}
\endminipage
\end{figure}

\blindtext

\end{document}

enter image description here

8
  • oh, golly -- please make those captions ragged right! they don't need to be that spacy! Feb 4, 2011 at 18:40
  • @Barbara: sorry, but the captions is incomplete: "A really awsame image and caption" ... :-)
    – user2478
    Feb 4, 2011 at 20:03
  • I'm just trying this out now, with three identical images, and I get a strange problem where the center image is shifted down, due to the length of the caption. Is there a way to prevent this with captions of varying length?
    – celenius
    Mar 24, 2011 at 0:55
  • How ahould the images be adjusted, at top or bottom?
    – user2478
    Mar 24, 2011 at 17:51
  • 1
    OH!!! "without an empty line"!!!!! That should be in bold!
    – K.S.
    Jan 30, 2021 at 22:02
13

Here is a solution with subfigure package. It has 2 rows and 2 columns of images. The widths are chosen such that it fits into a column of a 2-column page. I guess you get the idea.

\begin{figure}[t]
\centering
\subfigure[text]{
\includegraphics[width=.225\textwidth]{file}
}
\subfigure[text]{
\includegraphics[width=.225\textwidth]{file}
}

\subfigure[text]{
\includegraphics[width=.225\textwidth]{file}
}
\subfigure[text]{
\includegraphics[width=.225\textwidth]{file}
}

\caption{blablabla}
\label{fig:whatever}
\end{figure}

As you can see it's pretty simple to have to images/objects next to each other -- just put them into the same line. Or you can use multicol inside a figure.

Please note that subfigure is superseded by subfig which provides \subfloat command instead of \subfigure. More compatibility information is found in the subfig documentation.

3
  • 4
    Using subfigures is a good idea. I would prefer the subfig package, since it's newer than subfigure and it's widely considered as its successor.
    – Stefan Kottwitz
    Feb 5, 2011 at 16:26
  • 3
    according to wikipedia subfigure is depricated.
    – irrehaare
    Nov 10, 2012 at 16:26
  • 1
    The subcaption package is the way to go now! It provides a subfigure environment and the \subcaptionbox command.
    – ypnos
    Jul 29, 2016 at 22:28
9

I use the following technique:

\begin{figure}[h]       
    \fbox{\includegraphics{fig1.pdf}}   
    \hspace{30px}
    \fbox{\includegraphics{fig2.pdf}}
    \hspace{30px}
    \fbox{\includegraphics{fig3.pdf}}
    \caption{this is the caption}
    \label{materialflowChart}
\end{figure}

This places a thin line around each image (as it uses framebox). You can use \mbox in the same way if you don't want a frame. The \hspace{} command is a convenient way of controlling the spacing between the two images.

7
  • Some notes: \label always comes after \caption. I think you mean '30pt' not 30px, but \hfill would be better. Feb 4, 2011 at 14:31
  • @Martin: px is the pdf unit and exactly 1 pixel
    – user2478
    Feb 4, 2011 at 14:40
  • Thanks Martin, I did not know that about \label - I swapped the order. For some reason 30px works on my computer - I thought the px dimensions could be supplied? Is this not the case?
    – celenius
    Feb 4, 2011 at 14:41
  • @Herbert: thanks, I didn't know that pdftex is adding this unit. I had a short look in the TeXbook and run a test with tex beforehand. Should have used pdftex :-) Feb 4, 2011 at 14:43
  • @Martin - Just curious, why is \hfill better?
    – celenius
    Feb 4, 2011 at 14:45

You must log in to answer this question.

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