这是我正在处理的片段:
\begin{landscape}
\begin{table}[hbt!]
\centering
\begin{tabularx}{5.75in}%
{@{} P{1in} P{0.4in} P{0.4in} P{0.5in} P{0.5in} P{0.4in} P{0.4in} P{0.5in} P{0.5in} @{}}
\toprule
\multicolumn{1}{c}{\multirow{3}{*}{\textbf{Average Accuracy}}}
& \multicolumn{4}{c}{\textbf{ResNet-50}} & \multicolumn{4}{c}{\textbf{MobileNet-V2}} \tabularnewline
\cmidrule(lr){2-9}
& \multicolumn{2}{c}{Segmentation} & \multicolumn{2}{c}{Non-Segmentation} & \multicolumn{2}{c}{Segmentation} & \multicolumn{2}{c}{Non-Segmentation} \tabularnewline
\cmidrule(lr){2-9}
& \centering SVM & \centering KNN & \centering SVM & \centering KNN & \centering SVM & \centering KNN & \centering SVM & \centering SVM & \centering KNN \tabularnewline
\midrule
Training & 0.85 & 0.74 & 0.73 & 0.72 & 0.76 & 0.70 & 0.70 & 0.69 \tabularnewline
Test & 0.84 & 0.73 & 0.72 & 0.70 & 0.75 & 0.69 & 0.69 & 0.62 \tabularnewline
\bottomrule
\end{tabularx}
\caption{Cassava Disease Detection System Performance Results \parencite{Sedat2021Disease}}
\label{table:Cassava Disease Detection System Performance Results}
\end{table}
\end{landscape}
但是,第 3 行居中仅适用于合并单元格,因此我必须手动将非合并单元格的文本居中。但是,我遇到了一个许多人都熟悉的错误,即使最后一列文本居中。有人知道如何修复它吗?非常感谢您的帮助。谢谢!
答案1
您的标题和副标题太长:请缩短它们。这样就不需要横向模式了。
\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage{biblatex}
\begin{document}
\begin{table}[hbtp!]
\centering
\begin{tabular}{
@{}
l
*{8}{S[table-format=1.2]}
@{}
}
\toprule
\smash{\bfseries\begin{tabular}[t]{@{}l@{}}Average \\ Accuracy\end{tabular}} &
\multicolumn{4}{c}{\textbf{ResNet-50}} &
\multicolumn{4}{c@{}}{\textbf{MobileNet-V2}} \\
\cmidrule(lr){2-5} \cmidrule(l){6-9}
& \multicolumn{2}{c}{S} & \multicolumn{2}{c}{NS}
& \multicolumn{2}{c}{S} & \multicolumn{2}{c@{}}{NS} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(l){8-9}
& {SVM} & {KNN} & {SVM} & {KNN} & {SVM} & {KNN} & {SVM} & {KNN} \\
\midrule
Training & 0.85 & 0.74 & 0.73 & 0.72 & 0.76 & 0.70 & 0.70 & 0.69 \\
Test & 0.84 & 0.73 & 0.72 & 0.70 & 0.75 & 0.69 & 0.69 & 0.62 \\
\bottomrule
\multicolumn{9}{@{}l@{}}{\strut\footnotesize S: Segmented; NS: Nonsegmented}
\end{tabular}
\caption{Cassava Disease Detection System Performance Results \parencite{Sedat2021Disease}}
\label{table:Cassava Disease Detection System Performance Results}
\end{table}
\end{document}
看到输出后,您可能希望将表格扩展到文本宽度。
\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage{biblatex}
\begin{document}
\begin{table}[hbtp!]
\setlength{\tabcolsep}{0pt}% leave TeX the spacing
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
l
*{8}{S[table-format=1.2]}
}
\toprule
\smash{\bfseries\begin{tabular}[t]{@{}l@{}}Average \\ Accuracy\end{tabular}} &
\multicolumn{4}{c}{\textbf{ResNet-50}} &
\multicolumn{4}{c}{\textbf{MobileNet-V2}} \\
\cmidrule{2-5} \cmidrule{6-9}
& \multicolumn{2}{c}{S} & \multicolumn{2}{c}{NS}
& \multicolumn{2}{c}{S} & \multicolumn{2}{c}{NS} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9}
& {SVM} & {KNN} & {SVM} & {KNN} & {SVM} & {KNN} & {SVM} & {KNN} \\
\midrule
Training & 0.85 & 0.74 & 0.73 & 0.72 & 0.76 & 0.70 & 0.70 & 0.69 \\
Test & 0.84 & 0.73 & 0.72 & 0.70 & 0.75 & 0.69 & 0.69 & 0.62 \\
\bottomrule
\multicolumn{9}{l}{\strut\footnotesize S: Segmented; NS: Nonsegmented}
\end{tabular*}
\caption{Cassava Disease Detection System Performance Results \parencite{Sedat2021Disease}}
\label{table:Cassava Disease Detection System Performance Results}
\end{table}
\end{document}