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}
\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 theU^{(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
to1.6
.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.