I am using floatrow
and have a global setup with \floatsetup
. However I have one subfloatrow
in my document which requires different settings. How do I locally adjust the \floatsetup
/options for one float
?
[Tex/LaTex] local options for floatrow
floatrow
Related Solutions
You can use the \renewcommand\subfloatrowsep{\hskip 6\columnsep}
to increase the figure separation.
\documentclass{article}
\usepackage{caption,subcaption,floatrow}
\usepackage[demo]{graphicx}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\thisfloatsetup{floatwidth=.35\hsize,%
capposition=beside,%
capbesideposition=left,%
capbesidesep=none}
\renewcommand\subfloatrowsep{\hskip 6\columnsep} % figure separation is done here
\begin{figure}
\ffigbox[\textwidth]{
\begin{subfloatrow}[2]\useFCwidth
\fcapside[\FBwidth]{\includegraphics[width=3cm,height=3cm]{test}}{\caption{}}%
\subfloatrowsep
\fcapside[\FBwidth]{\includegraphics[width=1cm,height=3cm]{test}}{\caption{}}%
\end{subfloatrow}}
{\caption{\blindtext}}
\end{figure}
\end{document}
In the above if you use some side caption text, you will blow up the layout. In such cases, the following can be used.
\documentclass{article}
\usepackage{caption,subcaption,floatrow}
\usepackage[demo]{graphicx}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\thisfloatsetup{floatwidth=.45\hsize,capbesidewidth=sidefil,
capposition=beside,capbesideposition=left,capbesidewidth=3.5cm,%subfloatrowsep={.2\FBwidth},%
capbesidesep=none,}
\renewcommand\subfloatrowsep{\hskip 1.5\columnsep} % figure separation is done here
\begin{figure}
\ffigbox[\textwidth]{
\begin{subfloatrow}[2]%\useFCwidth
\fcapside[\FBwidth]{\includegraphics[width=3cm,height=3cm]{test}}{\caption{This is caption for A}}%
\subfloatrowsep
\fcapside[\FBwidth]{\includegraphics[width=1cm,height=3cm]{test}}{\caption{This is caption for figure B that is long}}%
\end{subfloatrow}}
{\caption{\blindtext}}
\end{figure}
\end{document}
First: you have included floatrow
twice.
You can use ffigbox
inside a figure
environment:
\documentclass[a4paper,12pt]{scrartcl}
\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}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (4,4);
\end{tikzpicture}
\caption{First}
\end{figure}
\ffigbox[\FBwidth]{%
\begin{subfloatrow}
\ffigbox[0.5\textwidth]{%
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (4,4);
\end{tikzpicture}}{\caption{First}}
\ffigbox[0.5\textwidth]{%
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (5,5);
\end{tikzpicture}}{\caption{Second}}%
\end{subfloatrow}%
}{\caption{Describing both subfigures}}
\end{document}
Allergy notice: some parts of the above code might be nuts (or needless)
To answer your questions in comments (from the floatrow
package manual):
Another command which creates figures -
\ffigbox
- puts caption below contents. The default width of caption equals to the width of text. [...] a float box, created by the\ffigbox
command looks similar to the plain figure environment. But if you set, for example, the option[\FBwidth]
[...] you’ll get a caption width equal to the width of picture [...]
There are similar boxes where the caption is placed elsewhere (eg: \fcapside
places it beside the figure). As far as I know \floatsetup[subfigure]{objectset=centering}
doesn't effect the subfigure
environment of the subcaption
package but these boxes.
If you hate this stack you can hope that is only my overcomplicated solution and there are better ones. Or you may want to try xpatch
(or etoolbox
) to do the "global" subcaption centering stuff (instead of using floatrow
for that) as a "hail mary"...
\usepackage{xpatch}
\makeatletter
% \subcaption@minipage is the last macro call in \subfigure (and \begin{subfigure})
\xapptocmd{\subcaption@minipage}{\centering}{}{}
\makeatother
Best Answer
The command
\floatsetup
allows the user to specify some options. This specification is always local.If you do the setup in your preamble the setup is done for the whole document.
To change the setup for a single subfloat you can use
\floatsetup
inside a group. The floating objects are always a group so you can change\floatsetup
inside the object without any effects to other objects.