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

equations

I have a matrix written as following:

$$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}$$


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.

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}
$$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{document}


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}
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{document}