如何将表格和图形放入小页面中?

如何将表格和图形放入小页面中?

我正在尝试使用 minipage 将图形放在表格旁边。下面是我的表格。

\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}

在此处输入图片描述

带有 minipage 的代码不起作用。表格丢失。

\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}

答案1

由于您无法放置浮动环境(例如 table在 内部)minipage,因此请反过来做,将其放置minipages在 内部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*}
\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}

相关内容