16

I want to position 3 images side by side. Actually I am doing like this, but they don't get side by side (see the pic on the bottom). Also is there any way to show only 1 caption for these 3 figures?

\begin{figure}[ht]


\begin{minipage}[b]{0.3\linewidth}
\centering
\includegraphics[scale=1]{i/houghtrain.png}
\caption{default}
\label{fig:figure1}
\end{minipage}

\hspace{0.3cm}


\begin{minipage}[b]{0.4\linewidth}
\centering
\includegraphics[width=\textwidth]{i/houghframe.png}
\caption{default}
\label{fig:figure2}
\end{minipage}

\hspace{0.3cm}

\begin{minipage}[b]{0.4\linewidth}
\centering
\includegraphics[width=\textwidth]{i/houghspace.png}
\caption{default}
\label{fig:figure3}
\end{minipage}
\end{figure}

They are not good positioned:

enter image description here

We can go outside the margin of the document if it is needed

dynamic
  • 1,711
  • 1
    you have blank lines=paragraph breaks between the images. – David Carlisle Jun 13 '13 at 12:36
  • You were right! if you want post an answer. Also if you know how to show only one caption i will sure accept it – dynamic Jun 13 '13 at 12:40
  • Please take a look at http://tex.stackexchange.com/questions/65386/how-to-vertically-align-3-images-with-subfigure?rq=1 –  Jun 13 '13 at 12:47

1 Answers1

31

If you just want three images side by side they can be positioned just as you would position three letters or boxes, no need for minipage wrappers etc. I also added p to your optional argument as not having it makes it more likely the float will go to the end of the document.

\begin{figure}[htp]

\centering
\includegraphics[width=.3\textwidth]{i/houghtrain.png}\hfill
\includegraphics[width=.3\textwidth]{i/houghframe.png}\hfill
\includegraphics[width=.3\textwidth]{i/houghspace.png}

\caption{default}
\label{fig:figure3}

\end{figure}
David Carlisle
  • 757,742
  • is there any way to ignore the margin? I have to reduce the scale of the images to get them on a single line. (and there is plenty of space on the left and right) – dynamic Jun 13 '13 at 12:55
  • 1
    @yes123 put \hspace*{-1cm} before the first and after the last and you steal 1cm from each margin – David Carlisle Jun 13 '13 at 12:58
  • I think it goes on conflict with \hfill – dynamic Jun 13 '13 at 13:08
  • @yes123 it will be OK. – David Carlisle Jun 13 '13 at 13:09
  • it leaves too much space between the images: http://i.stack.imgur.com/wJG1s.png if i try to enlarge a litte bit the central image they get on two lines =/ – dynamic Jun 13 '13 at 13:12
  • 2
    the hfill just pads the space, if that space is too big your images are too small or you have taken too much space out of the margin oh hang on the width key in my answer is wrong: you can not make then all \textwidth wide, will edit... – David Carlisle Jun 13 '13 at 13:18
  • Damn latex really... lol – dynamic Jun 13 '13 at 13:20
  • This question is a duplicate of a question on using subfigure. Would you advice against using subfigure and using minipage instead? – tommy.carstensen Mar 17 '15 at 12:39
  • 1
    @tommy.carstensen It depends if you want subfigures:-) that is if the previous figure was figure 2 and you have three captions in this one, do you want captions labeled 3a,3b,3c or captions labeled 3,4,5 subfigure is about getting 3a,3b,3c – David Carlisle Mar 17 '15 at 13:01
  • I have scourged the interwebs for a solution this problem. A bunch of them use \minpage, \subfigure, and \beging{subfigure}. This is by far the simplest and most straightforward solution. I wish there was a way to have sub captions to the images. – Waseem May 05 '20 at 16:33