1

I am trying to put a figure beside a table using a minipage. Below is my table.

\documentclass[twocolumn]{book}
\usepackage   {lipsum}
\usepackage   {showframe} % just for this example
\usepackage   {subfig}
\usepackage   {tikz}
\usepackage{booktabs, array}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\begin{document}

\begin{table} \setlength{\tabcolsep}{4pt} \scriptsize \centering \caption{XX.} \begin{tabular}{l|x{.3in}x{.3in}|x{.3in}x{.3in}|x{.3in}x{.3in}} \toprule & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c}{XX} \ \textbf{Recognition} & Left & Right & Left & Right & Left & Right \ \midrule XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ \bottomrule \multicolumn{6}{c}{\textcolor{white}{1}} \ \toprule & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c}{XX} \ \textbf{Anticipation} & Left & Right & Left & Right & Left & Right \ \midrule XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ \bottomrule \end{tabular} \end{table}

\end{document}

enter image description here

The code with the minipage does not work. The table goes missing.

\documentclass[twocolumn]{book}
\usepackage   {lipsum}
\usepackage   {showframe} % just for this example
\usepackage   {subfig}
\usepackage   {tikz}
\usepackage{booktabs, array}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\begin{document}

\begin{minipage}{0.6\textwidth} \begin{table} \setlength{\tabcolsep}{4pt} \scriptsize \centering \caption{XX.} \begin{tabular}{l|x{.3in}x{.3in}|x{.3in}x{.3in}|x{.3in}x{.3in}} \toprule & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c}{XX} \ \textbf{Recognition} & Left & Right & Left & Right & Left & Right \ \midrule XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ \bottomrule \multicolumn{6}{c}{\textcolor{white}{1}} \ \toprule & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c}{XX} \ \textbf{Anticipation} & Left & Right & Left & Right & Left & Right \ \midrule XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ \bottomrule \end{tabular} \end{table} \end{minipage} \begin{minipage}{0.3\textwidth} \includegraphics[width=\textwidth]{example-image-a} \caption{caption below} \end{minipage} \end{document}

Kong
  • 2,313

1 Answers1

2

Since you can't place a floating environment such as table inside of a minipage, do it the other way around and place the minipages inside of the table.

enter image description here

\documentclass[twocolumn]{book}
\usepackage   {lipsum}
\usepackage   {showframe} % just for this example
\usepackage   {subfig}
\usepackage   {tikz}
\usepackage{booktabs, array}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\begin{document} \begin{table} \begin{minipage}{0.6\textwidth} \setlength{\tabcolsep}{4pt} \scriptsize \centering \caption{XX.} \begin{tabular}{l|x{.3in}x{.3in}|x{.3in}x{.3in}|x{.3in}x{.3in}} \toprule & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c}{XX} \ \textbf{Recognition} & Left & Right & Left & Right & Left & Right \ \midrule XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ \bottomrule \multicolumn{6}{c}{\textcolor{white}{1}} \ \toprule & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c|}{XX} & \multicolumn{2}{c}{XX} \ \textbf{Anticipation} & Left & Right & Left & Right & Left & Right \ \midrule XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ XX XX & XX & XX & XX & XX & XX & XX \ \bottomrule \end{tabular} \end{minipage} \hfill \begin{minipage}{0.3\textwidth} \includegraphics[width=\textwidth]{example-image-a} \captionof{figure}{caption below} \end{minipage} \end{table} \end{document}

leandriis
  • 62,593