我想创建多行表。这是基线表。
documentclass[prodmode,acmtecs]{acmsmall} % Aptara syntax
\usepackage[ruled]{algorithm2e}
\usepackage{multirow}
\begin{document}
\section{Introduction}
\begin{table}[!t]
\tbl{The caption.\label{cap}}
{\begin{tabular}{p{2.0cm}p{3.0cm}p{3.5cm}p{1.0cm}p{0.8cm}p{0.8cm}}
\hline
\textbf{Workload} & \textbf{Description} & \textbf{Input} & \textbf{Miss Ratio} & \textbf{MPKI} & \textbf{LPKI} \\
\hline
A & B & C & 1 & 2 & 3 \\
\hline
D & E & F & 4 & 5 & 6 \\
\hline
G & H & I & 7 & 8 & 9 \\
\hline
J & K & L & 10 & 11 & 12 \\
\hline
M & N & O & 13 & 14 & 15 \\
\hline
P & Q & R & 16 & 17 & 18 \\
\hline\hline
S & T & U & 19 & 20 & 21 \\
\hline
V & W & X & 22 & 23 & 24 \\
\hline
Y & Z & AA & 25 & 26 & 27 \\
\hline
AB & AC & AD & 28 & 28 & 29 \\
\hline
AE & AF & AG & 30 & 31 & 32 \\
\hline
AH & AI & AJ & 33 & 34 & 35 \\
\hline\hline
AK & AL & AM & 36 & 37 & 38 \\
\hline
AN & AO & AP & 39 & 40 & 41 \\
\hline
\end{tabular}}
\end{table}
\medskip
\end{document}
输出为
现在我想将workload
列分成两列。像这样
+-----------------+----
| workload
+----------+-----------
| | A
| | D
| group1 | G
| | J
| | M
| | P
-----------------------
-----------------------
| | S
| | V
| group2 | Y
| | AB
| | AE
| | AH
-----------------------
-----------------------
| | AK
| group3 | AN
-----------------------
因此,我在表格行上添加了另一列,将 6{}p 增加到 7p{},并添加了以下几行
\multirow{6}{*}{group1} & A & B & C & 1 & 2 & 3 \\
...
\multirow{6}{*}{group2} & S & T & U & 19 & 20 & 21 \\
...
\multirow{2}{*}{group3} & AK & AL & AM & 36 & 37 & 38 \\
但结果却远远超出了预期。事实上,我没有看到任何行跨度!!
更新
应用答案中的方法并将 A、B、... 替换为真实文本后,我看到此输出
\addlinespace
我使用了而不是\hline
。如您所见,每组中的行之间都有间隙。
答案1
应该使用水平线来构造内容,但右侧的空白也可以起到同样的作用。看看表格,它看起来更干净。请注意规则前后的小空白。
这个包siunitx
帮助我们将数字按小数点对齐。
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
{\begin{tabular}{lcccS[table-format=2]S[table-format=2]S[table-format=2]}
\toprule
\multicolumn{2}{c}{Workload} & {Description} & {Input} & {Miss Ratio} & {MPKI} & {LPKI} \\
\midrule
& A & B & C & 1 & 2 & 3 \\
& D & E & F & 4 & 5 & 6 \\
group1 & G & H & I & 7 & 8 & 9 \\
& J & K & L & 10 & 11 & 12 \\
& M & N & O & 13 & 14 & 15 \\
& P & Q & R & 16 & 17 & 18 \\\addlinespace[1.3ex]
& S & T & U & 19 & 20 & 21 \\
& V & W & X & 22 & 23 & 24 \\
group2 & Y & Z & AA & 25 & 26 & 27 \\
& AB & AC & AD & 28 & 28 & 29 \\
& AE & AF & AG & 30 & 31 & 32 \\
& AH & AI & AJ & 33 & 34 & 35 \\\addlinespace[1.3ex]
group3 & AK & AL & AM & 36 & 37 & 38 \\
& AN & AO & AP & 39 & 40 & 41 \\
\bottomrule
\end{tabular}}
\end{document}
我不太确定我是否理解了这个问题。我尝试构建一个场景,但没有成功。目前我无法重现这种行为。请注意,这multirow
总是需要手工劳动。请注意,我使用\midrule
了再次以获得更好的间距。
请考虑以下事项
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{array}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{2.5cm}}
\begin{document}
{\begin{tabular}{lLLLS[table-format=2]S[table-format=2]S[table-format=2]}
\toprule
\multicolumn{2}{c}{Workload} & {Description} & {Input} & {Miss Ratio} & {MPKI} & {LPKI} \\
\midrule \multirow{15}{*}{\rotatebox{90}{group1}} & Lions are pretty big & Every lock has its key & Canada is a country. & 1 & 2 & 3 \\
& some useful information here & E & F & 4 & 5 & 6 \\
& Why did the duck cross the road? & H & I & 7 & 8 & 9 \\
& There are footprints on your back & K & L & 10 & 11 & 12 \\
& Did the lion eat the zebra? & N & O & 13 & 14 & 15 \\
& There's a cat on the window sill & Q & R & 16 &
17 & 18 \\\midrule
& Lions are pretty big & Every lock has its key & Canada is a country. & 1 & 2 & 3 \\
& some useful information here & E & F & 4 & 5 & 6 \\
& Why did the duck cross the road? & H & I & 7 & 8 & 9 \\
group1 & There are footprints on your back & K & L & 10 & 11 & 12 \\
& Did the lion eat the zebra? & N & O & 13 & 14 & 15 \\
& There's a cat on the window sill & Q & R & 16 &
17 & 18 \\\midrule
\multirow{6}{*}{\rotatebox{90}{group2}} & S & T & U & 19 & 20 & 21 \\
& V & W & X & 22 & 23 & 24 \\
& Y & Z & AA & 25 & 26 & 27 \\
& AB & AC & AD & 28 & 28 & 29 \\
& AE & AF & AG & 30 & 31 & 32 \\
& AH & AI & AJ & 33 &
34 & 35 \\\midrule
\multirow{2}{*}{group3} & AK & AL & AM & 36 & 37 & 38 \\
& AN & AO & AP & 39 & 40 & 41 \\
\bottomrule
\end{tabular}}
\end{document}