3
\begin{equation*}
    U^{k} = \begin{tikzpicture}
            \matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)
            {
                z^{k}     &  0 & \cdots & s z^{0} & s z^{1} & \cdots & s z^{k-2} & s    z^{k-1} \\
                z^{k-1} s &  \vdots&    & -\overline{z} & s^{2} z^{0}   & \cdots & s^{2} z^{k-3} & s^{2} z^{k-2} \\
                z^{k-2} s &   & &  & -\overline{z} & s^{2} z^{0} & \cdots & s^{2} z^{k-3} \\
                \vdots    &   & &  &   & \ddots & \ddots & \vdots \\
                z s       & \vdots&  &   & 0 &   & -\overline{z} & s^{2} z^{0} \\
                s         & 0 & \cdots &  &   &   &   & -\overline{z} \\
                0         & 1 &   & 0 &  &  &   &   \\
                \vdots    &   & \ddots & &  &   & 0 &   \\
                0         & 0 &   & 1 &  & &   &   \\
            };
            \draw (m-2-4.north west) rectangle (m-6-8.south east);
            \draw (m-7-2.north west) rectangle (m-9-4.south east);
            \end{tikzpicture}
\end{equation*}

thats my code and the result enter image description here

the one rectangle is to small. any ideas? and to have the "U^k=" in the middle?

mfg
  • 31

2 Answers2

2

To bring U^k= to the middle use [baseline={(m.center)}] as the option to the \begin{tikzpicture}. and to make the rectangle bigger use (m-6-8.south east-|m-2-8.north east) in

 \draw (m-2-4.north west) rectangle (m-6-8.south east-|m-2-8.north east);

which means x coordinate same as m-2-8.north east and y coordinate same as that of m-6-8.south east.

Code:

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix}
\begin{document}
  \begin{equation*}
    U^{k} = \begin{tikzpicture}[baseline={(m.center)}]
            \matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)
            {
                z^{k}     &  0 & \cdots & s z^{0} & s z^{1} & \cdots & s z^{k-2} & s    z^{k-1} \\
                z^{k-1} s &  \vdots&    & -\overline{z} & s^{2} z^{0}   & \cdots & s^{2} z^{k-3} & s^{2} z^{k-2} \\
                z^{k-2} s &   & &  & -\overline{z} & s^{2} z^{0} & \cdots & s^{2} z^{k-3} \\
                \vdots    &   & &  &   & \ddots & \ddots & \vdots \\
                z s       & \vdots&  &   & 0 &   & -\overline{z} & s^{2} z^{0} \\
                s         & 0 & \cdots &  &   &   &   & -\overline{z} \\
                0         & 1 &   & 0 &  &  &   &   \\
                \vdots    &   & \ddots & &  &   & 0 &   \\
                0         & 0 &   & 1 &  & &   &   \\
            };
            \draw (m-2-4.north west) rectangle (m-6-8.south east-|m-2-8.north east);
            \draw (m-7-2.north west) rectangle (m-9-4.south east);
            \end{tikzpicture}
\end{equation*}
\end{document}

enter image description here

2

I've discovered easy bundle in CTAN and this is a good question to test easybmat package.

As usual you need to know columns number but also rows number. It's possible to select different alignemt (l,c,r) for rows and columns. And it's possible to draw paths between elements.

\documentclass{article}
\usepackage{amsmath}
\usepackage{easybmat}

\begin{document}
\begin{equation*}
    U^{k} = \left(\begin{BMAT}{cccccccc}{ccccccccc}
                z^{k}     &  0 & \cdots & s z^{0} & s z^{1} & \cdots & s z^{k-2} & s    z^{k-1} \\
                z^{k-1} s &  \vdots&    & -\overline{z} & s^{2} z^{0}   & \cdots & s^{2} z^{k-3} & s^{2} z^{k-2} \\
                z^{k-2} s &   & &  & -\overline{z} & s^{2} z^{0} & \cdots & s^{2} z^{k-3} \\
                \vdots    &   & &  &   & \ddots & \ddots & \vdots \\
                z s       & \vdots&  &   & 0 &   & -\overline{z} & s^{2} z^{0} \\
                s         & 0 & \cdots &  &   &   &   & -\overline{z} \\
                0         & 1 &   & 0 &  &  &   &   \\
                \vdots    &   & \ddots & &  &   & 0 &   \\
                0         & 0 &   & 1 &  & &   &   
    \addpath{(1,0,0)rrruuulllddd}
    \addpath{(3,3,0)rrrrruuuuulllllddddd}
    \end{BMAT}\right)
\end{equation*}
\end{document}

enter image description here

Ignasi
  • 136,588
  • This one is also very good, especially that the rectangles don't overlap, merely that the empty space at the top of the big rectangle is a bit out of order – mfg Aug 27 '14 at 15:16
  • @mfg And also the right space on the small one. May be it's possible to adjust it but this was my just first test with easybmat and used default parameters. – Ignasi Aug 27 '14 at 17:21