add tag
Anonymous 13189
Hi,

I use the tabularray package and need alternating colors every two rows instead of every row. I'd like to do this with a pattern instead of assigning the rowcolors manually.

Any help would be appreciated.
Top Answer
samcarter
Quick hack:

```
\documentclass{article}

\usepackage{xcolor}
\usepackage{tabularray}

\ExplSyntaxOn
\NewChildSelector { double } [1] []
  {
    \tl_if_blank:nTF {#1}
      {
        \int_step_inline:nnnn {4} {4} { \l_tblr_childs_total_tl }
          { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
        \int_step_inline:nnnn {3} {4} { \l_tblr_childs_total_tl }
          { \clist_put_right:Nn \l_tblr_childs_clist {##1} }          
      }
      { \__tblr_child_selector_odd_or_even:nn { even } {#1} }
  } 
\ExplSyntaxOff

\begin{document}

\begin{tblr}{
  rows={blue},
  row{double} = {red}
}
a\\
b\\
c\\
d\\
e\\
f\\
g\\
h\\
a\\
b\\
c\\
d\\
e\\
f\\
g\\
h\\
\end{tblr}

\end{document}
```

![Screenshot 2024-06-28 at 09.49.07.png](/image?hash=e584ce8a5dad1d2f68693eba8d38dea95b17a6752a12158fe2581779d5b4a977)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.