我想用 tabularray 生成一个包含合并单元格的表格。最小示例如下所示:
\documentclass{article}
\usepackage{rotating}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{amssymb}
\begin{document}
\begin{table*}
\centering
\begin{tblr}{
cell{2}{1} = {r=2}{},
cell{2}{3} = {c=3}{},
colspec = {ll|ccc},
columns = {valign = m}
}
\toprule
& \textbf{Attacker} & \rotatebox{90}{\textbf{Content}} & \rotatebox{90}{\textbf{Metadata}} & \rotatebox{90}{\textbf{Profiling}} \\
\midrule
Architecture A & User A & Only in proximity of the victim. & & \\
& User B & \checkmark & \checkmark & \checkmark\\
\end{tblr}
\end{table*}
\end{document}
合并单元格的内容属于“内容”、“元数据”和“分析”列。目前,如您所见,“内容”和“元数据”列具有其最小宽度,而“分析”列的宽度与合并单元格的内容一样。我该怎么做,才能使它们都具有相同的宽度并居中对齐?除了手动指定它们的宽度之外,还有其他可能吗?
答案1
您可以使用hspan=even
选项来分发它们均匀地:
\documentclass{article}
\usepackage{rotating}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{amssymb}
\begin{document}
\begin{table*}
\centering
\begin{tblr}{
cell{2}{1} = {r=2}{},
cell{2}{3} = {c=3}{},
colspec = {ll|ccc},
columns = {valign = m},
hspan=even
}
\toprule
& \textbf{Attacker} & \rotatebox{90}{\textbf{Content}} & \rotatebox{90}{\textbf{Metadata}} & \rotatebox{90}{\textbf{Profiling}} \\
\midrule
Architecture A & User A & Only in proximity of the victim. & & \\
& User B & \checkmark & \checkmark & \checkmark\\
\end{tblr}
\end{table*}
\end{document}