3

enter image description here

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.

3
  • you are missing \multicolumn{1}{r}{} on the second row. Commented May 15, 2014 at 10:40
  • @DavidCarlisle see the update.
    – MickG
    Commented May 15, 2014 at 10:54
  • you want {r|}{} for a cell with a line on the right Commented May 15, 2014 at 11:12

2 Answers 2

1

How about this attempt?

enter image description here

Code

\documentclass[border=10pt]{standalone}
\begin{document}
$
\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).
$
\end{document}
1

How about an altogether different approach?

Here, I just wrap the entries of the left matrix in \struted \frameboxes. The use of stacks allows me to set the inter-row and inter-column spacing conveniently to allow not only all the boxes to mesh together nicely, but also to match the inter-row spacing of the matrix on the right side of the equality (which I right aligned).

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\def\mfbox#1{\kern-\fboxrule\protect\framebox[5ex]{$\strut#1$}}
\begin{document}
\[
\fboxsep=-.5\fboxrule
\tabbedCenterstack{
\mfbox{-1}&&&\\
&\mfbox{-1}&&\\
&&\mfbox{0}&\mfbox{-1}\\
&&\mfbox{1}&\mfbox{-2}
} = \setstacktabbedgap{2ex}\fixTABwidth{T}
\parenMatrixstack[r]{
-1 & 0 & 0 & 0 \\
0 & -1 & 0 & 0 \\
0 & 0 & 0 & -1 \\
0 & 0 & 1 & -2
}
\]
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .