# The best way to place figures side-by-side in Latex

By | September 13, 2013

There are different way of placing figures side by side in Latex, subcaption, subfig, subfigure, or even minipage. This post will tell you which one is the best.

## subcaption

A useful extension is the subcaption package (the subfigure and subfig packages are deprecated and shouldn’t be used any more), which uses subfloats within a single float. This gives the author the ability to have subfigures within figures, or subtables within table floats. Subfloats have their own caption, and an optional global caption. An example will best illustrate the usage of this package:

\usepackage{subcaption}
...
\begin{figure}
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{1.png}
\caption{Picture 1}
\label{fig:1}
\end{subfigure}
%
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{2.png}
\caption{Picture 2}
\label{fig:2}
\end{subfigure}
\end{figure}


## minipage

The minipage can be used to place figures side-by-side too. But it is not a floating environment, thus has to be placed in a figure environment. Another disadvantage of minipage is that it does not align fi gures. Therefore, subcaption is still the best package you should use.

\begin{figure}
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{1.png}
\caption{Picture 1}
\label{fig:1}
\end{minipage}

\begin{minipage}[b]{0.4\textwidth}
includegraphics[width=textwidth]{2.png}
\caption{Picture 2}
\label{fig:2}
\end{minipage}
\end{figure}


## subfig and subfigure

Although subfig and subfigure packages are deprecated and shouldn’t be used any more, I will still provide two simple examples, to show you how to use them. Note: subfig support hyperref with BUGS!

subfig

usepackage{subfig}
...
begin{figure}[!ht]
subfloat[Picture 1label{fig:1}]{%
includegraphics[width=0.4textwidth]{1.png}
}
hfill
subfloat[Picture 2label{fig:2}]{%
includegraphics[width=0.4textwidth]{2.png}
}
caption{Main figure caption}
end{figure}


subfigure

usepackage{subfigure}
...
begin{figure}[ht]
subfigure[Picture 1]{%
includegraphics[width=.4textwidth]{1.png} label{fig:1}
}
subfigure[Picture 2]{%
includegraphics[width=.4textwidth]{2.png} label{fig:2}
}
caption{Main figure caption}
end{figure}


## 11 thoughts on “The best way to place figures side-by-side in Latex”

1. Annoyed

None of these actually place them side by side

1. neus

I’ve just tried it out and its one on the top of the other… (I used subcaption)

1. mat

remove the space between the subfigures and the code should work as expected

…….
label{fig:1}
end{subfigure}
begin{subfigure}[b]{0.4textwidth}
includegraphics[width=textwidth]{2.png}

……..

1. Muammar

This is true. Deleting the blank line between the subfigures blocks make the graphs to be side by side. Thanks for the post.

2. Muammar

Forgot to mention, there are errors in the units. All textwidth should have a blackslash -> \textwidth. LaTeX complains about this.

3. pearl

I’ve been figuring subfigure problem in my tex file for more than an hour before I stumbled on your site. Just dropping by to say thanks! Hope everything is going well with you 🙂

4. pearl

I’ve been figuring out my subfigure problem for an hour until I stumbled upon your site. Just dropping by to say thanks! Hope everything is going well with you 🙂

5. Javan

Very good contribution! Thanks a lot! You saved my day!