# Subfloat: Label beside, caption below

I'm looking for a possibility to put the label (a),(b),(c)... of a subfigure beside the subfigure and the caption below. So I'm tried sidesubfigure (Subfig label positioning), which puts the label exactly as I want to, but I didn't find a solution to put the caption below the image.

\documentclass{article}
\usepackage{floatrow}
\usepackage{subfig}
\usepackage{caption}
\usepackage{rule}

\begin{document}

\begin{figure}
\sidesubfloat[description]{\rule{2cm}{2cm}}
\hfill
\sidesubfloat[description]{\rule{2cm}{2cm}}
\end{figure}

\end{document}

Is there a possiblity to do that?

Edit: Just got another problem, when I'm adding 4 same size picture in 2 rows like this, the pictures are shifted:

\begin{figure}[H]
\begin{mysubfigure}{desc}{imageA}
\includegraphics[width=4cm, height=4cm]{imageA}
\end{mysubfigure}
\hfill
\begin{mysubfigure}{shorter desc}{imageB}
\includegraphics[width=4cm, height=4cm]{imageB}
\end{mysubfigure}
\newline
\begin{mysubfigure}{desc}{imageC}
\includegraphics[width=4cm, height=4cm]{imageC}
\end{mysubfigure}
\hfill
\begin{mysubfigure}{shorter desc}{imageD}
\includegraphics[width=4cm, height=4cm]{imageD}
\end{mysubfigure}
\caption{Two images: \subref{imageA} is imageA, \subref{imageB} is imageB}
\end{figure}

Here is a solution using the stackengine (and the varwidth) package.

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{varwidth}
\usepackage{stackengine}

\usepackage{lipsum}
\usepackage{float}

\DeclareCaptionLabelFormat{none}{}
\captionsetup[subfigure]{justification=centering, labelformat=none}

\newsavebox{\mybox}
\newlength{\mylength}

\makeatletter
\newenvironment{mysubfigure}[2]{%
\def\arg@caption{#1}%
\def\arg@label{#2}%
\def\arg@ref{(\subref{\arg@label})}%
\sbox{\mybox}{\begin{varwidth}{\linewidth}{\arg@ref}\end{varwidth}}%
\edef\arg@reflen{\the\wd\mybox}%
\edef\arg@refline{\the\dimexpr\ht\mybox+\dp\mybox}%
\begin{lrbox}{\mybox}%
\begin{varwidth}{\linewidth}%
}{%
\end{varwidth}%
\end{lrbox}%
\setlength{\mylength}{\the\dimexpr\ht\mybox+\dp\mybox-\arg@refline}%
\setlength{\mylength}{0.5\mylength}%
\hspace{\arg@reflen}\subfigure[b]{\the\wd\mybox}%
\centering%
\toplap[\mylength]{l}{\arg@ref}\usebox{\mybox}%
\caption{\arg@caption\label{\arg@label}}%
\endsubfigure%
}
\makeatother

\begin{document}

\lipsum[1]

\begin{figure}[H]
\centering
\begin{mysubfigure}{longer description than the other}{imageA}
\includegraphics[width=3cm, height=6cm]{imageA}
\end{mysubfigure}
\begin{mysubfigure}{shorter desc}{imageB}
\includegraphics[width=4cm, height=3cm]{imageB}
\end{mysubfigure}
\caption{Two images: \subref{imageA} is imageA, \subref{imageB} is imageB}
\end{figure}

\lipsum[2]

\end{document}
• Sorry, but this is not solution I'm looking for, because I still want to have a supcaption below each picture. I insert a picture to my first post to make it clearer. – Thomas Nov 19 '13 at 9:03
• @Thomas I'll check... – masu Nov 19 '13 at 9:20
• @Thomas I've "checked" :) – masu Nov 19 '13 at 10:47
• Hi, nearly perfect now, thank you. There's only one question left: When the two subfigures have different heights, they are vertically centered. What do I have to change for an alignment at the bottom (as a subfloat does) of the pictures? – Thomas Nov 19 '13 at 20:46
• @Thomas really good question which revealed a bug on my part... have to look into this... – masu Nov 19 '13 at 21:25