# diagonal line within matrix

I've got simple task - draw block of matrices, when one of the matrices contains diagonal and vertical lines. I am able to make diagonal dotted lines but so far i have not succeeded with solid line. Example of my matrix follows:

 \begin{pmatrix}
\hat{B} &         & & & \\
& ddots & & & \\
&         & ddots & & \\
&         & &  ddots \\\hline
\\
\\
& & \text{{\huge{0}}}  & &  \\
\\
\end{pmatrix}

-
–  Ignasi Oct 22 '12 at 15:38
You mean that you want a solid line instead of the diagonal dots? –  egreg Oct 22 '12 at 15:43
I would like to have one solid diagonal line across the whole matrix, or better to say across the upper part –  jiri jansa Oct 22 '12 at 15:59
Highly related: Diagonal dots spanning multiple lines/columns of a matrix. You can use some of those answers as well and just change the line style. –  Werner Oct 22 '12 at 19:03

One possibility is to use \tikzmark to place marks at the beginning and end of the lines and then draw them:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

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

\newcommand\MyLine[3][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[#1] (#2.north west) -- (#3.south east);
\end{tikzpicture}}

\begin{document}

$\begin{pmatrix} \phantom{0}\tikzmark{a} & & & & \\ & & & & \\ & & & & \\ & & & & \tikzmark{b}\phantom{0}\\\hline \\ \\ \multicolumn{5}{c}{\text{\huge 0}} \\ \\ \end{pmatrix}\qquad \begin{pmatrix} \phantom{0}\tikzmark{c} & \phantom{0}\tikzmark{e} & & & \\ & & & & \\ & & & & \tikzmark{f}\phantom{0} \\ & & & & \tikzmark{d}\phantom{0}\\\hline \\ \\ \multicolumn{5}{c}{\text{\huge 0}} \\ \\ \end{pmatrix}$
\MyLine[ultra thick]{a}{b}
\MyLine[blue,thick]{c}{d}
\MyLine[blue,thick]{e}{f}

\end{document}


-
works perfect ! –  jiri jansa Oct 23 '12 at 7:30