1

I am attempting to vertically centre a multiline cell, so far without success. In the following diagram A is fine, but B/C seem to be pushed to the top, rather than placed around the middle of the box. Also the spacing between them is larger than I would prefer:

enter image description here

The main table definition is:

    \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},
        }

and the multicell:

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

(Horizontal and vertical lines added just to see the issue more clearly: will be removed)

Full 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}

For @Zarko:

enter image description here

1 Answer 1

0

See if the following MWE gives what you after:

\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}

enter image description here

Addendum:
Purpose of gray box in the last column is not clear. Its definition is (to my opinion) to complicated. You may consider the following solution:

\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}

enter image description here

13
  • That looks much better, many thanks. But I don't follow the whys and wherefores of the changes, I'm afraid. Might you be able to explain them to me?
    – Ian
    Commented Nov 28, 2022 at 15:06
  • @Ian, see addendum. It may be more clear. In both examples important changes are in longtblr preamble marked by % <---.
    – Zarko
    Commented Nov 28, 2022 at 15:13
  • the graybox is simply a place holder for a tree of tikz instructions. For the purposes of a MWE, I should have replaced it: my bad. What does the FONT in the COLSPEC do? Is that the solution here, or the VSPAN, or are both needed? Is the change to the colseps relevant to the fix?
    – Ian
    Commented Nov 28, 2022 at 15:21
  • Is there any way to reduce the separation of B and C? Or should I just use a raisebox?
    – Ian
    Commented Nov 28, 2022 at 15:23
  • @Ian, for most of your question you can find in tabularray package better answer that I can copy/rewrite them from there. Documentation is concise and well illustrated. From colspec is obvious tha font define font in columns (\bfseries in the first column), vspan determine rows span at multi row cells. In your case define equal height of spanned rows. Why you like to reduce colsep? result is very ugly! Of course it is possible, but I will not encourage you to do this.
    – Zarko
    Commented Nov 28, 2022 at 15:30

Not the answer you're looking for? Browse other questions tagged .