# partitioned matrix

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.

    \documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}
$$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{document}

• Welcome! You have much better chances of getting an answer if you provide a minimal working example. A good starting point for you might be the second answer to this question. – user121799 Nov 13 '17 at 2:18
• this might help: Seemingly simple block matrix – barbara beeton Nov 13 '17 at 3:07
• Welcome to TeX.SX. When you post a question, you are expected to provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output. – Sandy G Nov 13 '17 at 5:47
• @barbarabeeton: Thank you, I have read the code but maybe it's too complicated to me. Thus, I expect a simpler one. – dat le Nov 13 '17 at 7:10
• @SandyG: Thank you for your replying. I will do it for the next times. – dat le Nov 13 '17 at 7:11

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}
$$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{document}


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).


• Totally awesome! Thank you, Sandy G, not only because of helping me code but also guiding me to post question properly. – dat le Nov 13 '17 at 15:25
• I should add, though it may seem strange, that comments should not be used for giving thanks. The way to show appreciation is to vote up an answer that you like (using the voting arrows to the left of the answer). Note that you can vote up more than one answer. You should also "accept" the answer that you believe is the best solution to your problem. – Sandy G Nov 13 '17 at 15:33

It's actually a two-by-two matrix, with nested ones:

\documentclass{article}
\usepackage{amsmath,array}

\begin{document}

$U'=\left( \begin{array}{@{}c|c@{}} U & \begin{array}{@{}c@{}} a \\ b \\ \vdots \end{array} \\ \cline{1-1} \multicolumn{1}{@{}c}{ \begin{matrix} a & b & \cdots \end{matrix} } & z \end{array} \right)$

\end{document}


• many thanks for your reply. It's greatly helpful. – dat le Nov 13 '17 at 15:23

If you like to have more dots without interruption, you may wish to use tikz.

 \documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
$U'~=~\left( \vcenter{\hbox{\begin{tikzpicture} \node[matrix of math nodes] (mymat) { & & ~& \left(U^{(k+1)}_a\right)_{0k} \\ & & ~& \left(U^{(k+1)}_a\right)_{1k} \\ & ~~~~~~{\text{\HugeU}}~~~~~~ & & \\[1cm] ~ & & ~ & ~ \\ a & & & \left (U^{(k+1)}_a\right)_{kk}\\ }; \draw (mymat-1-4.north west) -- (mymat-5-4.north west); \draw (mymat-4-1.south west) -- (mymat-4-3.south east); \draw[ultra thick,line cap=round,dash pattern=on 0 off 1.6mm](mymat-2-4)--(mymat-4-4); \draw[ultra thick,line cap=round,dash pattern=on 0 off 1.6mm](mymat-5-1)--(mymat-5-4); \end{tikzpicture}}}\right)$
\end{document}