As Mico suggest, probably you want to make a figure
environment, where you can have two figures with two captions using minipages
or subfigures
environments with two subcaptions ans a main caption. Note that figure environments are floats, so by default they can be moved to the top or bottom of the page, or to another page, although you can influence the position of float environments.
In any case, in these environments and the images usually is better set relative lengths as \linewidth
instead of absolute lengths as 3cm
.
On the other hand, at least for big images, instead of \centering
(and some spacer between the minipages
or the subfigures
) you may want these aligned with the margins, no matter its exact size. For this, use \hfill
as in this minimal working example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption} % for subfigures environments
\begin{document}
% Side by side subfigures
\begin{figure}
\begin{subfigure}[h]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Image A}
\end{subfigure}
\hfill
\begin{subfigure}[h]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{Image B}
\end{subfigure}%
\caption{This is a figure with two subfigures}
\end{figure}
% Side by side figures
\begin{figure}
\begin{minipage}[c]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Image A}
\end{minipage}
\hfill
\begin{minipage}[c]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{Image B}
\end{minipage}%
\end{figure}
\end{document}
minipage
to have width0.5\textwidth
, while each graphic is given a width of3cm
. If6cm
exceeds0.5\textwidth
, the two graphics simply won't fit in the available space.minipage
embedded in afigure
environment? The reason I ask is that you're using\caption
statements, which generally don't work outside offigure
andtable
environments.