Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
you are missing \multicolumn{1}{r}{} on the second row. –  David Carlisle May 15 at 10:40
    
@DavidCarlisle see the update. –  MickG May 15 at 10:54
    
you want {r|}{} for a cell with a line on the right –  David Carlisle May 15 at 11:12
add comment

2 Answers 2

up vote 2 down vote accepted

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}
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.