Tabularray: Selectively print some rows from a table stored in a macro

tablestabularray

How can I print some rows out of the table stored in \MyTable?

For example, I need to print two groups of rows = 1 to 3 and rows = 6 to 8 in two ways:

  1. print all the six rows as a whole without visual separation
  2. print a separating row between the two groups spanning the two columns with some centered titled (e.g. second part)
begin{filecontents*}{mytable.tex}
1  &  11  \\
2  &  12  \\
3  &  13  \\
4  &  14  \\
5  &  15  \\
6  &  16  \\
7  &  17  \\
8  &  18  \\
\end{filecontents*}

\documentclass{article}

\usepackage{xcolor, catchfile}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,siunitx}

\begin{document}

\CatchFileDef{\MyTable}{mytable.tex}{}

\begin{tblr}[ long, expand = \MyTable ]{ 
        row{odd} = {gray!10},
        row{even} = {white},
        row{1} = {white},
        colspec = {X S} 
    }
    \toprule[1.5pt]
    One & {{{Two}}}  \\
    \midrule
    \MyTable
    \bottomrule[1.5pt]
\end{tblr}

\end{document}

Best Answer

The following is a partial solution: it is not good enough, but at least it works.

\begin{filecontents*}{mytable.tex}
1  &  11  \\
2  &  12  \\
3  &  13  \\
4  &  14  \\
5  &  15  \\
6  &  16  \\
7  &  17  \\
8  &  18  \\
\end{filecontents*}

\documentclass{article}

\usepackage{xcolor, catchfile}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,siunitx}

\begin{document}

\CatchFileDef{\MyTable}{mytable.tex}{}

\newcommand\HideIt[1]{}

\begin{tblr}[ long, expand = \MyTable ]{ 
        row{odd} = {gray!10},
        row{even} = {white},
        row{1} = {white},
        colspec = {X S},
        stretch = 0,
        rowsep = 4pt,
        row{5-6} = {cmd=\HideIt,rowsep=0pt},
    }
    \toprule[1.5pt]
    One & {{{Two}}}  \\
    \midrule
    \MyTable
    \bottomrule[1.5pt]
\end{tblr}

\end{document}

enter image description here