多行单元格不在 tabularray 表中垂直居中

多行单元格不在 tabularray 表中垂直居中

我试图将多行单元格垂直居中,但目前还没有成功。下图中 A 没问题,但 B/C 似乎被推到了顶部,而不是放在框的中间。而且它们之间的间距比我希望的要大:

在此处输入图片描述

主表定义是:

    \begin{longtblr}[theme = fancy, entry=none,label=none]{
            colspec = {|l|l|Q[h,l]|},
            stretch = 0,
            columns = {colsep=1mm},
            column{1} = {leftsep=0pt},
            column{3} = {rightsep=0pt},
        }

和多单元:

        \inst{B} &
        \R{1},\DSXB{2} &
        \SetCell[r=2]{m} \Wrap{\RSFullFull{\add}} \\*
        
        \inst{C} &
        \R{1},\DLXB{2} & 
        -- \\ \hline

(添加水平线和垂直线只是为了更清楚地看到问题:将被删除)

完整 MWE:

\documentclass[8pt]{extarticle}  
\usepackage[papersize={105mm,297mm}, margin=5mm]{geometry}   
\pagenumbering{gobble} 

\usepackage[T1]{fontenc}
\usepackage{tgadventor}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[english]{babel}
\usepackage{ragged2e} 

\usepackage[x11names]{xcolor}
\usepackage{tikz} 
\usetikzlibrary{positioning, shapes.misc, shapes,arrows,chains, arrows.meta, calc, decorations.pathmorphing}


\usepackage{tabularray}

%%%%% tabularray settings

\NewTblrTheme{fancy}{
}

\DefTblrTemplate{contfoot}{default}{}
\DefTblrTemplate{conthead}{default}{}
\DefTblrTemplate{caption-tag}{default}{}
\DefTblrTemplate{caption-sep}{default}{}
\DefTblrTemplate{caption-text}{default}{}
\DefTblrTemplate{conthead-text}{default}{}
 

\tikzset{ 
    Register/.style={
        rectangle,
        minimum height = 1cm,
        minimum width = 8cm,    
    }, 
    point/.style={circle, inner sep=0pt, minimum size=2pt, fill=red},
    sizenode/.style = {font=\fontsize{22}{22}\selectfont\bfseries\sffamily, white},
    node distance = 5mm and 10mm, 
    >=Kite, 
    every node/.style={transform shape}, 
}
     

\newcommand\RSFullFull[2][]{
    \node (x) [Register] {};
    
    \fill [black!20] (x.south west) +(0,0) rectangle +(20,5); 
}
 

