2

I am having some problems using sub-floats. I am trying to put two images side by side in the same row to avoid wasting space, for which I used sub-floats. However, they touch each other that it is hard to read their captions at first. See this output:

enter image description here

Any idea how to solve this problem?! Moreover, those figures are not really related to each other (although they are illustrating the same problem), so I think they should be figure 2.2 and 2.3 rather than 2.2a and 2.2b, right? If yes, how can I do that?!

EDIT: Here is the code I used to produce this:

\usepackage{graphicx}
\usepackage{cite}
\usepackage{subfig}

\begin{figure}
  \centering
  \subfloat
  [
  Halper et al. \cite{HHS01} pointed out that in a configuration like this, the
  hemicube method of Philips et al. \cite{PBG92} would fail to find the position
  P to avoid occlusion while shooting the target. Image taken from \cite{HHS01}.
  ]
  {
    \label{fig:halper1}
    \includegraphics[width=0.45\textwidth]{halper1}
  }
  \subfloat
  [
  Volumes of partial and total occlusion. Image taken from \cite{CN05}.
  ]
  {
    \label{fig:occlusion_cones}
    \includegraphics[width=0.45\textwidth]{occlusion_cones}
  }
  \caption{}
  \label{fig:halper1}
\end{figure}
8
  • 1
    Could you please provide a minimal working example?
    – N.N.
    Jun 15, 2011 at 9:50
  • OK, I included the exact code I used.
    – Rafid
    Jun 15, 2011 at 9:53
  • A minimal example should generally be a complete document, including preamble, not just a snippet. That way we don't have to guess/search to find out which package(s) you have used. Jun 15, 2011 at 9:59
  • I thought the subfloat in LaTeX is well known! Anyway, I updated the code. Thanks.
    – Rafid
    Jun 15, 2011 at 10:03
  • 4
    Well yes, I assumed that you used the subfig package, but it was more a general comment. Having a complete example helps those who want to help you, as we can just copy-paste the entire code and compile it. To nitpick a little more, your example is still not complete, as there is no \documentclass and no document environment. Jun 15, 2011 at 10:09

2 Answers 2

6

To increase the space between the captions of the subfloats, one way is to add margin=<length> as an option to the subfig package, e.g.

\usepackage[margin=10pt]{subfig}

But this adds the margin to both sides of the caption. The package has many options for customizing the caption in that way, see the manual.

If you do not want fig. 2.2a, 2.2b, but fig. 2.2, 2.3, you can use two minipages within the figure environment:

\begin{figure}
  \begin{minipage}{0.45\textwidth}
    \centering
    \includegraphics{a}
    \caption{Caption A}
  \end{minipage}\hfill
  \begin{minipage}{0.45\textwidth}
    \centering
    \includegraphics{b}
    \caption{Caption B}
  \end{minipage}\hfill
\end{figure}
9

put a \hfill between the images:

\begin{figure}
  \centering
  \subfloat
  [
  Halper et al. \cite{HHS01} pointed out that in a configuration like this, the
  hemicube method of Philips et al. \cite{PBG92} would fail to find the position
  P to avoid occlusion while shooting the target. Image taken from \cite{HHS01}.
  ]
  {
    \label{fig:halper1}
    \includegraphics[width=0.45\textwidth]{halper1}
  }\hfill%%%%%%%%%%%%%%%%%%%%%% <========
  \subfloat
  [
  Volumes of partial and total occlusion. Image taken from \cite{CN05}.
  ]
  {
    \label{fig:occlusion_cones}
    \includegraphics[width=0.45\textwidth]{occlusion_cones}
  }
  \caption{}
  \label{fig:halper1}
\end{figure}
1
  • Good solution. However, @Torbjorn's solution below seems to be more flexible, since the margin can be adjusted.
    – Rafid
    Jun 15, 2011 at 10:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .