5

How do I place text RIGHT below an image (above the caption) within subfig? Here Is my code:

\documentclass{article}

\usepackage{hyperref}
\usepackage{graphicx} 
\usepackage{subfig} 

\begin{document}

\captionsetup[subfigure]{labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedright}
\captionsetup[figure]{singlelinecheck=off}

\begin{figure}
\subfloat[\textit{\textit{D. pulex}}
\newline \tiny \url{commons.wikimedia.org/wiki/File:Daphnia_pulex.png}
\newline \tiny Photos by Paul Hebert]{\label{dpulex}
\includegraphics[width=0.48\textwidth]{dpulex.png}
}
\end{figure}

\end{document}

Here is what it prints:

enter image description here

So I'd like those two lines written in tiny to appear below the image and above "(a) D. pulex". Any help will be appreciated.

Far Zin
  • 782

2 Answers2

5

Just include it below the image, rather than above the caption:

enter image description here

\documentclass{article}

\usepackage{graphicx,subfig}% http://ctan.org/pkg/{graphicx,subfig}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\captionsetup[subfigure]{labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedright}
\captionsetup[figure]{singlelinecheck=off}

\begin{document}

\begin{figure}
  \subfloat[\textit{D.\ pulex}\label{dpulex}]{%
    \centering\parbox{0.48\linewidth}{%
      \includegraphics[width=\linewidth]{example-image-a} \\
      {\tiny \url{commons.wikimedia.org/wiki/File:Daphnia_pulex.png} \\
      Photos by Paul Hebert}%
    }
  }
\end{figure}

\end{document}

The skip between the URL and credits can be changed to suit your needs. For example, use \\[-.5\baselineskip] instead of \\, say):

enter image description here

I've used a \parbox purely to have a left-aligned block. However, you can modify this to your liking. The fundamental idea remains the same.

Also, hyperref should actually be loaded last in this instance. See Which packages should be loaded after hyperref instead of before?

Moriambar
  • 11,466
Werner
  • 603,163
  • This would be great if only the space between lines wasn't so great. Is there any way i can resolve this (with or without the parbox) – Far Zin Apr 11 '13 at 02:26
  • 1
    @FarZin: Just use \\[-.5\baselineskip] instead of the regular \\ I have. – Werner Apr 11 '13 at 02:43
4

If you're willing to use the subcaption package instead of the subfigure package (which, I believe, is deprecated), you could use something like the following method:

\documentclass{article}
\usepackage[demo]{graphicx} % omit [demo] in real version
\usepackage{subcaption} 
\captionsetup[subfigure]{labelfont=bf, 
   singlelinecheck=off,
   justification=raggedright}
\captionsetup[figure]{singlelinecheck=off}
\usepackage{hyperref}
\begin{document}
\begin{figure}

\begin{subfigure}{0.48\textwidth}
\includegraphics[width=\linewidth]{dpulex.png}

\tiny Photos by Paul Hebert

\url{commons.wikimedia.org/wiki/File:Daphnia_pulex.png}

\caption{\textit{D. pulex}}\label{dpulex}
\end{subfigure}
\end{figure}
\end{document}

enter image description here

Mico
  • 506,678