[Tex/LaTex] Draw a line through one column of a matrix


I'd like to "cancel" (draw a line through) a column of a matrix (using \begin{pmatrix}..\end{pmatrix}). How can I do this?

Best Answer

The usual TikZ answer using \tikzmark to mark the top and bottom points where you want the line to be drawn:

enter image description here


  • This does require two runs. First one to determine the locations, and the second to do the drawing.




\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {$#2$};}

  \begin{tikzpicture}[overlay,remember picture]
    \draw[#1] (#2.north) -- (#3.south);

  \tikzmark{topA}{a} & \tikzmark{topB}b & {0} \\
  a & b & 0 \\
  a & b & 0 \\
  \tikzmark{bottomA}{c} & \tikzmark{bottomB}d & {1}
\DrawLine[red, thick, opacity=0.5]{topA}{bottomA}
Related Question