3

I would like the text in cell vertically center but it stay at the bottom. The rowspec looks like not take effect. The m should be vertically center.

\documentclass{standalone}
\usepackage{tabularray}
\usepackage{tikz}
\usepackage{color}
\begin{document}
\tiny\begin{tblr}{
  vspan=even, hspan=minimal,
  vspan=even, hspan=minimal,
  hline{1-Z}={black},
  row{odd} = {gray!5}, 
  colspec={Q[c] Q[l] Q[c] Q[l]},
  rowspec={Q[m] Q[m]},
  rowsep=1pt,
  colsep=1pt,
  row{1}={cmd=\textbf},
}
  Offset & Name  & Size & Value \\
  0      & AAAA & 1 &
\tikz \node[align=left] {
  0x00 – BBBB\\
0x01 – CCCC\\
0x02 – DDDD\\
0x03 – EEEE\\
0x04 – FFFF};
  \\
\end{tblr}
\end{document}

Output: enter image description here

0

2 Answers 2

3

Q[c, m] to set the text alignment.

For the TikZ node adjustment, use baseline=(current bounding box.center) to align it based on its center.

enter image description here

\documentclass{standalone}
\usepackage{tabularray}
\UseTblrLibrary{booktabs} %added here for better lines.
\usepackage{tikz}
\usepackage{color}

\begin{document}
\tiny
\begin{tblr}{
  vspan=even, hspan=minimal,
  hlines, vlines,
  row{odd} = {bg=gray!5},
  colspec={Q[c, m] Q[l, m] Q[c, m] Q[l, m]},
  rowsep=1pt,
  colsep=1pt,
  row{1}={font=\bfseries},
}
  Offset & Name  & Size & Value \\
  0      & AAAA  & 1    &
  \tikz[baseline=(current bounding box.center)]{
    \node[align=left, anchor=center] {
      0x00 – BBBB\\
      0x01 – CCCC\\
      0x02 – DDDD\\
      0x03 – EEEE\\
      0x04 – FFFF
    };
  }\\
\end{tblr}
\end{document}
1
  • Awesome, I saw a new c added, what does the m mean?
    – beetlej
    Apr 17 at 14:33
4

Using a tikz node seems unnecessarily complicate. You could use a multiline cell instead:

\documentclass{standalone}
\usepackage{tabularray}
\usepackage{tikz}
\usepackage{color}
\begin{document}
\begin{tblr}{
  vspan=even, hspan=minimal,
  vspan=even, hspan=minimal,
  hline{1-Z}={black},
  row{odd} = {gray!5}, 
  colspec={Q[c] Q[l] Q[c] Q[l]},
  rowspec={Q[m] Q[m]},
  rowsep=1pt,
  colsep=1pt,
  row{1}={cmd=\textbf},
}
  Offset & Name  & Size & Value \\
  0      & AAAA & 1 &
 {0x00 – BBBB\\
  0x01 – CCCC\\
  0x02 – DDDD\\
  0x03 – EEEE\\
  0x04 – FFFF}\\
\end{tblr}
\end{document}

enter image description here

1
  • Awesome, never know this better way!
    – beetlej
    Apr 17 at 14:35

You must log in to answer this question.

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