The bad numbering is due to the fact that counters in tblrs don't work properly without loading the tblr library counter (tabularray manual, §5.3). For me this also fixed the overall table widths and the extra height in the first row of the first table.
\UseTblrLibrary{counter}
The inconsistent width is because you've based the N column type off of c, which doesn't support width coefficients like X does. Disregarding the other issues for the moment, you could fix this by changing your column definition to:
\NewColumnType{N}[1][]{>{\refstepcounter{rowcntr}\therowcntr}X[#1]}
Here I've replaced c with X[#1]. #1 gets filled in with the optional argument to N. Without it, you effectively get X[1] no matter what argument you give to N.
The remaining, more difficult issue is the fact that your header and footer are numbered (and still wrongly at this point). I think what's going on here is a confusion between the older style column types from array and the new syntax introduced by tabularray. When you do row{1,Z} = {c,...}, c is not a column type that will replace the column type you've already assigned with colspec above; it's a value for key halign (see tabularray manual §2.4--5). Furthermore, even adding preto={}, the tabularray equivalent of >{} to this option set won't work, because you're modifying the definition of the row and not the column.
My recommendation would be to drop the NewColumnType and instead specify the numbering as a property of only the cell range you want numbered. Your table specification would then look like this:
colspec = {X[3]|X[5]},
width = \linewidth,
rowhead = 1,
rowfoot = 1,
row{even} = {azure9},
row{1,Z} = {c,font=\sffamily\bfseries,bg=azure5,fg=white},
cell{2-Y}{1} = {preto={\refstepcounter{rowcntr}\therowcntr}},
If you want to avoid having to copy the same definition for multiple tables, you can use \NewTblrEnviron to make a new table type:
\NewTblrEnviron{mytblr}
\SetTblrOuter[mytblr]{long}
\SetTblrInner[mytblr]{
colspec = {X[3]|X[5]},
width = \linewidth,
rowhead = 1,
rowfoot = 1,
row{even} = {azure9},
row{1,Z} = {c,font=\sffamily\bfseries,bg=azure5,fg=white},
cell{2-Y}{1} = {preto={\refstepcounter{rowcntr}\therowcntr}},
}
Lastly, you don't need \AtBeginEnvironment{tblr}{\setcounter{rowcntr}{0}} because [table] in \newcounter{rowcntr}[table] already does that. You also don't need array or makecell because you're using tabularray.
Without further ado, here's my version of your MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage{float} ¬ relevant for longtblr
\usepackage{nameref}
%\usepackage{setspace} %not used here
\usepackage{tabularray}
\UseTblrLibrary{counter}
%\usepackage[absolute,overlay]{textpos} %not used here
\usepackage{xcolor}
\newcounter{rowcntr}[table]
\renewcommand{\therowcntr}{\thetable.\arabic{rowcntr}}
\NewTblrEnviron{mytblr}
\SetTblrOuter[mytblr]{long}
\SetTblrInner[mytblr]{
colspec = {X[3]|X[5]},
width = \linewidth,
rowhead = 1,
rowfoot = 1,
row{even} = {azure9},
row{1,Z} = {c,font=\sffamily\bfseries,bg=azure5,fg=white},
cell{2-Y}{1} = {preto={\refstepcounter{rowcntr}\therowcntr}},
}
\begin{document}
\begin{mytblr}[
caption = {Long Table 1},
label = {tblr:long-table-1},
]{}
Col 1 & Col 2 \
\label{row:long-table-1-a} & Ipsum \
\label{row:long-table-1-b} & Ipsum \
Col 1 & Col 2 \
\end{mytblr}
\begin{mytblr}[
caption = {Long Table 2},
label = {tblr:long-table-2},
]{}
Col 1 & Col 2 \
\label{row:long-table-2-a} & Ipsum \
\label{row:long-table-2-b} & Ipsum \
Col 1 & Col 2 \
\end{mytblr}
\end{document}
EDIT in response to your comment:
It's odd that the row numbering wouldn't work without defining a new tabularray environment. This code works as intended for me:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{nameref}
\usepackage{tabularray}
\UseTblrLibrary{counter}
\usepackage{xcolor}
\newcounter{rowcntr}[table]
\renewcommand{\therowcntr}{\thetable.\arabic{rowcntr}}
\begin{document}
\begin{longtblr}[
caption = {Long Table 1},
label = {tblr:long-table-1},
]{
colspec = {X[3]|X[5]},
width = \linewidth,
rowhead = 1,
rowfoot = 1,
row{even} = {azure9},
row{1,Z} = {c,font=\sffamily\bfseries,bg=azure5,fg=white},
cell{2-Y}{1} = {preto={\refstepcounter{rowcntr}\therowcntr}},
}
Col 1 & Col 2 \
\label{row:long-table-1-a} & Ipsum \
\label{row:long-table-1-b} & Ipsum \
Col 1 & Col 2 \
\end{longtblr}
\begin{longtblr}[
caption = {Long Table 2},
label = {tblr:long-table-2},
]{
colspec = {X[3]|X[5]},
width = \linewidth,
rowhead = 1,
rowfoot = 1,
row{even} = {azure9},
row{1,Z} = {c,font=\sffamily\bfseries,bg=azure5,fg=white},
cell{2-Y}{1} = {preto={\refstepcounter{rowcntr}\therowcntr}},
}
Col 1 & Col 2 \
\label{row:long-table-2-a} & Ipsum \
\label{row:long-table-2-b} & Ipsum \
Col 1 & Col 2 \
\end{longtblr}
\end{document}
NewTblrEnviron, the counter does not reset between tables. For insight, how can that be fixed? – Ritmo2k Mar 09 '24 at 16:59