# How to manipulate width and position of items inside floatrow

From this answer by @lockstep I learned, how to put figure and table side by side:

\documentclass{article}

\usepackage{floatrow}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\begin{document}

\begin{figure}
\begin{floatrow}
%tried \ffigbox[0.5\linewidth]{%
\ffigbox{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
}
\capbtabbox{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}
}{%
\caption{A table}%
}
\end{floatrow}
\end{figure}

\end{document}


I don't understand, how to set the width of every column and align the table/figure left, center, right.

In the docs I found, that \ffigbox has width parameter and tried 0.5\linewidth, making each column half of the page. But that's all I achieved so far.

• What do you mean by "left" alignment of the table? So that the table as well as it's caption is left-aligned? – Werner Jun 20 '13 at 22:49
• @Werner Align the table or figure to the left side of the column. – user4035 Jun 20 '13 at 22:55
• @user4035 just the table/figure or also the caption? – Gonzalo Medina Jun 20 '13 at 23:48
• @GonzaloMedina The caption must be aligned by the center of the table or figure. – user4035 Jun 21 '13 at 6:49

Perhaps the best way to illustrate how the different commands work is to use some auxiliary boxes:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{xcolor}
\usepackage{floatrow}

\newcommand\MyBox[2][red!70!black]{{%
\setlength\fboxsep{0pt}\fcolorbox{#1}{white}{#2}}}

\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\pagestyle{empty}

\begin{document}

\begin{figure}
\MyBox[blue]{\begin{floatrow}
\MyBox{\ffigbox[\FBwidth]{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
}}%
\MyBox{\capbtabbox[\FBwidth]{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}%
}{%
\caption{A table}%
}}
\end{floatrow}}
\end{figure}

\begin{figure}
\MyBox[blue]{\begin{floatrow}
\MyBox{\ffigbox[8cm]{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
}}%
\MyBox{\capbtabbox[7cm]{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}%
}{%
\caption{A table}%
}}
\end{floatrow}}
\end{figure}

\begin{figure}
\MyBox[blue]{\begin{floatrow}
\MyBox{\ffigbox[8cm]{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
\MyBox{\capbtabbox[7cm]{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}%
}{%
\caption{A table}%
}}
\end{floatrow}}
\end{figure}

\end{document}


The floatrow environment (with default settings) reserves a box having a width equal to the entire \textwidth (the blue boxes in the example); the content will be centered by default.

The optional argument for ffigbox and captabbox allows to specify the width to be used for the content of each of these commands (the red boxes in the example); \FBwidth will give you the natural width (see first example), but you can select any other values (second and third example). In the third example a \qquad space was further introduced between the image and the table.

To control the position of the object inside its box, the package offers the objectset key which admits values similiar to those of justification for \captionsetup from the caption package; a little example using objectset=raggedright and the same settings for the width as as in the second example from the code above:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{xcolor}
\usepackage{floatrow}

\newcommand\MyBox[2][red!70!black]{{%
\setlength\fboxsep{0pt}\fcolorbox{#1}{white}{#2}}}

\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\pagestyle{empty}

\begin{document}

\thisfloatsetup{objectset=raggedright}
\begin{figure}
\MyBox[blue]{\begin{floatrow}
\MyBox{\ffigbox[8cm]{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
\MyBox{\capbtabbox[7cm]{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}%
}{%
\caption{A table}%
}}
\end{floatrow}}
\end{figure}

\end{document}


And, of course, you can use all the power of floatrow with all the power of caption to have, for example, both objects and captions raggedright or raggedleft:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{xcolor}
\usepackage[singlelinecheck=off,justification=raggedright]{caption}
\usepackage{floatrow}

\newcommand\MyBox[2][red!70!black]{{%
\setlength\fboxsep{0pt}\fcolorbox{#1}{white}{#2}}}

\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\pagestyle{empty}

\begin{document}

\thisfloatsetup{objectset=raggedright}
\begin{figure}
\MyBox[blue]{\begin{floatrow}
\MyBox{\ffigbox[8cm]{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
\MyBox{\capbtabbox[7cm]{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}%
}{%
\caption{A table}%
}}
\end{floatrow}}
\end{figure}

\thisfloatsetup{objectset=raggedleft}
\captionsetup{singlelinecheck=off,justification=raggedleft}
\begin{figure}
\MyBox[blue]{\begin{floatrow}
\MyBox{\ffigbox[8cm]{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
\MyBox{\capbtabbox[7cm]{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}%
}{%
\caption{A table}%
}}
\end{floatrow}}
\end{figure}

\end{document}