# How to display side-by-side figures in LaTeX

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
\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...

## 34 thoughts on “How to display side-by-side figures in LaTeX”

1. 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}
subfigure{includegraphics[width=3in]{fig2.pdf} }}}
caption{Text pertaining to both graphs …}
label{fig12}
end{figure}

2. Michael

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

3. Just what I needed. Thanks!

4. kerimcan

thanks for this post. very useful.

5. mahyar

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

6. Claudine Allen

Thanks. This was way helpfule for me. To get the caption to work for each subfigure do this

subfigure[Caption for Subfig2]{includegraphics[width=3.5in]{contextmodel2}}}

7. Many thanks. Very useful. I need it.

8. Thx John,
this is great, since it does work with Sweave. I had some serious trouble to get minipage to work with Sweave (see here) . Btw if you don’t use Sweave, minipage is also a nice way to place graphs or tables next to each other. You can also use seperate captions then.

9. The subfigure package is outdated, subfig should be used instead (according to subfigures page on CTAN).

10. Thanks for the post, worked great. I like to use a percentage of the text width as opposed to an absolute width in case I change the layout of the page.

Example:
begin{figure}
centering
mbox{
subfigure[]{
includegraphics[width=.5textwidth]{figures/fig-1.eps}
label{fig-1}
subfigure[]{
includegraphics[width=.5textwidth]{figures/fig-2.eps}
label{fig-2}
}
}
centering
caption{Text pertaining to both graphs …}
label{fig-all}
end{figure}

11. Thanks for this tip. It helped me!

12. suvam

Thanks!!!! It worked!!

13. Jayaram Sethuraman

Very useful. Thanks for posting this.

14. Very nice, but if you want two real figures side by side, you can also write something like this:

 begin{figure}[h] centering begin{minipage}{.4textwidth} includegraphics[width=textwidth]{qrcode} caption{Lorem} end{minipage} begin{minipage}{.4textwidth} includegraphics[width=textwidth]{qrcode} caption{Ipsum} end{minipage} end{figure} 

15. There is also package called floatrow. Not anly allows placing various floats side-by-side but also adds great functionality to manage captions. With extensive documentation.

16. Bogdan

Awesome tip. Worked like a charm.

Cheers

Thanks, it works fine. (I am using it in Springer One Column Documents).

18. cmdline

mbox worked like a charm

19. prateek

thanks, it has helped me
but i am stucked because it is giving errors when using with hyperref

20. Salut à tous, j’ai fini mn rapport de stage mais on me demande metre le numero de mon rapport sur la 1ere page et à gauche. J’ai tout fais mais je n’arrive pas à le metre à gauche. Aidez-moi.

[English translation via Google: Hi all, I ended mn placement report but wonder meter the number of my report on the first page and left. I do everything but I can not seem to meter on the left. Please help me.]

21. Abhiram Soori

Thanks a lot!
This post helped me.

22. Iftikhar Ali

Thanks alot. Now I can include figures in my tex files.

23. Human_translation.

Ibra translation from french,

Hello to all,

I have finished my training report but I was asked to write my report number on the left of the first page. I did everything but I am not able to write it on the left.

24. Very thanq :). Want to correct Andi and Matt. The width is not 0.4textwidth , but it is 0.4linewidth

26. Soroush

I believe it is also possible to put two figures side by side by defining two columns

27. Hi!

The subfigure package is not maintained. I’d recommend using either the subcaption or the subfig package.

28. Sumanta Sidui

Thank’s for the help.

29. John,

as you may have noticed from the amount of “thanks” comments, any article explaining succintly how to do something in LaTeX (that gets Google’s first page) is a lifesaver for thousands as me. I guess many (as me!) didn’t think it was a worthy “just-in-case” skill, and when faced with the need to use it have to default to “just-in-time”, copy-pasting commands until it works.

Anyway, thanks as well, and keep posting drops of LaTeX hacking/wisdom.

30. Guohua Liang

Thanks. It is great. Save me a lot of time.

31. Thank you! Saved the day.

32. Waqas Ahmed

It works flawlessly. Thanks a lot for the help!!

33. As in 2010 and 2012, the subfigure package is still obsolete. Please add a note to the original post that the given infomation is not up to date.