我正在尝试格式化表格,使其前两行和第一列留有空白。这意味着第 {1} 行没有垂直线,但另一行必须有。还没想好怎么做。这是我的 MWE:
\documentclass[12pt]{report}
\usepackage{multirow, array} % Opciones para trabajar con tablas
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{tblr}[
caption = {Title.},
label = {tab:an-c-cortes},
entry = {},
]{
colspec = {Q[l,m,2cm]|Q|Q|Q|Q|Q|Q|Q|},
rowhead = 1,
row{1} = {font = \footnotesize\bfseries},
row{2-Z} = {font = \footnotesize},
rowsep = 0pt,
% cell{2-Z}{1} = {c},
}
\cline{3-8}
\SetCell[c=2]{c} & & \SetCell[c=2]{c} Data 1 & & \SetCell[c=2]{c} Data 2 & & \SetCell[c=2]{c} Data 3 \\
\hline
\SetCell{c} A & B & Puntaje & C & Puntaje & D & E & F \\
\hline
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
\hline
\end{tblr}
\end{document}
表格输出:
答案1
像这样?
您的表格是简单表格还是长表格并不完全清楚。您编写的代码很乱。在下面的 MWE 中,我假设第一个表格是table
浮动表格,带有标题:
\documentclass[12pt]{report}
%\usepackage{multirow, array} % Not used in this MWE pciones para trabajar con tablas
\usepackage[skip=0.33\baselineskip]{caption}
%\usepackage{xcolor} % Not used in this MWE
\usepackage{tabularray}
%\UseTblrLibrary{booktabs} % Not used in this MWE
\begin{document}
\begin{table}[ht]
\centering
\caption{Title.}
\label{tab:an-c-cortes}
\begin{tblr}{hline{1}={3-Z}{solid}, hline{2-Z}={solid}, % changed
vline{1-2}={2-Z}{solid}, vline{3-Z}={solid}, % new
colspec = {*{3}{Q[c, wd=12mm] c} *{2}{Q[c, wd=2em]}}, % changed
cell{1}{odd} = {c=2}{}, % in first row are multi column cells
row{1} = {font = \footnotesize\bfseries},
row{2-Z} = {font = \footnotesize},
}
& & Data 1 & & Data 2 & & Data 3 & \\
A & B & Puntaje & C & Puntaje & D & E & F \\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
\end{tblr}
\end{table}
\end{document}
答案2
供参考,这里是一种使用来创建该表的方法nicematrix
。
\documentclass[12pt]{report}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{nicematrix}
\begin{document}
\begin{table}[ht]
\centering
\caption{Title.}
\label{tab:an-c-cortes}
\begin{NiceTabular}{*{8}{c}}[hvlines,corners]
& & \Block{1-2}{Data 1} & & \Block{1-2}{Data 2} & & \Block{1-2}{Data 3} \\
A & B & Puntaje & C & Puntaje & D & E & F \\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
\end{NiceTabular}
\end{table}
\end{document}