\documentclass{jarticle}
\usepackage{array}

\newlength{\cellwid}

\makeatletter
\newenvironment{latinsq}[1][00]{%
 \def\centcol{\centering \let\\=\tabularnewline \CellStrut}
 \arraycolsep0pt
 \setbox\@tempboxa\hbox{#1}%
 \cellwid\ht\@tempboxa  \advance\cellwid\dp\strutbox
 \ifdim\cellwid<\wd\@tempboxa % wide numbers set square size
   \@tempdima .5\wd\@tempboxa \advance\@tempdima -.5\cellwid % half difference
   \advance\cellwid \@tempdima \advance\@tempdima\dp\strutbox
 \else
   \@tempdima\dp\strutbox
 \fi
 \edef\CellStrut{\vrule
   width\z@ height\the\cellwid depth\the\@tempdima \relax}
 \advance\cellwid\@tempdima \advance\cellwid-2\arraycolsep
 \array{|>{\centcol}p{\cellwid}|*{20}{>{\centcol}p{\cellwid}|}}}%
 {\endarray}
\makeatother

\begin{document}

$$
\begin{latinsq}[1234]  %  Specify widest entry.  Default is "00"
\hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
  &  &   &  &   &  &   &  &   &  &   &  &   &  &   &  & \\ \hline
\end{latinsq}
$$

$$
\begin{latinsq}[123]  %  Specify widest entry.  Default is "00"
\hline
  &  & \\ \hline
 &  &  \\ \hline
&  &  \\ \hline
\end{latinsq}
$$

$$
\begin{latinsq} \hline
 1 & 3 & 4 & 2 \\ \hline
 2 & 4 & 3 & 1 \\ \hline
 3 & 1 & 2 & 4 \\ \hline
 4 & 2 & 1 & 3 \\ \hline
\end{latinsq}
$$
$$
\begin{latinsq}[123]  %  Specify widest entry.  Default is "00"
\hline
 1 & 2 & 3\\ \hline
11 & 0 &  \\ \hline
123& 45 & 6 \\ \hline
\end{latinsq}
$$

\end{document}
