2

I want to include a table and an image as two subfigures in a macro figure environment. Apparently the code compiles but it isn't placing the elements how I want: The table and the image side by side (instead of one on top of the other) in a single figure environment at the top of the page.

Here is the code:

\begin{figure*}[!t]
%\begin{table*}[!t]
\centering 
\scriptsize{
\begin{tabular}[H]{|c||c|c|c|c|c|}
\cline{1-3}
\Xhline{2\arrayrulewidth} % $k$
 & 1 & 2 & 3 & 4 & 5 \\ \cline{1-6}
\Xhline{2\arrayrulewidth}
Attribute1 & $\uparrow$ p1 & $\uparrow$ p2 & $\downarrow$ p3 & $\uparrow$ p4 & $\downarrow$ p5 \\ \cline{1-6}
Accuracy & 60.22\% & 65.24\% & 68.66\% & 70.21\% & 71.87\% \\ \cline{1-6}
\Xhline{3\arrayrulewidth}
Attribute2 & $\uparrow$ p1 & $\uparrow$ p2 & $\uparrow$ p3 & $\downarrow$ p4 & $\uparrow$ p5 \\ \cline{1-6}
Accuracy & 45.70\% & 54.53\% & 59.49\% & 62.91\% & 65.56\% \\ \cline{1-6}
\Xhline{3\arrayrulewidth}
 Attribute3 & $\uparrow$ p1 & $\uparrow$ p2 & $\uparrow$ p3 & $\uparrow$ p4 & $\downarrow$ p5 \\ \cline{1-6}
 Accuracy & 50.08\% & 60.37\% & 64.84\% & 68.02\% & 69.32\% \\ \cline{1-6}
\Xhline{2\arrayrulewidth}
\end{tabular}
}
\label{fig:AttributeComb}
%\vspace{-7pt}
\captionof{table}{Table1}
\label{table:AttributeCombT}
%\vspace{-25pt}
\subfigure[Title2]
{\includegraphics[scale=0.295,clip=true,draft=false,]{Performance.pdf}
\label{fig:performance}
}
\vspace{-25pt}

%\end{table*}
\end{figure*}
  • This would be a whole lot easier if your MWE provided all the usepackages. I'm getting a lot of errors from the tabular itself. – John Kormylo Jul 21 '14 at 22:50
2

The case of mixed floats can be managed by the floatrow package, see §2.3.1 of the documentation. I mixed one of my favourite images with your tables (slightly improved as to vertical spacing with the setcellgapes command, from mmakecell.

        \documentclass[12pt,a4paper]{article}
        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{lmodern}
        \usepackage{graphicx}
        \usepackage{caption}
        \captionsetup{font = footnotesize}
         \usepackage{floatrow, makecell}%
         \setcellgapes{2.8pt}\makegapedcells
        \begin{document}

        \begin{figure}\CenterFloatBoxes
        \floatsetup{floatrowsep = qquad}
           \begin{floatrow}
           \ffigbox[\FBwidth]{\raisebox{-1\height}{\includegraphics[scale = 0.4]{AliceSteadman}}}{\caption{Ralph Steadman’s Alice}\label{Dinah}}
             \killfloatstyle
             \ttabbox{\scriptsize%
            \begin{tabular}[H]{|c||c|c|c|c|c|}
            \cline{1-3}
            \Xhline{2\arrayrulewidth} % $k$
             & 1 & 2 & 3 & 4 & 5 \\ \cline{1-6}
            \Xhline{2\arrayrulewidth}
            Attribute1 & $\uparrow$ p1 & $\uparrow$ p2 & $\downarrow$ p3 & $\uparrow$ p4 & $\downarrow$ p5 \\ \cline{1-6}
            Accuracy & 60.22\% & 65.24\% & 68.66\% & 70.21\% & 71.87\% \\ \cline{1-6}
            \Xhline{3\arrayrulewidth}
            Attribute2 & $\uparrow$ p1 & $\uparrow$ p2 & $\uparrow$ p3 & $\downarrow$ p4 & $\uparrow$ p5 \\ \cline{1-6}
            Accuracy & 45.70\% & 54.53\% & 59.49\% & 62.91\% & 65.56\% \\ \cline{1-6}
            \Xhline{3\arrayrulewidth}
             Attribute3 & $\uparrow$ p1 & $\uparrow$ p2 & $\uparrow$ p3 & $\uparrow$ p4 & $\downarrow$ p5 \\ \cline{1-6}
             Accuracy & 50.08\% & 60.37\% & 64.84\% & 68.02\% & 69.32\% \\ \cline{1-6}
            \Xhline{2\arrayrulewidth}
            \end{tabular}
             }{\caption{A table}\label{mytable}}
           \end{floatrow}
        \end{figure}

        \end{document}

enter image description here

2

There are many ways to do this. You will note the minipages are currently set to align bottoms. The \rasieboxes are included in case you want to align tops. Also, you might want to make the second minipage wider to handle the caption in one line.

\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{mwe}

\newsavebox{\tempbox}
\newlength{\tempwidth}

\begin{document}

\begin{figure*}[!t]
%\begin{table*}[!t]
\savebox{\tempbox}{% compute size of tabulat
\scriptsize{
\begin{tabular}[b]{|c|}
Frankly, it doesn't\\
matter what your\\
tabular looks like!
\end{tabular}
}}%
\settowidth{\tempwidth}{\usebox{\tempbox}}%
\hfil\begin{minipage}[b]{\tempwidth}%
\raisebox{-\height}{\usebox{\tempbox}}%
%\vspace{-7pt}
\captionof{table}{Table1}%
\label{table:AttributeCombT}%
\end{minipage}%
%\vspace{-25pt}
\savebox{\tempbox}{\includegraphics[scale=0.295,clip=true,draft=false,]{example-image}}%
\settowidth{\tempwidth}{\usebox{\tempbox}}%
\hfil\begin{minipage}[b]{\tempwidth}%
\raisebox{-\height}{\usebox{\tempbox}}%
\captionof{figure}{performance}%
\label{fig:AttributeComb}%
\end{minipage}%
%\vspace{-25pt}
%\end{table*}
\end{figure*}

\end{document}

mixed table and figure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.