lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
247 stars 22 forks source link

Unexpected vertical align change for some cells #438

Open BenjaminGalliot opened 9 months ago

BenjaminGalliot commented 9 months ago

Here is the MWE:

\documentclass{book}

\usepackage{tabularray}
\usepackage{xcolor}

\begin{document}

\begin{longtblr}{
  colspec = {X[c,m]X[c,m]X[c,m]},
  cell{2-3}{2-3} = {m,blue!50!white} % change here (m to b/t)
}
  \hline
  head 1 & head 2 & head 3 \\
  \hline
  {a \\ b} & {c \\ d} & e \\
  \hline
  a & {b \\ c \\ d} & e \\
  \hline
  a & {b \\ c \\ d} & {e \\ \phantom{ } \\ \phantom{ }} \\
  \hline
\end{longtblr}

% Same but without content in first column.
\begin{longtblr}{
  colspec = {X[c,m]X[c,m]X[c,m]},
  cell{2-3}{2-3} = {m,blue!50!white} % change here (m to b/t)
}
  \hline
  head 1 & head 2 & head 3 \\
  \hline
  & {c \\ d} & e \\
  \hline
  & {b \\ c \\ d} & e \\
  \hline
  & {b \\ c \\ d} & {e \\ \phantom{ } \\ \phantom{ }} \\
  \hline
\end{longtblr}

\end{document}

I don't know if I am misusing the functionality, but I would simply like to change the vertical alignment (among other things) for a range of cells, yet other cells seem to interfere:

By the way, I'm using \phantom{ } to align certain contents between cells, is it on purpose that \\ alone isn't enough?

Thanks for your help!

muzimuzhi commented 9 months ago

It's expected behavior, see #434 for explanation and an attempt adding valign=M.

muzimuzhi commented 9 months ago

By the way, I'm using \phantom{ } to align certain contents between cells, is it on purpose that \\ alone isn't enough?

Sort of yes. Anything that can start an hmode suffices, for example \leavevmode. This article on Overleaf gives some discussion about the error "There's no line here to end".

For now I don't know if automatically adding \mode_leave_vertical: at the beginning of every line of a cell is a good idea or not.

BenjaminGalliot commented 9 months ago

It's expected behavior, see #434 for explanation and an attempt adding valign=M.

Thanks, I added your specific code in my preamble (until it is pushed on a new version) and it works!