[Tex/LaTex] partitioned matrix

matrices

Please tell me the way to code latex to produce a matrix whose form is in the following image. Many thanks. My current code is not the desired one. matrix

    \documentclass[a4paper]{article}
    \usepackage{amsmath}
    \begin{document}
    \begin{equation}
    U^{(k+1)}_a=
    \left(
    \begin{array}{ccccc|c}
    &  &  &  &  & \left(U^{(k+1)}_a\right)_{0k} \\
    &  &  &  &  & \left(U^{(k+1)}_a\right)_{1k} \\
    &  &  U^{(k)}_a  &  &  & \vdots \\
    &  &  &  &  & \vdots \\
    &  &  &  &  & \vdots \\
    \hline
    a_k & 0 & \dots & 0 & 0 & \left (U^{(k+1)}_a\right)_{kk}
    \end{array}
    \right).
    \end{equation}
    \end{document}

Best Answer

This can be done using the \multicolumn command. The \cline command makes the partial horizontal line. The 1-column \multicolumn in the last row eliminates the last portion of the vertical line. Using \multicolumn for the U^{(k)}_a entry automatically centers it horizontally instead of placing it in the third column.

I also added a bit of space between your rows by setting \arraystretch to 1.6.

\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
U^{(k+1)}_a=
\left(
\renewcommand{\arraystretch}{1.6}
\begin{array}{ccccc|c}
&  &  &  &  & \left(U^{(k+1)}_a\right)_{0k} \\
&  &  &  &  & \left(U^{(k+1)}_a\right)_{1k} \\
\multicolumn{5}{c|}{U^{(k)}_a} & \vdots \\
&  &  &  &  & \vdots \\
&  &  &  &  & \vdots \\
\cline{1-5}
a_k & 0 & \dots & 0 & \multicolumn{1}{c}{0} & \left (U^{(k+1)}_a\right)_{kk}
\end{array}
\right).
\end{equation}
\end{document}

enter image description here

I would also probably delete the 4th column and two of the rows of \vdots, and use \cdots instead of \dots, but that's just my opinion. If you add \usepackage{array} you'll get a cleaner join between the horizontal and vertical lines.

U^{(k+1)}_a=
\left(
\renewcommand{\arraystretch}{2}
\begin{array}{cccc|c}
&  &  &  & \left(U^{(k+1)}_a\right)_{0k} \\
    \multicolumn{4}{c|}{U^{(k)}_a} & \left(U^{(k+1)}_a\right)_{1k} \\
&  &  &  & \vdots \\
\cline{1-4}
a_k & 0 & \cdots & \multicolumn{1}{c}{0} & \left (U^{(k+1)}_a\right)_{kk}
\end{array}
\right).

enter image description here

Related Question