Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
You don't need the minipage there you can just use two \includegraphics –  David Carlisle May 20 '13 at 23:28

2 Answers 2

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

enter image description here

share|improve this answer
\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}

enter image description here

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.