Enforcing That \array Stays Square When Drawing Matrix
With tikz (There are others methods with tikz like matrix etc.)
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,2}
\foreach \y in {1,2}
{
\draw (\x,\y) +(-.5,-.5) rectangle ++(.5,.5);
\draw (\x,\y);
}
\node at (1,2) {$I_{r \times r}$} ;
\node at (1,1) {0} ; \node at (2,1) {0} ;\node at (2,2) {0} ;
\end{tikzpicture}
\end{document}
or you can do something like that but I'm not sure if all blank spaces are removed.
\def\vh{\vrule height 0.6cm depth 0.4cm width 0 cm}%
\newcommand{\sq}[2][1cm]{\hbox to #1{\hfil\vh#2\hfil}}%
$
\begin{array}{@{}|@{}c@{}|@{}c@{}|@{}}
\hline
\sq{$I_{r \times r}$}&\sq{0}\\
\hline
\sq{0} & \sq{0}\\
\hline
\end{array}
$
the width/height of a cell is a parameter of the columntype C
\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{@{}>{\rule[0.5\dimexpr-#1+1.2ex]{0pt}{#1}\hfil$}p{#1}<{$\hfil}@{}}
\begin{document}
\Huge
$\begin{array}{|C{2cm} | C{2cm} |}\hline
I_{r \times r} & 0 \\\hline
0 & 0 \\\hline
\end{array} $
$\begin{array}{|C{2.5cm} | C{2.5cm} |}\hline
I_{r \times r} & 0 \\\hline
0 & 0 \\\hline
\end{array} $
\end{document}