在表格中,我如何画一条水平线来分隔每三种智能手机型号?我的意思是在 LG、三星和小米之后必须有另一条线来分隔它们。此外,我还需要根据前三种型号分隔 25%、50% 和 75%。谢谢。
\begin{table*}[t!]
\caption{Localization errors in the three testing scenarios.}
\label{table:tab5}
\centering
\scalebox{0.82}{
\begin{tabular}{|P{0.15\linewidth}|P{0.20\linewidth}|P{0.15\linewidth}|P{0.14\linewidth}|P{0.14\linewidth}|}
\hline
Testing condition&
Performance comparison&
Smartphone model&
A&
B
\\\hline
Scenario 1 & \makecell{25\% error \\ 50\% error \\75\% error} & \makecell{LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi } & \makecell {1.675 \\ 2.134 \\ 2.563 \\3.858 \\4.892 \\ 4.593 \\6.564 \\ 8.277 \\ 6.723}& \makecell {2.179 \\ 2.758 \\ 2.845 \\4.215 \\ 5.560 \\ 4.964 \\7.568 \\ 8.537 \\ 7.232 } \\\hline
Scenario 2 & \makecell{25\% error \\ 50\% error \\75\% error} & \makecell{LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi } & \makecell {2.021 \\ 2.171 \\ 2.568 \\3.021 \\3.452 \\ 4.078 \\5.691 \\ 8.277 \\ 6.328}& \makecell {2.396 \\ 2.435 \\ 2.960 \\3.156 \\3.785 \\ 4.951 \\6.413 \\ 7.809 \\ 7.625} \\\hline
Scenario 3 & \makecell{25\% error \\ 50\% error \\75\% error}& \makecell{LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi \\LG \\ Samsung \\Xiaomi } & \makecell {1.849 \\ 1.724 \\ 2.341 \\3.052 \\3.148 \\ 4.654 \\4.794 \\ 6.273 \\ 6.738} & \makecell {2.515 \\ 2.369 \\ 3.209 \\3.387 \\4.577 \\ 5.479 \\6.044 \\ 8.248 \\ 8.669} \\\hline
\end{tabular}}
\end{table*}
答案1
{NiceTabular}
下面显示了如何使用 制作该表nicematrix
。
\documentclass{article}
\usepackage{caption}
\usepackage{nicematrix}
\begin{document}
\begin{table*}[t!]
\caption{Localization errors in the three testing scenarios.}
\label{table:tab5}
\centering
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular}{X[3,m,c]X[4,m,c]X[3,m,c]X[3,m,c]X[3,m,c]}[hvlines]
Testing condition & Performance comparison & Smartphone model & A & B \\
\Block{9-1}{} & \Block{3-1}{} & LG & 1.675 & 2.179 \\
& 25\% error & Samsung & 2.134 & 2.758 \\
& & Xiaomi & 2.563 & 2.845 \\
& \Block{3-1}{} & LG & 3.858 & 4.215 \\
Scenario 1 & 50\% error & Samsung & 4.892 & 5.560 \\
& & Xiaomi & 4.593 & 4.964 \\
& \Block{3-1}{} & LG & 6.564 & 7.568 \\
& 75\% error & Samsung & 8.277 & 8.537 \\
& & Xiaomi & 6.723 & 7.232 \\
\Block{9-1}{} & \Block{3-1}{} & LG & 2.021 & 2.396 \\
& 25\% error & Samsung & 2.171 & 2.435 \\
& & Xiaomi & 2.568 & 2.960 \\
& \Block{3-1}{} & LG & 3.021 & 3.156 \\
Scenario 2 & 50\% error & Samsung & 3.452 & 3.785 \\
& & Xiaomi & 4.078 & 4.951 \\
& \Block{3-1}{} & LG & 5.691 & 6.413 \\
& 75\% error & Samsung & 8.277 & 7.809 \\
& & Xiaomi & 6.328 & 7.625 \\
\Block{9-1}{} & \Block{3-1}{} & LG & 1.849 & 2.515 \\
& 25\% error & Samsung & 1.724 & 2.369 \\
& & Xiaomi & 2.341 & 3.209 \\
& \Block{3-1}{} & LG & 3.052 & 3.387 \\
Scenario 3 & 50\% error & Samsung & 3.148 & 4.577 \\
& & Xiaomi & 4.654 & 5.479 \\
& \Block{3-1}{} & LG & 4.794 & 6.044 \\
& 75\% error & Samsung & 6.273 & 8.248 \\
& & Xiaomi & 6.738 & 8.669 \\
\end{NiceTabular}
\end{table*}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。
答案2
您不需要makecell
在这里使用包。我将提供一个替代解决方案,tblr
其环境为tabularray
包裹:
\documentclass{article}
\usepackage{caption}
\usepackage{tabularray}
\begin{document}
\begin{table*}[t!]
\caption{Localization errors in the three testing scenarios.}
\label{table:tab5}
\centering
\begin{tblr}{
colspec = {|X[3,m,c]|X[4,m,c]|X[3,m,c]|X[3,m,c]|X[3,m,c]|},
cell{2,11,20}{1} = {r=9}{c}, %multirow
cell{2,5,8,11,14,17,20,23,26}{2} = {r=3}{c}, %multirow
}
\hline
Testing condition & Performance comparison & Smartphone model & A & B \\
\hline
Scenario 1 & 25\% error & LG & 1.675 & 2.179 \\
& & Samsung & 2.134 & 2.758 \\
& & Xiaomi & 2.563 & 2.845 \\
\hline
& 50\% error & LG & 3.858 & 4.215 \\
& & Samsung & 4.892 & 5.560 \\
& & Xiaomi & 4.593 & 4.964 \\
\hline
& 75\% error & LG & 6.564 & 7.568 \\
& & Samsung & 8.277 & 8.537 \\
& & Xiaomi & 6.723 & 7.232 \\
\hline
Scenario 2 & 25\% error & LG & 2.021 & 2.396 \\
& & Samsung & 2.171 & 2.435 \\
& & Xiaomi & 2.568 & 2.960 \\
\hline
& 50\% error & LG & 3.021 & 3.156 \\
& & Samsung & 3.452 & 3.785 \\
& & Xiaomi & 4.078 & 4.951 \\
\hline
& 75\% error & LG & 5.691 & 6.413 \\
& & Samsung & 8.277 & 7.809 \\
& & Xiaomi & 6.328 & 7.625 \\
\hline
Scenario 3 & 25\% error & LG & 1.849 & 2.515 \\
& & Samsung & 1.724 & 2.369 \\
& & Xiaomi & 2.341 & 3.209 \\
\hline
& 50\% error & LG & 3.052 & 3.387 \\
& & Samsung & 3.148 & 4.577 \\
& & Xiaomi & 4.654 & 5.479 \\
\hline
& 75\% error & LG & 4.794 & 6.044 \\
& & Samsung & 6.273 & 8.248 \\
& & Xiaomi & 6.738 & 8.669 \\
\hline
\end{tblr}
\end{table*}
\end{document}