News

New paper! in the American Naturalist

Wednesday, June 20, 2018

How to locate figures side by side (minipage)

\begin{figure}[h]
\centering
% figure1
\begin{minipage}{.48\textwidth}
\centering
\includegraphics[width=\linewidth]{figure1.png}
\caption{caption1} \label{fig:figure1}
\end{minipage}
\hfill
% figure2
\begin{minipage}{.48\textwidth}
\centering
\includegraphics[width=\linewidth]{figure2.png}
\caption{caption2} \label{fig:figure2}
\end{minipage}
\end{figure}

*\textwidth  : the global width of the textarea
**\linewidth : the width with respect to the list (or the column width of the each minipages in this case)


Also, by using a package "subcaption"
you can have a subcaption for each panel, and a main caption.

\usepackage{subcaption}

\begin{figure}[h]
\centering
% figure1
\begin{minipage}{.48\textwidth}
\centering
\includegraphics[width=\linewidth]{figure1.png}
\subcaption{caption1} \label{fig:figure1} % figure index will be (a)
\end{minipage}
\hfill
% figure2
\begin{minipage}{.48\textwidth}
\centering
\includegraphics[width=\linewidth]{figure2.png}
\subcaption{caption2} \label{fig:figure2} % figure index will be (b)
\end{minipage}
\caption{main-caption} \label{main-label} % figure index will be a number
\end{figure}