tabularray 中的单元格对齐和水平分布问题

tabularray 中的单元格对齐和水平分布问题

我一直在尝试设置一个包含特定内容的表格纵横分布行和列合并tabularray 包。以下是我的 MWE,强调了我在第一个细胞 cell{1}{1} = {r=2,c=1}{c}第三排 row{3}

在下面显示的示例中,可以注意到名为 D ( cell{1}{8} = {r=2,c=1}{c}) 和 F ( cell{1}{9} = {r=2,c=1}{c}) 的单元格遵循基于相同代码行 ( ) 的中心对齐定义cell{1}{1,8,9} = {r=2,c=1}{c}

在此处输入图片描述

我已经尝试了多个colspec给定mc对齐参数以及hspace=even\SetTblrInner{vspan=even, hspan=even},但没有一个能够使cell{1}{1}中心对齐并且cell{3}{1}相对于其他行均匀。

梅威瑟:

\usepackage{nth}
\usepackage{booktabs}
\usepackage{tabularx,booktabs}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{varwidth}


\begin{document}
\begin{tblr}{
    measure=vbox,
    %rows = {valign=c},
    row{1} = {bg=white, fg=black, font=\bfseries},
    cell{1}{1,8,9} = {r=2,c=1}{c}, %Defines the cell position row 1 colunm 1,8,9 as a 2 rows and 1 colunm cell with 'c' center aligment
    cell{1}{2,5} = {r=1,c=3}{c},
    %cell{1}{5} = {r=1,c=3}{c},
    %cell{1}{8} = {r=2,c=1}{c},
    %cell{1}{9} = {r=2,c=1}{c},
    hspan=even, vspan=even,
    width=1\columnwidth,
    %colspec={X[3cm,c,m] X[c,m] X[c,m] X[c,m] X[c,m] X[c,m] X[c,m] X[3cm,c,m] X[3cm,c,m]},
    colspec={Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m]},
    %colspec={Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]},
    %rowspec={Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]},
    hline{4-Y} = {1,8,9}{0.5pt, rightpos = -1, leftpos = -1},
    vline{2,5,8,9} = {1pt,solid},
    hline{1,Z} = {2pt},
    hline{3} = {1,8,9}{1.5pt, rightpos = -1, leftpos = -1},
    hline{3} = {2,3,4}{1.5pt, rightpos = -1, leftpos = -1, endpos},
    hline{3} = {5,6,7}{1.5pt, rightpos = -1, leftpos = -1, endpos},
    hline{4-Y} = {2,3,4}{0.5pt, rightpos = -1, leftpos = -1, endpos},
    hline{4-Y} = {5,6,7}{0.5pt, rightpos = -1, leftpos = -1, endpos},
    vline{3,4,6,7} = {0.5pt}   
} 



A & B &   &   & C &   &   & D & F \\

    & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ &  &  \\



            \nth{1} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8     
            \\

            \nth{2} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8
            \\
            

            \nth{3} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8
            \\

            \nth{4} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8
            \\

            \nth{5} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8
            \\

            \nth{6} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8
            \\

            \nth{7} & 
            1 & 
            2 & 
            3 &
            4 &
            5 &
            6 & 
            7 &
            8
            \\
           

\end{tblr}
\end{table*} %Summary of the different topological stage
\end{document}

提前感谢你们的支持!

答案1

如果我运行你的代码(我删除了多余的包),就不会遇到这个问题:

\documentclass{article}
\usepackage{nth}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{varwidth}


\begin{document}
\begin{table}[tbh]
  \begin{tblr}{
      width=1\columnwidth,
      measure=vbox,
      colspec={Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m] Q[c,m]},
      %rows = {valign=c},
      row{1} = {bg=white, fg=black, font=\bfseries},
      cell{1}{1,8,9} = {r=2,c=1}{c},
      cell{1}{2,5} = {r=1,c=3}{c},
      %cell{1}{5} = {r=1,c=3}{c},
      %cell{1}{8} = {r=2,c=1}{c},
      %cell{1}{9} = {r=2,c=1}{c},
      hspan=even, vspan=even,
      %colspec={X[3cm,c,m] X[c,m] X[c,m] X[c,m] X[c,m] X[c,m] X[c,m] X[3cm,c,m] X[3cm,c,m]},
      %colspec={Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]},
      %rowspec={Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]Q[c]},
      hline{4-Y} = {1,8,9}{0.5pt, rightpos = -1, leftpos = -1},
      vline{2,5,8,9} = {1pt,solid},
      hline{1,Z} = {2pt},
      hline{3} = {1,8,9}{1.5pt, rightpos = -1, leftpos = -1},
      hline{3} = {2,3,4}{1.5pt, rightpos = -1, leftpos = -1, endpos},
      hline{3} = {5,6,7}{1.5pt, rightpos = -1, leftpos = -1, endpos},
      hline{4-Y} = {2,3,4}{0.5pt, rightpos = -1, leftpos = -1, endpos},
      hline{4-Y} = {5,6,7}{0.5pt, rightpos = -1, leftpos = -1, endpos},
      vline{3,4,6,7} = {0.5pt}
    }
    A       & B   &     &     & C   &     &     & D & F \\
            & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ &   & \\
    \nth{1} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
    \nth{2} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
    \nth{3} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
    \nth{4} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
    \nth{5} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
    \nth{6} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
    \nth{7} & 1   & 2   & 3   & 4   & 5   & 6   & 7 & 8 \\
  \end{tblr}
\end{table} %Summary of the different topological stage
\end{document}

在此处输入图片描述

另外,不确定中间对齐是否有意,但如果您希望标题在一行中,请按照以下代码片段进行更改

% ... valgin added
row{1} = {valign=h, bg=white, fg=black, font=\bfseries},
cell{1}{1,8,9} = {r=2,c=1}{},   % c removed
% ...

在此处输入图片描述

相关内容