3

I am using subfigure environment. One of the images has 2 line caption. Below is the sample code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfigure}

\begin{document}
\begin{figure}[h]
  \centering
  \subfigure[One line caption]{
    \includegraphics[width=0.3\linewidth]{example-image-a}
  }
  \subfigure[Little longer caption takes over 2 lines]{
    \includegraphics[width=0.3\linewidth]{example-image-b}
  }
  \subfigure[One line caption]{
    \includegraphics[width=0.3\linewidth]{example-image-c}
  }
  \caption{Various example images}
  \label{fig:example_images}
\end{figure}
\end{document}

Plese see below the screenshot of generated PDF: Screenshot of generated PDF

The middle figure has two line caption. Notice that the second line starts just below from the caption numbering. I want the second line to start below from the first line, as shown in the modified picture below: Screenshot of the desired PDF

Any workaround, please?

0

2 Answers 2

4

Use the hang option. But, please, don't use subfigure in new documents.

\documentclass{article}
\usepackage{graphicx}
\usepackage[hang]{subfigure}

\begin{document}
\begin{figure}[h]
  \centering
  \subfigure[One line caption]{%
    \includegraphics[width=0.3\linewidth]{example-image-a}%
  }
  \subfigure[Little longer caption takes over 2 lines]{%
    \includegraphics[width=0.3\linewidth]{example-image-b}%
  }
  \subfigure[One line caption]{%
    \includegraphics[width=0.3\linewidth]{example-image-c}%
  }
  \caption{Various example images}
  \label{fig:example_images}
\end{figure}
\end{document}

Note also the added % characters, to avoid spurious spaces.

enter image description here

7

Please note that the subfigure package is deprecated. (Actually, it's been deprecated for quite a few years.) It should no longer be employed. Use either the subfig or the subcaption package.

Here's a solution that uses the subcaption package, its \subcaptionbox macro, and the package option format=hang:

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage[skip=0.333\baselineskip]{subcaption}
\captionsetup[subfigure]{format=hang}
\begin{document}
\begin{figure}[h]
  \subcaptionbox{One line caption\label{fig:a}}%
  {\includegraphics[width=0.3\linewidth]{example-image-a}}
  \hspace{\fill}
  \subcaptionbox{Slightly longer caption occupies 2 lines\label{fig:b}}%
  {\includegraphics[width=0.3\linewidth]{example-image-b}}
  \hspace{\fill}
  \subcaptionbox{One line caption\label{fig:c}}%
  {\includegraphics[width=0.3\linewidth]{example-image-c}}

  \caption{Various example images}\label{fig:example_images}
\end{figure}
\end{document}
1
  • I totally agree with you, however, I have many subfigure inside the article. This time, I just posted one. Can you please suggest the workaround for subfigure environment, which doesn't affect other subfigure?
    – ravi
    Jul 31, 2017 at 8:12

You must log in to answer this question.

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