我在 nicetabular 中有一个表,它有一个特定的问题:列以某种方式合并了?
\begin{NiceTabular}[]{c | c | *{4}S[table-format=3.2] | *{4}S[table-format=3.2]}
& & \Block{1-4}{Shoo} & \Block{1-4}{Papapapapa} \\
\toprule
\Block{1-2}{Qualitative Comparison} & \Block{1-2}{A} & \Block{1-2}{B} & \Block{1-2}{C} & \Block{1-2}{D} & \\
\toprule
\Block{1-2}{Direct effect } & \Block{1-2}{$\nearrow$} & \Block{1-2}{$\nearrow$} & \Block{1-2}{-} & \Block{1-2}{-} \\
$\%$\textbf{ foo} & \textbf{bar} & $\mu$=0.025 & $\mu$=0.05 \\ \toprule
a & b & -0.9 & -1.7 & -0.4 & -1.7 & -1.6 & -1.7 & -1.7 & -1.7 \\
\bottomrule\end{NiceTabular}
\
共有 10 列,第一行应该有两个空单元格,以及两个单元格,每个单元格横跨 4 列。第二行应该有 5 个单元格,每个单元格横跨两列。相反,这些列以某种方式相互重叠/合并,并且只占用前 6 列——最后一行每列包含一个元素,因此应该有助于横跨整个表格。
如果我&
在列之间添加额外的内容,我可以得到我想要的布局,但这不可能是正确的方法,不是吗?
\begin{NiceTabular}[]{c | c | *{4}S[table-format=3.2] | *{4}S[table-format=3.2]}
& & \Block{1-4}{Shock} & & & & \Block{1-4}{Parameter} \\
\toprule
\Block{1-2}{Qualitative Comparison}& & \Block{1-2}{A} & & \Block{1-2}{B} & & \Block{1-2}{C} & & \Block{1-2}{D} & \\
\toprule
\Block{1-2}{Direct effect } & & \Block{1-2}{$\nearrow$} & & \Block{1-2}{$\nearrow$} & & \Block{1-2}{-} & & \Block{1-2}{-} \\
$\%$\textbf{ foo} & \textbf{bar} & $\mu$=0.025 & $\mu$=0.05 \\ \toprule
a & b & -0.9 & -1.7 & -0.4 & -1.7 & -1.6 & -1.7 & -1.7 & -1.7 \\
\bottomrule\end{NiceTabular}
\\
答案1
该命令的语法\Block
与 的语法不同\multicolumn
。使用\Block
,您必须放置与符号 ( &
)。
\documentclass{article}
\usepackage{nicematrix,siunitx,booktabs}
\begin{document}
\begin{table}
\begin{NiceTabular}[]{c | c | *{4}S[table-format=3.2] | *{4}S[table-format=3.2]}
& & \Block{1-4}{Shock} & & & & \Block{1-4}{Parameter} \\
\toprule
\Block{1-2}{Qualitative\\ Comparison}& & \Block{1-2}{A} & & \Block{1-2}{B} & & \Block{1-2}{C} & & \Block{1-2}{D} & \\
\toprule
\Block{1-2}{Direct effect } & & \Block{1-2}{$\nearrow$} & & \Block{1-2}{$\nearrow$} & & \Block{1-2}{-} & & \Block{1-2}{-} \\
$\%$\textbf{ foo} & \textbf{bar} & $\mu$=0.025 & $\mu$=0.05 \\ \toprule
a & b & -0.9 & -1.7 & -0.4 & -1.7 & -1.6 & -1.7 & -1.7 & -1.7 \\
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}