\def\add{\raisebox{-1.5em}{{\fontsize{20}{20}\selectfont{+}}}}  
\newcommand\lowersub[1]{\raisebox{-0.1ex}{\textsubscript{#1}}}
\newcommand\raisesup[1]{\raisebox{0.1ex}{\textsuperscript{#1}}}
\newcommand\subsup[2]{\rlap{\lowersub{#1}}\raisesup{#2}}   
\newcommand{\R}[1]{R\textsubscript{#1}}  
\newcommand{\RE}[1]{R\subsup{#1}{E}} 
\newcommand{\I}[1]{I\textsubscript{#1}} 
\newcommand{\D}[1]{D\textsubscript{#1}} 
\newcommand{\DS}[1]{D\subsup{#1}{12}}
\newcommand{\DL}[1]{D\subsup{#1}{20}}
\newcommand{\X}[1]{X\textsubscript{#1}} 
\newcommand{\B}[1]{B\textsubscript{#1}} 
\newcommand{\inst}[1]{\textbf{#1}} 
\newcommand{\DSB}[1]{\DS{#1}(\B{#1})}
\newcommand{\DLB}[1]{\DL{#1}(\B{#1})}
\newcommand{\DSXB}[1]{\DS{#1}(\X{#1},\B{#1})}
\newcommand{\DLXB}[1]{\DL{#1}(\X{#1},\B{#1})}
\newcommand{\DXB}[1]{\D{#1}(\X{#1},\B{#1})}

\newcommand\Wrap[1]{ 
    \scalebox{0.3}{
        \begin{tikzpicture}[ scale=1.0, baseline=(current bounding box.center)]  % .north
            #1
            \useasboundingbox 
                ([shift={(0mm,2mm)}]current bounding box.north east) 
                rectangle 
                ([shift={(0mm,-2mm)}]current bounding box.south west);
        \end{tikzpicture}
    }
}
 
\begin{document}
        \begin{longtblr}[theme = fancy, entry=none,label=none]{
                colspec = {|l|l|Q[h,l]|},
                stretch = 0,
                columns = {colsep=1mm},
                column{1} = {leftsep=0pt},
                column{3} = {rightsep=0pt},
            }
        
            \hline
        
            \inst{A} & 
            R\textsubscript{1},R\textsubscript{2} &
            \Wrap{\RSFullFull{\add}} \\ \hline 
            
            \inst{B} &
            \R{1},\DSXB{2} &
            \SetCell[r=2]{m} \Wrap{\RSFullFull{\add}} \\*
            
            \inst{C} &
            \R{1},\DLXB{2} & 
            -- \\ \hline
 
 
        \end{longtblr} 
 
 
\end{document}

对于@Zarko:

在此处输入图片描述

答案1

看看以下 MWE 是否能满足您的要求:

\documentclass[8pt]{extarticle}
\usepackage[papersize={105mm,297mm}, margin=5mm]{geometry}
\pagenumbering{gobble}

\usepackage[T1]{fontenc}
\usepackage{tgadventor}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[english]{babel}

\usepackage{ragged2e}
\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, 
                calc,chains, 
                decorations.pathmorphing,
                positioning, 
                shapes, shapes.misc}
\usepackage{tabularray}

%%%%% tabularray settings
\NewTblrTheme{fancy}{
}

\tikzset{
    Register/.style={
        rectangle,
        minimum height = 1cm,
        minimum width = 8cm,
    },
    point/.style={circle, inner sep=0pt, minimum size=2pt, fill=red},
    sizenode/.style = {font=\fontsize{22}{22}\selectfont\bfseries\sffamily, white},
    node distance = 5mm and 10mm,
    >=Kite,
    every node/.style={transform shape},
}

\newcommand\RSFullFull[2][]{
    \node (x) [Register] {};

    \fill [black!20] (x.south west) +(0,0) rectangle +(20,5);
}


\def\add{\raisebox{-1.5\baselineskip}{{\fontsize{20}{20}\selectfont{+}}}}
\newcommand\lowersub[1]{\raisebox{-0.1ex}{\textsubscript{#1}}}
\newcommand\raisesup[1]{\raisebox{0.1ex}{\textsuperscript{#1}}}
\newcommand\subsup[2]{\rlap{\lowersub{#1}}\raisesup{#2}}
\newcommand{\R}[1]{R\textsubscript{#1}}
\newcommand{\RE}[1]{R\subsup{#1}{E}}
\newcommand{\I}[1]{I\textsubscript{#1}}
\newcommand{\D}[1]{D\textsubscript{#1}}
\newcommand{\DS}[1]{D\subsup{#1}{12}}
\newcommand{\DL}[1]{D\subsup{#1}{20}}
\newcommand{\X}[1]{X\textsubscript{#1}}
\newcommand{\B}[1]{B\textsubscript{#1}}
\newcommand{\inst}[1]{\textbf{#1}}
\newcommand{\DSB}[1]{\DS{#1}(\B{#1})}
\newcommand{\DLB}[1]{\DL{#1}(\B{#1})}
\newcommand{\DSXB}[1]{\DS{#1}(\X{#1},\B{#1})}
\newcommand{\DLXB}[1]{\DL{#1}(\X{#1},\B{#1})}
\newcommand{\DXB}[1]{\D{#1}(\X{#1},\B{#1})}

\newcommand\Wrap[1]{
    \scalebox{0.3}{
        \begin{tikzpicture}[baseline={([yshift=-1.5ex] current bounding box.center)}]  % .north
            #1
            \useasboundingbox
                (current bounding box.north east)
                rectangle
                (current bounding box.south west);
        \end{tikzpicture}
    }
}

\begin{document}
    \begin{longtblr}[
theme = fancy, 
entry=none,
label=none]{vlines,
            colspec = {Q[font=\bfseries] % <---
                       l c},
            colsep=1mm,                  % <---
            vspan = even                 % <---
            }
    \hline
A   &   \R{1},\R{2} 
        &   \Wrap{\RSFullFull{\add}}    \\
    \hline
B   &   \R{1},\DSXB{2} 
        & \SetCell[r=2]{m} \Wrap{\RSFullFull{\add}} \\*
C   &   \R{1},\DLXB{2}
        &                               \\
    \hline
    \end{longtblr}
\end{document}

在此处输入图片描述

附录:
最后一列灰色框的用途不明确。它的定义(在我看来)太复杂了。您可以考虑以下解决方案:

\documentclass[8pt]{extarticle}
\usepackage[papersize={105mm,297mm}, margin=5mm]{geometry}
\pagenumbering{gobble}

\usepackage[T1]{fontenc}
\usepackage{tgadventor}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[english]{babel}

\usepackage{ragged2e}
\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, 
                calc,chains, 
                decorations.pathmorphing,
                positioning, 
                shapes, shapes.misc}
\newcommand\GrayBox[1]{\tikz[baseline] 
                        \node[minimum width=\linewidth, minimum height=8ex, fill=gray!30] {#1};
                    }
\usepackage{tabularray}
%%%%% tabularray settings
\NewTblrTheme{fancy}{}

\newcommand\lowersub[1]{\raisebox{-0.1ex}{\textsubscript{#1}}}
\newcommand\raisesup[1]{\raisebox{0.1ex}{\textsuperscript{#1}}}
\newcommand\subsup[2]{\rlap{\lowersub{#1}}\raisesup{#2}}
\newcommand{\R}[1]{R\textsubscript{#1}}
\newcommand{\RE}[1]{R\subsup{#1}{E}}
\newcommand{\I}[1]{I\textsubscript{#1}}
\newcommand{\D}[1]{D\textsubscript{#1}}
\newcommand{\DS}[1]{D\subsup{#1}{12}}
\newcommand{\DL}[1]{D\subsup{#1}{20}}
\newcommand{\X}[1]{X\textsubscript{#1}}
\newcommand{\B}[1]{B\textsubscript{#1}}
\newcommand{\inst}[1]{\textbf{#1}}
\newcommand{\DSB}[1]{\DS{#1}(\B{#1})}
\newcommand{\DLB}[1]{\DL{#1}(\B{#1})}
\newcommand{\DSXB}[1]{\DS{#1}(\X{#1},\B{#1})}
\newcommand{\DLXB}[1]{\DL{#1}(\X{#1},\B{#1})}
\newcommand{\DXB}[1]{\D{#1}(\X{#1},\B{#1})}


\begin{document}
    \begin{longtblr}[
%theme = fancy, 
entry=none,
label=none]{colspec = {@{} Q[m, font=\bfseries] % <---
                       l 
                       X[c] @{}},               % <---
            colsep=1mm,                     % <---
            vspan = even                    % <---
            }
A   &   \R{1},\R{2} 
        &   \GrayBox                   \\
B   &   \R{1},\DSXB{2} 
        & \SetCell[r=2]{c}     \GrayBox{}   \\*
C   &   \R{1},\DLXB{2}
        &                               \\
    \end{longtblr}
\end{document}

在此处输入图片描述

相关内容