我正在尝试使用 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}