[Tex/LaTex] putting frame on a column of a matrix

equations

I have a matrix written as following:

\begin{equation}
 A={
 \begin{pmatrix} 
1 & -1 & 0  & 0 & 0 & \dots\\
0 &  1 & -1 & 0 & 0 &\dots\\ 
1 &  0 & -1 & 0 & 0 &\dots\\
0 &  0 &  1 & -1 & 0 &\dots\\
1 &  0 &  0 & -1 & 0 &\dots\\
0 &  0 &  0 &  1 & -1 &\dots\\
. &  . &  . & . &  . &\dots\\
. &  . &  . & . &  . &\dots\\
\end{pmatrix}
\end{equation}

I would like to have a box which frames the content of the forth column from its forth row to the end. I am wondering how it should be done?! I will appreciate for a help.

Best Answer

Here's one way with using a \smashed \fbox around a dropped \rule. EDITED to provide a colored box.

\documentclass{article}
\usepackage{amsmath,xcolor}
\fboxrule=1pt
\begin{document}
\begin{equation}
 A=
 \begin{pmatrix} 
1 & -1 & 0  & 0 & 0 & \dots\\
0 &  1 & -1 & 0 & 0 &\dots\\ 
1 &  0 & -1 & 0 & 0 &\dots\\
0 &  0 &  1 & \smash{\color{red}\fbox{\color{black}\rule[-50pt]{0pt}{1pt}$-1$}} & 0 &\dots\\
1 &  0 &  0 & -1 & 0 &\dots\\
0 &  0 &  0 &  1 & -1 &\dots\\
. &  . &  . & . &  . &\dots\\
. &  . &  . & . &  . &\dots\\
\end{pmatrix}
\end{equation}
\end{document}

enter image description here

And if you wanted the matrix entries right aligned, you could use a tabstack:

\documentclass{article}
\usepackage{tabstackengine,xcolor}
\def\mykern{\kern-\fboxsep\kern-\fboxrule}
\def\cfbox#1{\mykern\smash{\color{red}\protect\fbox{\color{black}#1}\mykern}}
\fboxrule=1pt
\begin{document}
\begin{equation}
 A=
\setstacktabbedgap{1.5ex}
\renewcommand\stackalignment{r}
 \parenMatrixstack{ 
1 & -1 & 0  & 0 & 0 & \dots\\
0 &  1 & -1 & 0 & 0 &\dots\\ 
1 &  0 & -1 & 0 & 0 &\dots\\
0 &  0 &  1 & \cfbox{\protect\rule[-50pt]{0pt}{1pt}$-1$} & 0 &\dots\\
1 &  0 &  0 & -1 & 0 &\dots\\
0 &  0 &  0 &  1 & -1 &\dots\\
. &  . &  . & . &  . &\dots\\
. &  . &  . & . &  . &\dots
}
\end{equation}
\end{document}

enter image description here

Related Question