How to display side-by-side figures in LaTeX

by John on January 14, 2009

The other day I tried putting two graphs side-by-side by setting R’s mfrow parameter. That made the graphs look odd because not everything was scaled proportionately. Then someone told me I could use a LaTeX command to place my original graphs side-by-side rather than creating a new image.

The trick is to use the subfigure package. Include the directive \usepackage{subfigure} at the top of your file, then use code something like the following.

\begin{figure}
\centering
\mbox{\subfigure{\includegraphics[width=3in]{fig1.pdf}}\quad
\subfigure{\includegraphics[width=3in]{fig2.pdf} }}
\caption{Text pertaining to both graphs ...} \label{fig12}
\end{figure}

If you put text in square brackets immediately after the \subfigure command, that text will be a caption for the corresponding sub-figure. For example, the LaTeX code above might be changed to include the following.

...\subfigure[Description of left graph]{\includegraphics...

{ 5 comments… read them below or add one }

1

jerry 02.26.09 at 13:08

awesome tip, john. very helpful.

i think there is a small bug (one bracket is missing).

\begin{figure}
\centering
\mbox{\subfigure{\includegraphics[width=3in]{fig1.pdf}
\quad
\subfigure{\includegraphics[width=3in]{fig2.pdf} }}}
\caption{Text pertaining to both graphs …}
\label{fig12}
\end{figure}

2

Michael 04.28.09 at 10:04

Thanks for the tip! It works flawlessly. Smiling! :) Smiling!

3

Steve 10.09.09 at 07:22

Just what I needed. Thanks!

4

kerimcan 11.19.09 at 15:05

thanks for this post. very useful.

5

mahyar 03.02.10 at 03:27

thanks, but how can i write two different captions for the two figures while i put them side by side?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>