# Two images inside minipage (side by side) with one common caption that says “Figure 1 & 2:”

I have two images inside a minipage, so I can have them side by side. When I make a caption for the images it only comes up as "figure 3: text", but I would like to have it showing "Figure 3 & 4: text".

I tried to \end{figure} and \begin{figure} in each minipage but the images would not show side by side anymore. The code I have at the moment is:

\begin{figure}[h]
\begin{minipage}[h]{0.3\textwidth}
\includegraphics[scale=0.58]{fig1}
\end{minipage} \hspace{0.2\textwidth}
\begin{minipage}[h]{0.3\textwidth}
\includegraphics[scale=0.58]{fig2}
\end{minipage}
\caption{text}
\end{figure}
-
You don't need the minipage there you can just use two \includegraphics –  David Carlisle May 20 '13 at 23:28

This isn't quite what you've asked for, but how about the following? I'm using the subcaption package to put your two pictures into two 'subfigures'. The pictures can then be referenced individually (Figure 1a and Figure 1b), or as a pair (Figure 1).

## Code

\documentclass{article}

\usepackage{subcaption}
\usepackage[demo]{graphicx}

\begin{document}
\begin{figure}[h]
\begin{subfigure}{0.3\textwidth}
\includegraphics[scale=0.58]{fig1}
\caption{horse}
\label{fig:horse}
\end{subfigure} \hspace{0.2\textwidth}
\begin{subfigure}{0.3\textwidth}
\includegraphics[scale=0.58]{fig2}
\caption{zebra}
\label{fig:zebra}
\end{subfigure}
\caption{animals}
\label{fig:animals}
\end{figure}

Figure~\ref{fig:animals} shows some animals. Figure~\ref{fig:horse} shows a horse.

\end{document}

## Result

-
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\newcounter{dummy}
\begin{document}

\begin{figure}[!h]
\centering
\includegraphics[scale=0.58]{fig1}
\caption{text}
\end{figure}

\begin{figure}[!h]
\centering%
\begin{minipage}{0.3\textwidth}
\includegraphics[width=\linewidth]{fig1}
\end{minipage}%
\hspace{0.2\textwidth}%
\begin{minipage}{0.3\textwidth}\centering
\includegraphics[width=\linewidth]{fig2}
\end{minipage}%
\renewcommand\thefigure{\arabic{figure} \& %
\setcounter{dummy}{\arabic{figure}}%
\protect\stepcounter{dummy}\arabic{dummy}}%
\caption{text}
\stepcounter{figure}%
\end{figure}

\begin{figure}[!h]
\centering
\includegraphics[scale=0.58]{fig1}
\caption{text}
\end{figure}

\end{document}

-
Thanks a lot, it works perfectly. Despite of working fine, there is an error which says "Undefined control sequence \caption{". I tried to play with the packages and see if there was a crash between them, but so far no luck. Do you know why is it showing this error? Thanks once again. –  user30975 May 20 '13 at 14:22
difficult to say. A \caption command is defined in nearly all documentclasses –  Herbert May 20 '13 at 15:15