cannot use \caption under minipage
To place a caption outside a floating environment, you can use \captionof
from the capt-of
or caption
packages::
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\noindent\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{fig1.eps}
\captionof{figure}{Some figure}
\label{fig:fig1}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{fig2.eps}
\captionof{figure}{Some figure}
\label{fig:fig2}
\end{minipage}
\end{document}
Notice the \noindent
and %
character I added to prevent undesired spacing.
You can also wrap a figure environment around your minipage, that way you do not need to use captionof
or capt-of
:
\begin{figure}[!htbp]
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{Images/img1.JPG}
\caption{cap1}
\label{fig:img1}
\end{minipage}\hfill
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{Images/img2}
\caption{cap2}
\label{fig:img2}
\end{minipage}
\end{figure}