I try to color the diagonal of a matrix.
\begin{equation}
C=
\begin{bmatrix}
1 & 1 & 0\\
0 & 1 & 1\\
1 & 0 & 1\\
\end{bmatrix}
\end{equation}
All I found was related to rows and columns (see. https://tex.stackexchange.com/a/69714/74926
and
http://www.alecjacobson.com/weblog/?p=1289)
Could someone may help.
I already found this. Sadly the line overlay the text and the brackets.
Some further help would be great.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\tikzmark}[2]{
\tikz[overlay,remember picture,baseline]
\node[anchor=base] (#1) {$#2$};
}
\begin{document}
\[
\begin{pmatrix}
\tikzmark{top}{1} & \tikzmark{top2}{1} & 0 \\
0 & 1 & \tikzmark{bottom2}{1} \\
\tikzmark{end}{1} & 0 & \tikzmark{bottom}{1}\\
\end{pmatrix}
\]
\begin{tikzpicture}[overlay,remember picture]
\draw[red,line width=1mm,line cap=round] (top.north west) -- (bottom.south east);
\draw[red,line width=1mm,line cap=round] (top2.north west) -- (bottom2.south east);
\draw[red,line width=1mm,line cap=round] (end.north west) -- (end.south east);
\end{tikzpicture}
\end{document}
Best Answer