I need to place a couple of images side by side (horizontally) in a presentation I'm doing with beamer
, so I looked around and inserted the following code (sugested by this post):
\documentclass{beamer}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{frame}
\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{image1}
\caption{A subfigure}
\end{minipage}
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{image2}
\caption{A subfigure}
\end{minipage}
\caption{A figure with two subfigures}
\end{figure}
\end{frame}
\end{document}
But the images appear one over the other (vertically). I tried both approaches suggested in the aforementioned post but I get the same result. What can I be doing wrong and how can I fix it?
Best Answer
The
minipage
environment adds a small piece of horizontal space after it, so if you usethen you get the desired result- here's a complete MWE.