[Tex/LaTex] how to put subfigures in several rows

subfloats

basically i need something like rowspan option in html table. I want that an figure 3 and figure 4 occupy three rows, I need a layout something like this:

|figure 1 | figure 2 |               |               |
|figure 5 | figure 6 | figure 3 | figure 4 |
|figure 7 | figure 8 |               |               |

how i can get this layout?

Best Answer

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{subfig}
\usepackage{tabularx}

\begin{document}

\begin{figure}
\def\tabularxcolumn#1{m{#1}}
\begin{tabularx}{\linewidth}{@{}cXX@{}}
%
\begin{tabular}{cc}
\subfloat[A]{\includegraphics[width=2cm]{logo}} 
   & \subfloat[B]{\includegraphics[width=3cm]{logo}}\\
\subfloat[C]{\includegraphics[width=2cm]{logo}} 
   & \subfloat[D]{\includegraphics[width=3cm]{logo}}\\
\subfloat[E]{\includegraphics[width=2cm]{logo}} 
   & \subfloat[F]{\includegraphics[width=3cm]{logo}}\\
\end{tabular}
&
\subfloat[G]{\includegraphics[width=2cm,height=4cm]{logo}}
&
\subfloat[H]{\includegraphics[width=\linewidth]{logo}}
\end{tabularx}

\caption{Many figures}\label{foo}
\end{figure}

\end{document}

the demo output