如果有人能帮助我我会非常高兴。
我使用以下代码来生成表格:
\begin{table}
\centering
\begin{tabular}{ccccccccccl}
\toprule
& \multicolumn{2}{c}{$\BART<BASE>$}& \multicolumn{2}{c}{$\SIMPLE<1L>$}& \multicolumn{2}{c}{$\SIMPLE<3L>$}& \multicolumn{2}{c}{$\SIMPLE<6L>$}& \multicolumn{2}{c}{$\SIMPLE<1L>$}\\
\midline{2-3}\midline{4-5}\midline{6-7}\midline{8-9}\midline{10-11}
& $\bpe$& $\wordwise$& $\bpe$& $\wordwise$& $\bpe$& $\wordwise$& $\bpe$& $\wordwise$& $\bpe$& $\wordwise$\\
\midrule
$\mathbf{Acc}$& 99.1\%& 98.1\%& 73.6\%& 56.0\%& 92.4\%& 87.2\%& 94.4\%& 89.7\%& 99.6\%& 99.7\%\\
$\mathbf{Acc}_{BR}$& 90.5\%& 90.1\%& 33.7\%& 8.8\%& 81.7\%& 90.3\%& 78.1\%& 89.8\%& 95.3\%& 97.6\%\\
\bottomrule
\end{tabular}
\caption{Scores averaged over all grammars}
\label{tab:my_label}
\end{table}
我在文档中将命令 \midline 定义为
\newcommand\midline[1]{\cmidrule(lr){#1}}
但我最终得到的是阶梯状的斜坡。
我只是希望他们能在一起……
答案1
除了不要“埋葬”\cmidrule
指令之外,您还不应该右修剪最后\cmidrule
一行。即,用 替换\cmidrule(lr){10-11}
。\cmidrule(l){10-11}
而且,我认为您应该将 11 列设置为l *{10}{c}
而不是*{10}c l
。
\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters as needed
\usepackage{booktabs}
\newcommand\bpe{\mathcal{T}^{\mathit{bpe}}} % ?
\newcommand\wordwise{\mathcal{T}^{\mathit{words}}} % ?
\begin{document}
\begin{table}
\centering
$\begin{array}{@{} l *{10}{c} @{}}
\toprule
& \multicolumn{2}{c}{\mathrm{BART}_{\mathrm{BASE}}}
& \multicolumn{2}{c}{\mathrm{SIMPLE}_{\mathrm{1L}}}
& \multicolumn{2}{c}{\mathrm{SIMPLE}_{\mathrm{3L}}}
& \multicolumn{2}{c}{\mathrm{SIMPLE}_{\mathrm{6L}}}
& \multicolumn{2}{c@{}}{\mathrm{SIMPLE}_{\mathrm{1L}}}\\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
\cmidrule(lr){6-7} \cmidrule(lr){8-9}
\cmidrule(l){10-11}
& \bpe& \wordwise & \bpe& \wordwise
& \bpe& \wordwise & \bpe& \wordwise
& \bpe& \wordwise\\
\midrule
\mathbf{Acc}
& 99.1\%& 98.1\%& 73.6\%& 56.0\%& 92.4\%& 87.2\%& 94.4\%& 89.7\%& 99.6\%& 99.7\%\\
\mathbf{Acc}_{\mathrm{BR}}
& 90.5\%& 90.1\%& 33.7\%& 8.8\%& 81.7\%& 90.3\%& 78.1\%& 89.8\%& 95.3\%& 97.6\%\\
\bottomrule
\end{array}$
\caption{Scores averaged over all grammars}
\label{tab:my_label}
\end{table}
\end{document}
答案2
编写表格的另一种方法是使用tabularray
带有库的 \packagebooktabs
并siunitx
加载同名的包:
\documentclass{article} % used document class is unknown
\usepackage{geometry} % your document layout is unknown
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
% column headers symbols
\newcommand\Tbpe{\mathcal{T}^{\mathit{bpe}}}
\newcommand\Tword{\mathcal{T}^{\mathit{words}}}
\newcommand\SIMPLE[1]{\mathrm{SIMPLE}_{\mathrm{#1L}}}
\begin{document}
\begin{table}
\begin{tblr}{colspec = {@{} Q[l, mode=math] *{10}{X[c, si={table-format=2.1}]} @{}},
cell{1}{even[2]} = {c=2}{},
cell{3-Z}{2-Z} = {appto={\,\%}},
row{1,2} = {guard, mode=math},
}
\toprule
& \mathrm{BART}_{\mathrm{BASE}} &
& \SIMPLE{1} &
& \SIMPLE{3} &
& \SIMPLE{6} &
& \SIMPLE{1} & \\
\cmidrule[lr]{2-3} \cmidrule[lr]{4-5} \cmidrule[lr]{6-7}
\cmidrule[lr]{8-9} \cmidrule[l]{10-11}
& \Tbpe &\Tword & \Tbpe &\Tword & \Tbpe &\Tword & \Tbpe &\Tword & \Tbpe & \Tword \\
\midrule
\mathbf{Acc}
& 99.1 & 98.1 & 73.6 & 56.0 & 92.4 & 87.2 & 94.4 & 89.7 & 99.6 & 99.7 \\
\mathbf{Acc}_{\mathrm{BR}}
& 90.5 & 90.1 & 33.7 & 8.8 & 81.7 & 90.3 & 78.1 & 89.8 & 95.3 & 97.6 \\
\bottomrule
\end{tblr}
\caption{Scores averaged over all grammars}
\label{tab:my_label}
\end{table}
\end{document}