# NiceMatrix first-row vertical alignment

I have a NiceMatrix which is right aligned, but I am looking for a way to have the first-row centered.

Here is the code :

\begin{bNiceMatrix}[r,first-row,last-col,code-for-first-row = \scriptstyle \color{blue} \arabic{jCol},code-for-last-col = \scriptstyle \color{blue} \arabic{iRow}]
&  &  &  & \\
-2 & 3 & -4 & 5 & \\
3 & -4 & 5 & -6 & \\
-4 & 5 & -6 & 7 & \\
5 & -6 & 7 & -8 &
\end{bNiceMatrix}


And here is the result :

I would like to have the blue column numbers centered.

Thanks in advance for the help.

Z

You should put each element of the first row'' in a mono-cell \Block. By default, the value of alignement of a \Block is c (centered).

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\begin{bNiceMatrix}% [ r, first-row, last-col, code-for-first-row = \Block{}{\color{blue} \scriptstyle \arabic{jCol}}, code-for-last-col = \scriptstyle \color{blue} \arabic{iRow} ] & & & & \\ -2 & 3 & -4 & 5 & \\ 3 & -4 & 5 & -6 & \\ -4 & 5 & -6 & 7 & \\ 5 & -6 & 7 & -8 & \\ \end{bNiceMatrix}$

\end{document}


As usual with nicematrix, you need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).