Figure and Table next to each other (memoir class) [duplicate]

To save space, I would like to place the following table next to each other. Each has a separate caption. I have this,

I want this,

Sample code,

\documentclass[]{memoir}
\usepackage[utf8x]{inputenc}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{algorithmic}
\usepackage{algorithmicthesis}

\begin{document}

\begin{figure}
\centering
\includegraphics[scale=0.2]{figure.png}
\caption{This is the caption for figure}
\end{figure}
\begin{table}
\centering
\caption{This is the caption for table}
\begin{tabular}{cc}
1 & Item 1 \\
3 & Item 2 \\
4 & Item 3 \\
5 & Item 4 \\
5 & Item 5 \\
\end{tabular}
\end{table}

\end{document}


The solution mentioned here doesn’t allow two captions.

-
And another possible duplicate: tex.stackexchange.com/q/62282/21591 . –  mafp Mar 19 '13 at 11:00

marked as duplicate by mafp, zeroth, Andrew Swann, diabonas, lockstepMar 19 '13 at 11:36

The capt-of package provides the right solution with \captionof. Also caption provides it, but this package is not recommended with memoir; on the contrary, the trick performed by capt-of is compatible with this class.

\documentclass{memoir}
\usepackage[demo]{graphicx} % the demo option is just for the example
\usepackage{capt-of}

\begin{document}

\begin{figure}
\centering
\begin{minipage}[t]{.4\textwidth}
\centering
\vspace{0pt}
\includegraphics[width=\textwidth]{figure.png}
\caption{This is the caption for figure}
\end{minipage}\hfill
\begin{minipage}[t]{.4\textwidth}
\centering
\vspace{0pt}
\captionof{table}{This is the caption for table}
\begin{tabular}{cc}
1 & Item 1 \\
3 & Item 2 \\
4 & Item 3 \\
5 & Item 4 \\
5 & Item 5 \\
\end{tabular}
\end{minipage}
\end{figure}

\end{document}


The \vspace{0pt} commands are to ensure top alignment. Dispose of them as you wish.

-
Thanks. This works. \hspace{} can be used instead of \file to fine tune space between columns. –  entropy Mar 19 '13 at 11:14
I didn't even know that the capt-of package exists but that was I was looking for. :) –  hpesoj626 Mar 19 '13 at 12:40

I agree with your comment, egreg. Now I adjunt an elaborate example:

\begin{figure}[htbp]\RawFloats
\begin{minipage}{0.65\textwidth}
\centering
\includegraphics[scale=0.75]{figure.pdf}
\captionof{figure}{caption of figure\label{fig06-42a}}
\end{minipage}

\begin{minipage}{0.25\textwidth}
\begin{center}
\captionof{table}{caption of table}\label{tab3}
\vspace{6pt}
\begin{tabular}{c c}
\hline
\rule[-8pt]{0pt}{22pt}$M$& \hspace{20pt}$10 \log_{10}R_{M}$  \\
\hline
\rule{0pt}{14pt}8&\hspace{20pt} 1,65 \\
16&\hspace{20pt} 4,20 \\
32&\hspace{20pt} 7,02 \\
64&\hspace{20pt} 9,95 \\
\hline
\end{tabular}
\end{center}
\end{minipage}
\end{figure}

-
@hpsoj626 Thanks for your edition. –  jpayansomet Mar 19 '13 at 12:56