[Tex/LaTex] diagonal line within matrix

matrices

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:

enter image description here

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

Best Answer

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}

enter image description here