代码
\documentclass{statsoc}
\begin{document}
\begin{table}
\caption{The confusion tables for Subject 1}
\hline\hline %inserts double horizontal lines
Bagging\\
\begin{tabular}{c c c c c c} % centered columns (4 columns)
\hline\hline %inserts double horizontal lines
Predicted \textbackslash Actual & Speed 1 & Speed 2 & Speed 3 & Speed 4 &
Speed 5 \\ [0.5ex] % inserts table
%heading
\hline % inserts single horizontal line
Speed 1 & 24 & 0 & 0 & 0 & 0 \\ % inserting body of the table
Speed 2 & 0 & 25 & 0 & 1 & 0 \\
Speed 3 & 0 & 0 & 25 & 0 & 0 \\
Speed 4 & 0 & 0 & 0 & 24 & 0\\
Speed 5 & 1 & 0 & 0 & 0 & 25 \\ [1ex] % [1ex] adds vertical space
\hline\hline %inserts single line
Boosting\\
\hline\hline %inserts single line
Predicted \textbackslash Actual & Speed 1 & Speed 2 & Speed 3 & Speed 4 &
Speed 5 \\ [0.5ex] % inserts table
%heading
\hline % inserts single horizontal line
Speed 1 & 22 & 0 & 0 & 0 & 0 \\ % inserting body of the table
Speed 2 & 0 & 25 & 0 & 1 & 0 \\
Speed 3 & 3 & 0 & 24 & 0 & 0 \\
Speed 4 & 0 & 0 & 0 & 23 & 0\\
Speed 5 & 0 & 0 & 1 & 0 & 24 \\ [1ex] % [1ex] adds vertical space
\hline %inserts single line
\end{tabular}
\label{table:S1_confusion_table} % is used to refer this table in the text
\end{table}
\end{document}
错误
标有“Boosting the Title”的第二个表格左对齐,而不是像 Bagging Table 那样居中。
答案1
像这样?
(红线表示文本边框)
使用article
文档类姆韦是:
\documentclass{article}
\begin{document}
\centering % <---
\begin{table}
\caption{The confusion tables for Subject 1}
%\hline\hline % works only inside tabular ; inserts double horizontal lines
\begin{tabular}{c c c c c c} % centered columns (6! not 4 columns)
\multicolumn{6}{c}{Bagging} \\
\hline\hline %inserts double horizontal lines
Predicted \textbackslash Actual
& Speed 1 & Speed 2 & Speed 3 & Speed 4 & Speed 5 \\ [0.5ex] % inserts table
%heading
\hline % inserts single horizontal line
Speed 1 & 24 & 0 & 0 & 0 & 0 \\ % inserting body of the table
Speed 2 & 0 & 25 & 0 & 1 & 0 \\
Speed 3 & 0 & 0 & 25 & 0 & 0 \\
Speed 4 & 0 & 0 & 0 & 24 & 0\\
Speed 5 & 1 & 0 & 0 & 0 & 25 \\ [1ex] % [1ex] adds vertical space
\hline\hline %inserts single line
\multicolumn{6}{c}{Boostingm}\\
\hline\hline %inserts single line
Predicted \textbackslash Actual & Speed 1 & Speed 2 & Speed 3 & Speed 4 &
Speed 5 \\ [0.5ex] % inserts table
%heading
\hline % inserts single horizontal line
Speed 1 & 22 & 0 & 0 & 0 & 0 \\ % inserting body of the table
Speed 2 & 0 & 25 & 0 & 1 & 0 \\
Speed 3 & 3 & 0 & 24 & 0 & 0 \\
Speed 4 & 0 & 0 & 0 & 23 & 0\\
Speed 5 & 0 & 0 & 1 & 0 & 24 \\ [1ex] % [1ex] adds vertical space
\hline %inserts single line
\end{tabular}
\label{table:S1_confusion_table} % is used to refer this table in the text
\end{table}
\end{document}
\hline
不应该在外面tabular
。为了使“标题”居中,您应该使用\multicolumn
环境。
编辑:
我将借助以下包来设计您的表格booktbs
:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\renewcommand\arraystretch{1.2}
\caption{The confusion tables for Subject 1}
\begin{tabular}{c c c c c c} % centered columns (6! not 4 columns)
\toprule
\multicolumn{6}{c}{Bagging} \\
\midrule
Predicted \textbackslash Actual
& Speed 1 & Speed 2 & Speed 3 & Speed 4 & Speed 5 \\
%heading
\hline % inserts single horizontal line
Speed 1 & 24 & 0 & 0 & 0 & 0 \\
Speed 2 & 0 & 25 & 0 & 1 & 0 \\
Speed 3 & 0 & 0 & 25 & 0 & 0 \\
Speed 4 & 0 & 0 & 0 & 24 & 0 \\
Speed 5 & 1 & 0 & 0 & 0 & 25 \\
\midrule
\multicolumn{6}{c}{Boostingm}\\
\midrule
Predicted \textbackslash Actual & Speed 1 & Speed 2 & Speed 3 & Speed 4 &
Speed 5 \\ [0.5ex] % inserts table
%heading
\midrule
Speed 1 & 22 & 0 & 0 & 0 & 0 \\ % inserting body of the table
Speed 2 & 0 & 25 & 0 & 1 & 0 \\
Speed 3 & 3 & 0 & 24 & 0 & 0 \\
Speed 4 & 0 & 0 & 0 & 23 & 0\\
Speed 5 & 0 & 0 & 1 & 0 & 24 \\
\bottomrule
\end{tabular}
\label{table:S1_confusion_table} % is used to refer this table in the text
\end{table}
\end{document}
这使: