The subcaption package offers a command called \subcaption
which typesets a sub-caption alone and has the same syntax as \caption
. You can place this command where you want, i.e. also beside a figure.
Addendum 2011-01-19, Example code:
\documentclass{article}
\usepackage{caption,subcaption}
\begin{document}
\begin{figure}
\parbox[b]{.5\linewidth}{\Large
Insert picture here --
Insert picture here --
Insert picture here --
Insert picture here}%
\hspace{.1\linewidth}%
\parbox[b]{.4\linewidth}{%
\subcaption{This is just a short document to show that
we can place the sub-caption where we want to.}}
\caption{Main caption.}
\end{figure}
\end{document}
Furthermore the floatrow package offers stuff like that (and more).
I'd suggest writing your own macro to place the sub-figure numbering:
\documentclass{revtex4-1}% http://ctan.org/pkg/ltxutil
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\newcommand{\subfigimg}[3][,]{%
\setbox1=\hbox{\includegraphics[#1]{#3}}% Store image in box
\leavevmode\rlap{\usebox1}% Print image
\rlap{\hspace*{10pt}\raisebox{\dimexpr\ht1-2\baselineskip}{#2}}% Print label
\phantom{\usebox1}% Insert appropriate spcing
}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{@{}p{0.45\linewidth}@{\quad}p{0.45\linewidth}@{}}
\subfigimg[width=\linewidth]{A)}{example-image-a} &
\subfigimg[width=\linewidth]{B)}{example-image-b} \\
\subfigimg[width=\linewidth]{C)}{example-image-c} &
\subfigimg[width=\linewidth]{D)}{example-image-a}
\end{tabular}
\caption{A caption}
\end{figure}
\end{document}
Once you have the image, you can print it in a box and extract its dimensions in order to use them to position the label.
The above macro \subfigimg[<options>]{<label>}{<image>}
does exactly that. It inserts <image>
with options <options>
and imprints the <label>
10pt from the left and 2 baseline skips from the top of the image.
No packages nor tomfoolery. Just box manipulation.
Some added flair with string comparison for positioning...
pdfTeX introduced \pdfstrcmp
for string comparison in version 1.30:
\pdfstrcmp{<a>}{<b>}
compares two strings and returns the strings "0"
if equals <b>
, "-1" if <a>
is less than <b>
, "1" if <a>
is greater
than <b>
.
\documentclass{revtex4-1}% http://ctan.org/pkg/ltxutil
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{xkeyval,xcolor}% http://ctan.org/pkg/{xkeyval,xcolor}
\makeatletter
\newlength{\sfp@hseplen}\newlength{\sfp@vseplen}
\define@cmdkey{subfigpos}[sfp@]{pos}[ul]{}% \sfp@pos
\define@cmdkey{subfigpos}[sfp@]{font}[\small]{}% \sfp@font
\define@cmdkey{subfigpos}[sfp@]{vsep}[2\baselineskip]{\setlength{\sfp@vseplen}{\sfp@vsep}}% \sfp@vsep
\define@cmdkey{subfigpos}[sfp@]{hsep}[10pt]{\setlength{\sfp@hseplen}{\sfp@hsep}}% \sfp@hsep
\newcommand{\subfigimg}[3][,]{%
\setkeys{Gin,subfigpos}{pos,font,vsep,hsep,#1}% Set (default) keys
\setbox1=\hbox{\includegraphics{#3}}% Store image in box
\ifnum\pdfstrcmp{\sfp@pos}{ul}=0% UPPER LEFT placement of subfig label
\leavevmode\rlap{\usebox1}% Print image
\rlap{\hspace*{\sfp@hsep}\raisebox{\dimexpr\ht1-\sfp@vsep}{\sfp@font{#2}}}% Print label
\phantom{\usebox1}% Insert appropriate spacing
\else\ifnum\pdfstrcmp{\sfp@pos}{ur}=0% UPPER RIGHT placement of subfig label
\leavevmode\usebox1% Print image
\llap{\raisebox{\dimexpr\ht1-\sfp@vsep}{\sfp@font{#2}}\hspace*{\sfp@hsep}}% Print label
\else\ifnum\pdfstrcmp{\sfp@pos}{lr}=0% LOWER RIGHT placement of subfig label
\leavevmode\usebox1% Print image
\llap{\raisebox{\sfp@vsep}{\sfp@font{#2}}\hspace*{\sfp@hsep}}% Print label
\else% Assume LOWER LEFT placement of subfig label
\leavevmode\rlap{\usebox1}% Print image
\rlap{\hspace*{\sfp@hseplen}\raisebox{\sfp@vsep}{\sfp@font{#2}}}% Print label
\phantom{\usebox1}% Insert appropriate spacing
\fi\fi\fi
}
\makeatother
\begin{document}
\begin{figure}
\centering
\begin{tabular}{@{}p{0.45\linewidth}@{\quad}p{0.45\linewidth}@{}}
\subfigimg[width=\linewidth,pos=lr]{A)}{example-image-a} &
\subfigimg[width=\linewidth,pos=ll,font=\color{green!30!red}]{B)}{example-image-b} \\
\subfigimg[width=\linewidth,pos=ur,font=\LARGE]{C)}{example-image-c} &
\subfigimg[width=\linewidth,pos=ul]{D)}{example-image-a}
\end{tabular}
\caption{A caption}
\end{figure}
\end{document}
The above MWE adds the keys pos
, font
, hsep
and vsep
to the mix. In turn they allow for selecting the pos
ition of the label, which font
to use, the h
orizontal sep
aration and v
ertical sep
aration.
Best Answer
Here's one possible solution using the
floatrow
andsubfig
packages: