lvjr / tabularray

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

\SetCell breaks the line breaking #499

Open suuuehgi opened 4 months ago

suuuehgi commented 4 months ago

Without further knowledge, I assume that \SetCell adheres to the width = 0.85\linewidth, but this is not the case.

\documentclass{scrartcl}
\usepackage{tabularray, blindtext}

\begin{document}
\begin{longtblr}{
    width = 0.85\linewidth,
    colspec = {|rX|}
    }
 \hline
 test & \blindtext \\
 % \SetCell[c=2]{l} \blindtext\\ % <-- uncomment this line to break the text alignment
 \hline
\end{longtblr}
\end{document}

Screenshot from 2024-05-31 00-15-47 Screenshot from 2024-05-31 00-16-04

Current git version.

sgolovan commented 4 months ago

In your \SetCell argument you specify the cell spec l which means that it is formatted as a one-line cell. One way to mitigate this is to add hspan=minimal to the table options. It would mean that cell width is calculated using small one-column cells, and the span cells just use this calculated width. Also, you may want to replace l by j to make the span cell justified.

The code:

\documentclass{scrartcl}
\usepackage{tabularray, blindtext}

\begin{document}
\begin{longtblr}{
    width = 0.85\linewidth,
    colspec = {|rX|},
    hspan = minimal
    }
 \hline
 test & \blindtext \\
 \SetCell[c=2]{j} \blindtext\\
 \hline
\end{longtblr}
\end{document}
suuuehgi commented 4 months ago

Thank you very much! But shouldn't one-line cells stick to the outside width of the table?

sgolovan commented 3 months ago

If you use l instead of X in the colspec argument, the whole paragraph turns into one line ignoring the width specification. Something similar happens with \SetCell and the default hspan value.