# [Tex/LaTex] Vertical lines spanning only certain rows in matrix

matrices

As you can see in the picture, there is an annoying extra vertical line I want to remove: the one in row 2 at the matrix's start. The code for that is:

\begin{array}{|c|c|c|c|}
\multicolumn{2}{r}{}\\\cline{1-1}
-1 \\ \cline{1-2}
& -1 \\ \cline{2-4}
\multicolumn{1}{r}{} & & 0 & -1 \\ \cline{3-4}
\multicolumn{1}{r}{} & & 1 & -2 \\\cline{3-4}
\end{array}=\left(\begin{array}{cccc}
-1 & 0 & 0 & 0 \\
0 & -1 & 0 & 0 \\
0 & 0 & 0 & -1 \\
0 & 0 & 1 & -2
\end{array}\right).


So, is there a more logical way of getting a vertical column separator line to span only certain rows other than making part of it vanish with \multicolumn? How do I remove that extra vertical line? Is there a way to draw the horizontal line on top of cell 1,1 that doesn't add an extra line at the top?

Update:

If I put \multicolumn in the second row, the vertical line on the right of that row's first cell also vanishes, which I do not want. That's why I didn't put it and why I asked this question.

\documentclass[border=10pt]{standalone}
$\begin{array}{c|c|c|c|} \multicolumn{1}{r}{}\\ \cline{1-1} \multicolumn{1}{|r|}{-1} \\ \cline{1-2} & -1 \\ \cline{2-4} \multicolumn{1}{r}{} & & \phantom{-}0 & -1 \\ \cline{3-4} \multicolumn{1}{r}{} & & \phantom{-}1 & -2 \\ \cline{3-4} \end{array} = \left(\begin{array}{cccc} -1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 0 & -1 \\ 0 & 0 & 1 & -2 \end{array}\right).$