I'm working with caption
and subcaption
to style my (sub)figure captions and especially with floatrow to center my figures. However, this does not work for subfigures, as the following nMWE (nearly minimal) example illustrates:
\documentclass[a4paper,12pt]{scrartcl}
\usepackage{floatrow}
\usepackage{tikz,floatrow,hyperref}
\usepackage[hypcap=true]{caption}
\usepackage[hypcap=true]{subcaption}
\usepackage[all]{hypcap} %link to top of figure
% caption format
\captionsetup{format=hang,labelsep=space,indention=-2cm,labelfont=bf,width=.9\textwidth,skip=.5\baselineskip}
\captionsetup[sub]{labelfont=bf,labelsep=period,subrefformat=simple,labelformat=simple}
%center both ?
\floatsetup[figure]{objectset=centering}
\floatsetup[subfigure]{objectset=centering} %does not center subfigures
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (4,4);
\end{tikzpicture}
\caption{First}
\end{figure}
\begin{figure}
\begin{subfigure}{.49\textwidth}%\centering is not centered without centering
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (4,4);
\end{tikzpicture}
\caption{First}
\end{subfigure}
\begin{subfigure}{.49\textwidth}\centering
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (5,5);
\end{tikzpicture}
\caption{Second}
\end{subfigure}
\caption{Describing both subfigures}
\end{figure}
\end{document}
Clearly, the first figure gets centered and everything is fine. Though, comparing the second figures subfigures, I have to use \centering
(illustraed in the second subfigure) to center, which does not work, by using \floatsetup[subfigure]
.
I would like to center subfigures without using \centering
, but using a global package command. Any ideas how to obtain such layout using floatrow
?
Any other approach is of course nice too, it's just, that i'm already using floatrow
to center figures (globally).
PS: I'm using XeLaTeX, but I hope that does not change much in these observations.