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 want to put two images next to each other and in order to do that I have written these code:

\begin{figure}[h]
\begin{minipage}{16pc}
\includegraphics[width=16pc]{P_1.eps}
\caption{\label{fig4} Caption of the first image.
\end{minipage}\hspace{2pc}%
\begin{minipage}{16pc}
\includegraphics[width=16pc]{P_2.eps}
\caption{\label{fig4} Caption of the second image.
\end{minipage}
\end{figure}

But in pdf I see

Figure 4: Caption of the first image. Figure 5: Caption of the second image.

How I can change it so that it was

Figure 4-a: Caption of the first image. Figure 4-b: Caption of the second image.

or

Figure 4.a: Caption of the first image. Figure 4.b: Caption of the second image.

Thanks!

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

You can use the subcaption package (a powerful companion to the caption package):

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}

\DeclareCaptionFormat{subfig}{\figurename~#1#2#3}
\DeclareCaptionSubType*{figure}
\captionsetup[subfigure]{format=subfig,labelsep=colon,labelformat=simple}

\begin{document}

\begin{figure}[!ht]
  \begin{subfigure}[b]{.5\linewidth}
    \centering
    \rule{4cm}{3cm}
    \caption{A subfigure}
    \label{fig:1a}
  \end{subfigure}%
  \begin{subfigure}[b]{.5\linewidth}
    \centering
    \rule{4cm}{3cm}
    \subcaption{Another subfigure}
    \label{fig:1b}
  \end{subfigure}
  \caption{A figure with two subfigures}
  \label{fig:1}
\end{figure}

\end{document}
share|improve this answer
1  
+1 subcaption is the best option. Forget subfig and subfigure –  Martin H Mar 15 '11 at 20:37
    
Personally I would use \renewcommand\subfigurename{\figurename} (or \renewcommand\subfigurename{Figure}) after \DeclareCaptionSubType*{figure} instead of defining and using an own caption format called subfig, because this would make it possible to use other caption formats as well. I just see that I have forgotton to document this one (sorry for that), will do this in the very next version. –  Axel Sommerfeldt Mar 16 '11 at 18:54
    
Why it requires so long code? Can't we have another simplified code like the answer of Thomas Connor is. I would use the code of Thomas Connor, but I worried because the subfigure package is considered obsolete. –  Narek Mar 21 '11 at 7:18
    
@Narek: besides using an obsolete package (which is not advisable), the code in Thomas Connor's answer contains some typos and does not produce the headings that you required for the caption of the subfigures. The code I provided is not so long if you think of the benefits it provides. –  Gonzalo Medina Mar 21 '11 at 14:33
    
@Narek, you can easily add a command that would get you code that looks the same as the code from Thomas Connor but that has the same result as the code from this answer. –  Alessandro Vermeulen Feb 2 '13 at 10:57
add comment

You have to use the package subfigure. The syntax is for instance:

\begin{figure}[htp]
  \centering
  \subfigure[caption (a)]{\includegraphics[width=16pc]{P_1.eps}}\label{...}}
  \subfigure[caption (b)]{\includegraphics[width=16pc]{P_2.eps}}\label{...}}
  \caption{general caption}
  \label{...}
\end{figure}

You will get the expected result.

share|improve this answer
3  
@Tomas The subfigure package is considered obsolete; alternative options are the subfig or the subcaption packages. Besides, your code snippet contains superfluous closing braces and does not produce the labels for the subfigures that @Narek required. –  Gonzalo Medina Mar 15 '11 at 20:34
    
@Gonzalo: Thanks for the advice! I'll check it. –  Thomas Connor Mar 15 '11 at 20:37
add comment

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.