平均能量损失

平均能量损失

考虑下表

\begin{tabular}{cccccc}
    \toprule
    N   &       \multicolumn3c{L-family}    &   \multicolumn2c{H-family}    \\
    n   &   large   &   Large   &   LARGE   &       huge    &   Huge        \\
    \bottomrule
\end{tabular}

我想强调列的分组,因此使用@构造

\def\htc#1{ {\hskip#1\tabcolsep} }
\begin{tabular}{c  @\htc4  ccc  @\htc4  cc}
    \toprule
    N   &       \multicolumn3c{L-family}    &   \multicolumn2c{H-family}    \\
    n   &   large   &   Large   &   LARGE   &       huge    &   Huge        \\
    \bottomrule
\end{tabular}

现在我必须微调多列,因为水平空间已经关闭

\begin{tabular}{c  @\htc4  ccc  @\htc4  cc}
\toprule
N   &   \multicolumn3{@\htc{-3}c}{L-family} &   \multicolumn2{@\htc0c}{H-family}
\\
n   &   large   &   Large   &   LARGE       &       huge        &       Huge    
\\
\bottomrule
\end{tabular}

为什么会有这些脏常量?可以采用更自动化的方式吗?

平均能量损失

\documentclass{article}
\usepackage{booktabs}
\begin{document}

\parskip1em

Consider the following table

\begin{tabular}{cccccc}
    \toprule
    N   &       \multicolumn3c{L-family}    &   \multicolumn2c{H-family}    \\
    n   &   large   &   Large   &   LARGE   &       huge    &   Huge        \\
    \bottomrule
\end{tabular}

~

I want to emphasis the grouping of columns, hence the @-construction

\def\htc#1{ {\hskip#1\tabcolsep} }
\begin{tabular}{c  @\htc4  ccc  @\htc4  cc}
    \toprule
    N   &       \multicolumn3c{L-family}    &   \multicolumn2c{H-family}    \\
    n   &   large   &   Large   &   LARGE   &       huge    &   Huge        \\
    \bottomrule
\end{tabular}

~

Now I have to fine-tune the multicolumn

\begin{tabular}{c  @\htc4  ccc  @\htc4  cc}
\toprule
N   &   \multicolumn3{@\htc{-3}c}{L-family} &   \multicolumn2{@\htc0c}{H-family}
\\
n   &   large   &   Large   &   LARGE       &       huge        &       Huge    
\\
\bottomrule
\end{tabular}

Why the dirty constantss?

\end{document}

PS 在这个问题中: 使用多列和 @{\hskip} 时对齐问题?答案建议\tabcolsep使用空的来抑制@{}。可以看出,这并不总能给你想要的结果。

答案1

表达式@是相关列右侧边缘的一部分,因此在使用时\multicolumn重复跨度的完整组件(包括其右侧@表达式):

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\def\htc#1{ {\hskip#1\tabcolsep} }
\begin{document}

\parskip1em


I want to emphasis the grouping of columns, hence the @-construction


\begin{tabular}{c  @{\htc4}  ccc  @{\htc4}  cc}
    \toprule
    N   &       \multicolumn{3}{c@{\htc4}}{L-family}    &   \multicolumn{2}{c}{H-family}    \\
    n   &   large   &   Large   &   LARGE   &       huge    &   Huge        \\
    \bottomrule
\end{tabular}


\end{document}

答案2

使用{NiceTabular}ofnicematrix及其内置命令\Block,您可以直接获得预期的输出。

\documentclass{article}
\usepackage{nicematrix}
\usepackage{booktabs}

\begin{document}

\NewDocumentCommand{\htc}{m}{\hspace{#1\tabcolsep}}

\begin{NiceTabular}{c@{\htc{4}}ccc@{\htc{4}}cc}
\toprule
N & \Block{1-3}{L-family}       &&& \Block{1-2}{H-family} \\
n & large &   Large   & LARGE     &  huge    &   Huge     \\
\bottomrule
\end{NiceTabular}

\end{document}

您需要多次编译(因为nicematrix在后台使用 PGF/Tikz 节点)。

上述代码的输出

相关内容