![在表中创建多个多行](https://linux22.com/image/416914/%E5%9C%A8%E8%A1%A8%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%A4%9A%E4%B8%AA%E5%A4%9A%E8%A1%8C.png)
我目前有一个带有以下代码的表格,我想以下面发布的图像的形式获取它。
\begin{table}[ht]
\caption{####}\label{table:####}
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline
\multirow{2}{*}{A} &
\multicolumn{2}{c}{B} &
\multicolumn{2}{c}{C} &
\multicolumn{2}{c|}{D} \\
&
Modell& A& A& A& A& A\\
\hline
Modell& A& A& 11461 & A& A& A\\
\hline
Modell & A & A& A& A& A& A\\
\hline
Modell & A & A& A& A& A& A\\
\hline
Modell & A & A& A& A& A& A\\
\hline
\end{tabular}
\end{tab}
图像代表预期的最终结果,我只需要多个行来表示我的数据。
答案1
您可以使用\cline
而不是\hline
,来仅覆盖从第二列开始的列。
但是,笼状桌子确实很丑,所以我也提出了一种不同的实现方式。
\documentclass{article}
\usepackage{booktabs} % for the second realization
\begin{document}
\begin{table}
\centering
\caption{A caged table}\label{caged}
\begin{tabular}{|l|l|c|c|c|c|c|c|}
\hline
Model & A & \multicolumn{2}{l|}{B} & \multicolumn{2}{l|}{C} & \multicolumn{2}{l|}{D} \\
\hline
Model 1 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
\cline{2-8}
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\cline{2-8}
& A3 & B3.1 & B3.2 & C3.1 & C3.2 & D3.1 & D3.2 \\
\cline{2-8}
& A4 & B4.1 & B4.2 & C4.1 & C4.2 & D4.1 & D4.2 \\
\hline
Model 2 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
\cline{2-8}
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\hline
Model 3 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
\cline{2-8}
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\hline
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{A better table}\label{better}
\begin{tabular}{@{}lccccccc@{}}
\toprule
Model & A & \multicolumn{2}{c}{B} & \multicolumn{2}{c}{C} & \multicolumn{2}{c}{D} \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(l){7-8}
& & B1 & B2 & C1 & C2 & D1 & D2 \\
\midrule
Model 1 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
& A3 & B3.1 & B3.2 & C3.1 & C3.2 & D3.1 & D3.2 \\
& A4 & B4.1 & B4.2 & C4.1 & C4.2 & D4.1 & D4.2 \\
\midrule
Model 2 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\midrule
Model 3 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\midrule
\end{tabular}
\end{table}
\end{document}