It's easy with the environment {NiceTabular}
of nicematrix
.
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular}{>{\bfseries}cccccc}[hvlines,corners=NW] % NW = north west
\RowStyle{\bfseries}
& 1 & 2 & 3 & 4 & 5 \\
1 & & & 1 & 1 & \\
2 & & & & 1 & 1 \\
3 & 1 & & & & 1 \\
4 & 1 & 1 & & & \\
5 & & 1 & 1 & & \\
\end{NiceTabular}
\end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes under the hood).

Answer to the comment. Usually, one uses the rules of \booktabs
(\toprule
, midrule
, \bottomrule
, etc.) only with a design without any vertical rule...
However, if you want to add rules with the thickness of a \toprule
of booktabs
(equal to \heavyrulewidth
), it's possible with nicematrix
by defining a custom style of line with the key custom-line
:
\documentclass{article}
\usepackage{nicematrix,booktabs,tikz}
\begin{document}
\NiceMatrixOptions
{
custom-line =
{
command = boldhline ,
ccommand = cboldhline ,
tikz = { line width = \heavyrulewidth } ,
total-width = \heavyrulewidth
}
}
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular}{>{\bfseries}cccccc}[hvlines,corners=NW] % NW = north west
\cboldhline{2-last}
\RowStyle{\bfseries}
& 1 & 2 & 3 & 4 & 5 \\
1 & & & 1 & 1 & \\
2 & & & & 1 & 1 \\
3 & 1 & & & & 1 \\
4 & 1 & 1 & & & \\
5 & & 1 & 1 & & \\
\boldhline
\end{NiceTabular}
\end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes under the hood).

booktabs
, have a look at this question\toprule
.\cmidrule
.booktabs
.