The minipage
environment adds a small piece of horizontal space after it, so if you use
...
\begin{minipage}{.5\textwidth}
...
\end{minipage}%
\begin{minipage}{.5\textwidth}
...
then you get the desired result- here's a complete MWE.
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{example-image-a}
\caption{A subfigure}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{example-image-b}
\caption{A subfigure}
\end{minipage}
\caption{A figure with two subfigures}
\end{figure}
\end{frame}
\end{document}
So, I took a previous answer of mine and made it more serious by using captions rather than just minipage text. The I took your image saved it as molecule-orig.png
and used imagemagic convert:
convert molecule-orig.png -transparent white molecule.png
So the background in molecule.png
is transparent and doesn't obscure the car.

\documentclass{article}
\usepackage{graphicx,capt-of}
\begin{document}
\setlength\unitlength{1cm}
\vspace*{\fill}
\noindent
\begin{picture}(0,0)\bfseries\large
\put(4,3){\includegraphics{house}}
\put(0.5,5){\parbox{5cm}{\raggedright
\captionof{figure}{If you are feeling generous
I'd like a house, preferably one with architectural
design integrity, like this}}}
\put(0,17){\includegraphics{car}}
\put(8,21.5){\parbox{3cm}{\raggedright
\captionof{figure}{I'd like a \textbf{Car},
preferably with four wheels.}}}
\put(0,10){\includegraphics{computer}}
\put(0,9){\parbox{6cm}{\raggedright
\captionof{figure}{A new \textbf{computer}
would be nice. (I won't need vim)}}}
\put(8,12){\includegraphics{cake}}
\put(9,11.5){\parbox{3cm}{\raggedright
\captionof{figure}{\textbf{Cake}, of course}}}
\put(5,15){\includegraphics[scale=.4]{molecule}}
\put(10,18){\parbox{3cm}{\raggedright
\captionof{figure}{one of these is apparently needed}}}
\end{picture}
\end{document}
Best Answer
For two independent side-by-side figures, you can use two
minipage
s inside afigure
enviroment; for two subfigures, I would recommend thesubcaption
package with itssubfigure
environment; here's an example showing both approaches:The
demo
option forgraphicx
was used only to make my example compilable for everyone; you shouldn't use that option in your actual code.The
%
(between\end{subfigure}
and\begin{subfigure}
orminipage
) is really important; not suppressing it will cause a spurious blank space to be added, the total length will surpass\textwidth
and the figures will end up not side-by-side.