# subfloatrow and tabularx, wrong numbering of figure

I wanted to "group" a figure and a table to get one figure. It has been proposed to use floatrow for this, with the possibility to remove the subcaptions later on (subfloatrow of package floatrow does not work without subcaptions).

But it seems, that the figure inside the environment will be counted (global figure number), even though it's in a subfloatrow!

The attached example shows the same source code with tabularx in the beginning and tabular in the end. One can see that the numbering starts with 2 instead of 1!

\documentclass{article}
\usepackage{caption,subcaption,tabularx,floatrow}

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

\begin{document}
\setcounter{figure}{0}
\begin{figure}[t!]
\ffigbox{
\begin{subfloatrow}
\ffigbox{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
}
\capbtabbox{%
\begin{tabularx}{4cm}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabularx}
}{%
\caption{A table}%
}
\end{subfloatrow}
}{%
\caption{A figure and a table}%
}
\end{figure}
\end{document}


Has anybody an idea on how to prevent this? Is it a bug?

-
Welcome to TeX.sx! A tip: You can use backticks  to mark your inline code. – Corentin Nov 9 '12 at 14:52
An interesting problem you've come across! I've taken the liberty of streamlining your code to a "true" minimum working example (MWE) by removing unneeded packages, eliminating blindtext, and eliminating one of the two figure environments. Incidentally, what is the purpose of combining a (sub)figure environment and a tabular environment in a single figure environment? Cross-references to the tabular portions of a figure might come out looking quite awkward. – Mico Nov 9 '12 at 16:45
Hi Mico! Thanks for the cleaning-up ;-) ! In fact, the table references the figure, so I'd like them to be nicely joint together. Using a kind of meta-enviromnet (name it "scheme", e.g.) would be more logical, but rather tedious to work out... Referencing the table, saying: "see Figure 1.b)" looks fine to me! – Guntram Nov 9 '12 at 17:51

If I understand correctly, and you do not want the subcaptions, you only need two minipage environments without extra packages.

To add subcaptions to the table and the figure without inferering the figure counter, one option could be the same, but adding the package caption and using \caption* (with asterik) when needed. This is a MWE:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{blindtext}
\usepackage{caption}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}[htp]
\centering
\begin{minipage}{3cm}
\includegraphics[width=3cm,height=3cm]{/home/fran/MWE.png}
\end{minipage}\hspace{1cm}
\begin{minipage}{.4\textwidth}
\begin{tabularx}{4cm}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabularx}
\end{minipage}
\caption{A figure and a table}%
\end{figure}

\blindtext

\begin{figure}[htp]
\centering
\begin{minipage}{3cm}
\includegraphics[width=3cm,height=3cm]{/home/fran/MWE.png}
\caption*{The figure}
\end{minipage}\hspace{1cm}
\begin{minipage}{.4\textwidth}
\caption*{The table}
\begin{tabularx}{4cm}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabularx}
\end{minipage}
\caption{A figure and a table}%
\end{figure}

\end{document}
`
-
Hello Fran! Thanks for your example! I wanted to use as few ways of placing figures as possible in my work. So I found floatrow to be a very rich and flexible package to assist me with this. I don't know why - but I kinda don't like minipages (no offence meant ;-) )! But there may be times I'll have to use them. After all, I can solve my problem without using tabularx but tabular, but I found this behaviour unexpected and disturbing, so I thouhgt to share it - maybe someone can fix this... – Guntram Nov 9 '12 at 18:01