3

I recently played with tabularray package. It's an awesome, very powerful, easily customizable table and matrix builder. But I'm intrigued about how this package handle stretch. As the minimum example, here are two exactly same tables, but one is put as float, the other as longtblr (imagine this table can get very long:

\documentclass{article}
\usepackage{tabularray}
\usepackage{setspace}
\setstretch{1.5}

\begin{document}

\begin{table}[htbp]
    \centering
    \begin{talltblr}[
        caption = {Sample Data with Footnotes},
        label = {tab:sample},
        note{a} = {Measured at standard conditions},
        note{b} = {Adjusted for humidity},
        note{c} = {Gauge pressure readings},
    ]{
        colspec = {lcc},
        stretch = 1.0,
        hline{1} = {1.2pt},
        hline{2} = {0.8pt}, 
        hline{Z} = {1.2pt},
        row{1} = {font=\bfseries, abovesep = 4pt, belowsep = 2pt},
        row{2} = {abovesep = 4pt},
        row{Z} = {belowsep = 2pt},
    }
        Parameter & Value A\TblrNote{a} & Value B\TblrNote{b} \\
        Temperature & 25°C & 30°C \\
        Pressure\TblrNote{c} & 1.2 atm & 1.5 atm \\
        Flow Rate & 15 L/min & 20 L/min \\
    \end{talltblr}
\end{table}

\begin{longtblr}[
    caption = {Sample Data with Footnotes},
    label = {tab:sample2},
    note{a} = {Measured at standard conditions},
    note{b} = {Adjusted for humidity},
    note{c} = {Gauge pressure readings},
]{
    colspec = {lcc},
    stretch = 1.0,
    hline{1} = {1.2pt},
    hline{2} = {0.8pt}, 
    hline{Z} = {1.2pt},
    row{1} = {font=\bfseries, abovesep = 4pt, belowsep = 2pt},
    row{2} = {abovesep = 4pt},
    row{Z} = {belowsep = 2pt},
}
    Parameter & Value A\TblrNote{a} & Value B\TblrNote{b} \\
    Temperature & 25°C & 30°C \\
    Pressure\TblrNote{c} & 1.2 atm & 1.5 atm \\
    Flow Rate & 15 L/min & 20 L/min \\
\end{longtblr}

\end{document}

Which outputs to this (using LuaLaTeX 2024, on overleaf public): The output of two identical tables by tabularray

Even with exactly the same stretch of 1.0, the former respect the value, but the latter instead use the globally defined \setstretch{1.5}. To remedy it, I should wrap the second table inside a curly bracket, and insert \setstretch{1.0} for the scope of that table only.

Is this an intended behavior, or will this be repaired in the future?

Many thanks for your attention!

4
  • 1
    That's unrelated to tabularray, try \documentclass{article} \usepackage{tabularray} \usepackage{setspace} \setstretch{1.5} \usepackage{lipsum} \begin{document} \begin{table}[htbp] \centering \lipsum[2] \end{table} \lipsum[2] \end{document} Commented Jul 4 at 10:21
  • Thanks for the suggestion. Does this mean the inner option stretch = 1.0 doesn't change the stretch of the text? Commented Jul 4 at 10:27
  • 1
    I think the tabularray stretch works independent of the setspace stretch. They are just two different things. Commented Jul 4 at 10:31
  • See also \arraystretch (no package). Commented Jul 4 at 13:20

1 Answer 1

4

setspace turns increased spacing off inside floats e.g. table and figure.

From setspace.sty:

%---Reset baselinestretch within floats and footnotes.

% GT:  Tue 23 Jan 1996:  This is where the conflict with the combination
% of the color package and the figure environment used to occur.

% Floats.

% GT:  Sat 28 Sep 1996:  \@xfloat is the only place where \normalsize
% is still used in setspace.sty !

\let\latex@xfloat=\@xfloat
\def\@xfloat #1[#2]{%
  \latex@xfloat #1[#2]%
  \def\baselinestretch{\setspace@singlespace}%
  \normalsize
}

This is stated in the 'Old documentation' in the package file, but seems to have been lost in the 'new',

%%         2. Double spacing is turned off within footnotes and floats (figures
%%            and tables).
2
  • 1
    So it's not that the tabularray behavior that change, but rather how setspace is working... This mean, tabularray stretch has nothing to do with setspace's stretch, and instead it just kinda like multiply two numbers together? Commented Jul 4 at 11:42
  • 1
    @ChristopherJaya as far as I can tell, tabularray just measures the current height of \strutbox and takes that as the base dimension. if that dimension differs at the start of different tblr environments, the resulting stretch will differ even for the same stretch=<value>. so they are related in the sense that setspace's stretch affects the height of \strutbox, which affects the effect of setting stretch=<value>. Commented Jul 4 at 12:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.