1

I should add a header row: 1 2 3 4 to a matrix and a column (as before: 1 2 3 4 ) on the left of the same matrix. But the style should be different like below:

enter image description here

this is my MWE:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}

\tikzset{square matrix/.style={
    matrix of nodes,
    column sep=-\pgflinewidth, row sep=-\pgflinewidth,
    nodes={draw,
      minimum height=#1,
      anchor=center,
      text width=#1,
      align=center,
      inner sep=0pt
    },
  },
  square matrix/.default=0.5cm
}

\matrix[square matrix]
{
16 & 3 & 2 & 13 \\
5 & 10 & 11 & 8 \\
9 & 6  & 7 & 12 \\
4 & 15 & 14 & 1 \\
};

\end{tikzpicture}
\end{document}

Thank you so much!