tables – How to Enumerate Vertically Table Cells Using tabularray?

numberingtablestabularrayvertically

Please consider the following MWE which produces a table with enumerated cells as you can see in image-1. I would like to enumerate the cells but in a vertical manner as you can see in image-2. How can I do that (using just one table)?

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{counter}

\newcounter{mycnta}
\newcommand{\mycnta}{\stepcounter{mycnta}\arabic{mycnta}}

\begin{document}
    
    \begin{tblr}{hlines}
        \mycnta & \mycnta & \mycnta \\
        \mycnta & \mycnta & \mycnta \\
        \mycnta & \mycnta & \mycnta \\
    \end{tblr}
\end{document}

image-1

I would like the numbering to be like that:

image-2

Best Answer

A clumsy but quite simple solution:


\documentclass[margin=3mm]{standalone}
\usepackage{tabularray}

\begin{document}

\begin{tblr}{hlines}
\arabic{rownum} 
    &   \the\numexpr3+\arabic{rownum}
        &   \the\numexpr6+\arabic{rownum}       \\
\arabic{rownum}
    &   \the\numexpr3+\arabic{rownum} 
        &   \the\numexpr6+\arabic{rownum}       \\
\arabic{rownum}
    &   \the\numexpr3+\arabic{rownum}
        &   \the\numexpr6+\arabic{rownum}       \\
\end{tblr}
\end{document}

enter image description here

Edit (1): or shortly

\documentclass[margin=3mm]{standalone}
\usepackage{tabularray}

\begin{document}

[![enter image description here][2]][2]
\begin{tblr}{hlines,
            colspec = {Q[cmd=\arabic{rownum}] 
                       Q[cmd=\the\numexpr3+\arabic{rownum}]
                       Q[cmd=\the\numexpr6+\arabic{rownum}] }
            }
    &   &       \\
    &   &       \\
    &   &       \\
\end{tblr}
\end{document}

Edit (2): or without manual settings of the last row number:

\documentclass[margin=3mm]{standalone}
\usepackage{xcolor}
\usepackage{tabularray}
\newcounter{A}

\begin{document}

\begin{tblr}{colspec = {Q[cmd=\arabic{rownum}] 
                       Q[cmd=\the\numexpr\value{A}+\arabic{rownum}]
                       Q[cmd=\the\numexpr2*\value{A}+\arabic{rownum}] },
             cell{Z}{1} = {cmd={\arabic{rownum}\setcounter{A}{\arabic{rownum}}}},
             row{1}  = {bg=gray8}
            }
    &   &       \\
    &   &       \\
    &   &       \\
    &   &       \\
    &   &       \\
\end{tblr}
\end{document}

enter image description here