# Captions in sub floats using subfloatrow are too narrow

I have a figure that has several subfigures, each with its own caption. I am aligning the subfloats using subfloatrow. How do I make the captions expand at least to the width of the graphic? Currently they are extremely narrow.

\documentclass[11pt]{amsart}
\usepackage{amsmath,amssymb,amsthm,latexsym,graphicx}
\usepackage{subfig,keyval,caption}
\usepackage[]{floatrow}
\floatsetup[table]{style=plaintop}
\usepackage{tikz}

\begin{document}
\begin{figure}[htbp]
\begin{center}
\ffigbox{
\begin{subfloatrow*}[3]
\subfloat[A very very very very very veryvery very veryvery very very long subcaption]
{\begin{tikzpicture}
\draw (0,0) rectangle(5,5);
\end{tikzpicture}}
\subfloat[A very very very very very veryvery very veryvery very very long     subcaption that is even longer than the first]
{\begin{tikzpicture}
\draw (0,0) rectangle(4,6);
\end{tikzpicture}}
\subfloat[And we're now talking about the third subfigure blah blah]
{\begin{tikzpicture}
\draw (0,0) rectangle(2,1);
\end{tikzpicture}}
\end{subfloatrow*}}{
\caption{And here's the caption to the main figure that seems to be working ok}
\label{tournaments}}
\end{center}
\end{figure}
\end{document}

• The code above works fine if the figures are put in via \includegraphics{} rather than using tikz to create them. This is totally confusing. – Leah Wrenn Berman Jan 29 '14 at 21:13

Inside the subfloatrow environment, instead of using \subfloat, use \ffigbox to surround your subfigures and pass \FBwidth to the optional argument (this gives you captions with a width equal to that of the subfigures; use a higher value, if desired).

\documentclass[11pt]{amsart}
\usepackage{amsmath,amssymb,amsthm,latexsym,graphicx}
\usepackage{subfig,keyval,caption}
\usepackage[]{floatrow}
\floatsetup[table]{style=plaintop}
\usepackage{tikz}

\DeclareCaptionSubType[alph]{figure}
\captionsetup[subfigure]{labelformat=brace,textfont=md,labelfont=up}

\begin{document}
\begin{figure}[htbp]
\centering
\ffigbox{%
\begin{subfloatrow}[3]
\ffigbox[\FBwidth]{\caption{A very very very very very veryvery very veryvery very very long subcaption}}
{\begin{tikzpicture}
\draw (0,0) rectangle(5,5);
\end{tikzpicture}}
\ffigbox[\FBwidth]{\caption{A very very very very very veryvery very veryvery very very long     subcaption that is even longer than the first}}
{\begin{tikzpicture}
\draw (0,0) rectangle(4,6);
\end{tikzpicture}}
\ffigbox[\FBwidth]{\caption{And we're now talking about the third subfigure blah blah}}
{\begin{tikzpicture}
\draw (0,0) rectangle(2,1);
\end{tikzpicture}}
\end{subfloatrow}%
}%
{\caption{And here's the caption to the main figure that seems to be working ok}
\label{tournaments}}
\end{figure}
\end{document}


Since the third figure is really narrow, the caption gets pporly typeset; consider perhaps using a ragged style for subfigure captions, or giving some more space for captions for such narrow subfigures, or try not to use such narrow subfigures, if possible.

• Interestingly, if you use subfloatrow* instead of subfloatrow (which is what I had needed to use in the past to fix numbering issues) this fix does not work at all (it numbers the subfloats as separate figures and the captions are too short still). I wish there were more comprehensible documentation for floatrow. – Leah Wrenn Berman Jan 29 '14 at 20:12