我已经在 Stack Exchange 中搜索了有关如何创建一个具有 2 个并排有多列的表格的投影仪的答案,我得到的所有答案都涉及具有少量列的表格。
目前我有两个表格,每个表格有 8 列,格式化为一个ieeetran
文档类,我想将它们并排放在我的投影仪文档的一张幻灯片中。
我的文档中的代码的 MSE ieeetran
:
\documentclass{ieeetran}
\usepackage{rotating}
\usepackage{booktabs, makecell, multirow}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\sisetup{table-number-alignment=center}
\caption{Confusion matrix normalized}
\label{tab1}
\settowidth\rotheadsize{\textbf{Predicted}}
\centering
\begin{tabular}{*{2}{>{\bfseries}l} *{6}{S[table-format=1.2]} }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{Class1}} & {\textbf{Class2}} & {\textbf{Class3}}
& {\textbf{Class4}} & {\textbf{Class5}} & {\textbf{Precision}}\\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& Class1 & 0.34 & 0.13 & 0.17 & 0.09 & 0.27 & 0.59 \\
& Class2 & 0.29 & 0.17 & 0.21 & 0.02 & 0.33 & 0.05 \\
& Class3 & 0.20 & 0.16 & 0.26 & 0.16 & 0.21 & 0.22 \\
& Class4 & 0.12 & 0.15 & 0.22 & 0.36 & 0.15 & 0.65 \\
& Class5 & 0.34 & 0.13 & 0.10 & 0.17 & 0.26 & 0.01 \\
\midrule
& Recall & 0.35 & 0.05 & 0.03 & 0.78 & 0.16 & \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[ht]
\caption{Confusion matrix actual class values}
\label{tab2}
\settowidth\rotheadsize{\textbf{Predicted}}
\centering
\begin{tabular}{*{2}{>{\bfseries}l} *{5}{S[table-format=4.0]}S[table-format=1.2] }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{Class1}} & {\textbf{Class2}} & {\textbf{Class3}}
& {\textbf{Class4}} & {\textbf{Class5}} & {\textbf{Precision}}\\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& Class1 & 5007 & 1896 & 2437 & 1314 & 3947 & 0.59 \\
& Class2 & 409 & 218 & 286 & 27 & 458 & 0.05 \\
& Class3 & 1688 & 1365 & 2159 & 1346 & 1759 & 0.22 \\
& Class4 & 2386 & 3093 & 4521 & 7323 & 2978 & 0.65 \\
& Class5 & 311 & 113 & 93 & 154 & 233 & 0.01 \\
\midrule
&Recall & {0.35} & {0.05} & {0.03} & {0.78} & {0.16} & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
你可能喜欢:
\documentclass{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamerfont{caption}{size=\scriptsize}
%----
\usepackage{rotating}
\usepackage{booktabs, makecell, multirow}
\usepackage{xparse} % it is not required at the latest version
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\NewExpandableDocumentCommand\mcl{O{1}m}
{\multicolumn{#1}{l}{#2}}
\usepackage{siunitx}
\begin{document}
\begin{frame}[fragile]
\frametitle{Two tables}
\begin{columns}[T]
\begin{column}{0.52\textwidth}
\begin{table}
\scriptsize
\setlength\tabcolsep{0pt}
\settowidth\rotheadsize{ \textbf{Predicted} }
\caption{Confusion matrix normalized}
\label{tab1}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} *{2}{>{\bfseries}l}
*{6}{S[table-format=1.2]} }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{C 1}} & {\textbf{C 2}} & {\textbf{C 3}}
& {\textbf{C 4}} & {\textbf{C 5}} & {\textbf{Precision}} \\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& C 1 & 0.34 & 0.13 & 0.17 & 0.09 & 0.27 & 0.59 \\
& C 2 & 0.29 & 0.17 & 0.21 & 0.02 & 0.33 & 0.05 \\
& C 3 & 0.20 & 0.16 & 0.26 & 0.16 & 0.21 & 0.22 \\
& C 4 & 0.12 & 0.15 & 0.22 & 0.36 & 0.15 & 0.65 \\
& C 5 & 0.34 & 0.13 & 0.10 & 0.17 & 0.26 & 0.01 \\
\midrule
\mcc [2]{Recall}
& 0.35 & 0.05 & 0.03 & 0.78 & 0.16 & \\
\bottomrule
\end{tabular*}
\end{table}
\end{column}
\begin{column}{0.55\textwidth}
\begin{table}
\scriptsize
\setlength\tabcolsep{0pt}
\settowidth\rotheadsize{ \textbf{Predicted} }
\caption{Confusion matrix actual class values}
\label{tab2}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} *{2}{>{\bfseries}l}
*{5}{S[table-format=4.0]}
S[table-format=1.2] }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{C 1}} & {\textbf{C 2}} & {\textbf{C 3}}
& {\textbf{C 4}} & {\textbf{C 5}} & {\textbf{Precision}} \\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& C 1 & 5007 & 1896 & 2437 & 1314 & 3947 & 0.59 \\
& C 2 & 409 & 218 & 286 & 27 & 458 & 0.05 \\
& C 3 & 1688 & 1365 & 2159 & 1346 & 1759 & 0.22 \\
& C 4 & 2386 & 3093 & 4521 & 7323 & 2978 & 0.65 \\
& C 5 & 311 & 113 & 93 & 154 & 233 & 0.01 \\
\midrule
\mcc [2]{Recall}
&{0.35} &{0.05} &{0.03} &{0.78} &{0.16} & \\
\bottomrule
\addlinespace
\mcl[8]{\emph{Note}: \textbf{C} stands for \textbf{Class}.}
\end{tabular*}
\end{table}
\end{column}
\end{columns}
\end{frame}
\end{document}
编辑: 或者对上述命题进行以下小的变形:
\documentclass{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamerfont{caption}{size=\scriptsize}
%----
\usepackage{rotating}
\usepackage{booktabs, makecell, multirow}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\NewExpandableDocumentCommand\mcl{O{1}m}
{\multicolumn{#1}{l}{#2}}
\usepackage{siunitx}
\begin{document}
\begin{frame}[fragile]
\frametitle{Two tables (second variant)}
\begin{columns}[T]
\begin{column}{0.52\textwidth}
\begin{table}
\scriptsize
\setlength\tabcolsep{0pt}
\settowidth\rotheadsize{ \textbf{Predicted} }
\caption{Confusion matrix normalized}
\label{tab1}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} *{2}{>{\bfseries}l}
*{6}{S[table-format=1.2]} }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{C 1}} & {\textbf{C 2}} & {\textbf{C 3}}
& {\textbf{C 4}} & {\textbf{C 5}} & {\textbf{P}} \\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& C 1 & 0.34 & 0.13 & 0.17 & 0.09 & 0.27 & 0.59 \\
& C 2 & 0.29 & 0.17 & 0.21 & 0.02 & 0.33 & 0.05 \\
& C 3 & 0.20 & 0.16 & 0.26 & 0.16 & 0.21 & 0.22 \\
& C 4 & 0.12 & 0.15 & 0.22 & 0.36 & 0.15 & 0.65 \\
& C 5 & 0.34 & 0.13 & 0.10 & 0.17 & 0.26 & 0.01 \\
\midrule
\mcc [2]{Recall}
& 0.35 & 0.05 & 0.03 & 0.78 & 0.16 & \\
\bottomrule
\end{tabular*}
\end{table}
\end{column}
\begin{column}{0.55\textwidth}
\begin{table}
\scriptsize
\setlength\tabcolsep{0pt}
\settowidth\rotheadsize{ \textbf{Predicted} }
\caption{Confusion matrix actual class values}
\label{tab2}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} *{2}{>{\bfseries}l}
*{5}{S[table-format=4.0]}
S[table-format=1.2] }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{C 1}} & {\textbf{C 2}} & {\textbf{C 3}}
& {\textbf{C 4}} & {\textbf{C 5}} & {\textbf{P}} \\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& C 1 & 5007 & 1896 & 2437 & 1314 & 3947 & 0.59 \\
& C 2 & 409 & 218 & 286 & 27 & 458 & 0.05 \\
& C 3 & 1688 & 1365 & 2159 & 1346 & 1759 & 0.22 \\
& C 4 & 2386 & 3093 & 4521 & 7323 & 2978 & 0.65 \\
& C 5 & 311 & 113 & 93 & 154 & 233 & 0.01 \\
\midrule
\mcc [2]{Recall}
&{0.35} &{0.05} &{0.03} &{0.78} &{0.16} & \\
\bottomrule
\addlinespace
\mcl[8]{\emph{Note}: \makecell[lt]{\textbf{C} stands for \textbf{Class}\\ and \textbf{P} for \textbf{Precision}.}}
\end{tabular*}
\end{table}
\end{column}
\end{columns}
\end{frame}
\end{document}