如何使行内容垂直居中对齐?

如何使行内容垂直居中对齐?

以下是我的代码的MWE。

\documentclass{article}
\usepackage{tabularray}

\begin{document}
\begin{longtblr}[
    caption = {ABC},
    label = {tab:test},
]{
    width = \textwidth,
    colspec= {X[0.75,c] X[0.5,c] X[c] X[c] X[c] X[c] X[c]},
    rowhead = 2,
    hline{2-Z}={solid},
    column{2}={mode=math},
    columns={font=\small},
    row{1-2} = {font=\bfseries}
}
\SetCell[r=2]{c}{ID} &  & \SetCell[c=5]{c}{Concept ID} \\ 
& & 1 & 2 & 3 & 4 & 5 \\
% similar block of cells
\SetCell[r=5]{m}{IIIA} & A & {B} & {C} & {D} & {E} & {F} \\  
& G & {H} & {I} & {J} & {K} & {L} \\ 
& M & {N} & {O} & {P} & {Q} & {R} \\  
& S & {T} & {U} & {V} & {W} & {X} \\  
& Y & {Z} & {AA} & {AB} & {AC} & {AD} \\ 
\SetCell[r=5]{m}{IIIB} & AE & {AF} & {AG} & {AH} & {AI} & {AJ}\\ 
& AK & {AL} & {AM} & {AN} & {AO} & {AP} \\ 
& AQ & {AR} & {AS} & {AT} & {AU} & {AV} \\  
& AW & {AX\\A} & {AY\\B} & {AZ\\C} & {BA\\D} & {BB\\E} \\
& BC & {AX\\A} & {AY\\B} & {AZ\\C} & {BA\\D} & {BB\\E} \\ 
% similar block of cells
\end{longtblr}
\end{document}

在此处输入图片描述

如何垂直居中对齐最后两行(第 2 列)?

答案1

改成colspec

    colspec= {X[0.75,c] X[0.5,c] X[c,m] X[c,m] X[c,m] X[c,m] X[c,m]},

或者

    colspec= {X[0.75,c] X[0.5,c] *{5}{X[c,m]} },

在此处输入图片描述

编辑:
不过,我会按照以下方式编写您的表格:

\documentclass{article}
\usepackage{tabularray}

\begin{document}
\begin{longtblr}[
    caption = {ABC},
    label = {tab:test},
]{
    hline{1,2,Z}={solid}, % changed
    colspec= {X[0.75,c] X[0.5,c, mode=math] X[c,m] X[c,m] X[c,m] X[c,m]  X[c,m]}, % changed
    rowhead = 2,
    columns={font=\small},
    row{1-2} = {font=\bfseries}
}
\SetCell[r=2]{c}{ID} &  & \SetCell[c=5]{c}{Concept ID} \\
& & 1 & 2 & 3 & 4 & 5 \\
% similar block of cells
    \hline
\SetCell[r=5]{m}    IIIA
& A & B & C  & D  & E  & F \\
& G & H & I  & J  & K  & L \\
& M & N & O  & P  & Q  & R \\
& S & T & U  & V  & W  & X \\
& Y & Z & AA & AB & AC & AD \\
    \hline
\SetCell[r=5]{m}    IIIB
& AE & AF & AG & AH & AI & AJ\\
& AK & AL & AM & AN & AO & AP \\
& AQ & AR & AS & AT & AU & AV \\
& AW & {AX\\A} & {AY\\B} & {AZ\\C} & {BA\\D} & {BB\\E} \\
& BC & {AX\\A} & {AY\\B} & {AZ\\C} & {BA\\D} & {BB\\E} \\
\end{longtblr}

\end{document}

在此处输入图片描述

相关内容