How to print graphics on a new line in floatrow/subfloatrow

How can I skip to a newline in a subfloatrow environment (floatrow package) after two graphics. I want to typeset two graphics A.pdf and B.pdf on the same line, C.pdf and D.pdf should be on a new line. All graphics should be part of the same subfloatrow, considering the labels and captions. I'm missing part of the floatrow concept so I tried silly things like introducing newlines (\\ and \newline) which of course won't work.

This is the code I used:

preamble:

\documentclass{article}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{caption}

\begin{document}
\clearpage
\begin{figure}[h!]
\ffigbox[\FBwidth]
{\begin{subfloatrow}
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{A.pdf}}%
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{B.pdf}}%
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{C.pdf}}%
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{D.pdf}}%
\end{subfloatrow}}
{\caption{this is a caption}}
\end{figure}
\end{document}

-
Please post a complete, minimal and compilable version of your document. – Gonzalo Medina May 3 '11 at 12:18
this should work – Timtico May 3 '11 at 13:42
I edited your code because you wrote \start{document}. I assume you thought of writing \begin{document}. – Thorsten May 3 '11 at 13:57
ah yes, ofcourse, thank alot – Timtico May 3 '11 at 14:04
I added the subfig package to your code to make it (except for the actual figures) compilable. – Gonzalo Medina May 3 '11 at 14:34

For each row you need to use the subfloatrow environment:

\documentclass{article}
\usepackage{floatrow}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\usepackage{caption}

\begin{document}

\begin{figure}[h!]
\ffigbox[\FBwidth]
{\begin{subfloatrow}
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{A.pdf}}%
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{B.pdf}}%
\end{subfloatrow}
\begin{subfloatrow}
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{C.pdf}}%
\sidesubfloat[]{\includegraphics[width = 0.4\textwidth]{D.pdf}}%
\end{subfloatrow}}
{\caption{this is a caption}}
\end{figure}

\end{document}


I used the demo option for graphicx to make my example code compilable for everyone; do not use that option in your actual code.

-
that was what I tried first, and for some reason it didnt work, but It seems I did something wrong then! thanks. – Timtico May 3 '11 at 15:01

As this caused me quite an headache: If there is only one subfloat in a subfloatrow things might break (this happens in very odd ways). The trick is to add an empty subfloat. e.g. \sidesubfloat[]{}{}. I don't know whether this breaks other things, but it did the job for me.

-