# How to draw this special matrix with horizontal line and vertical line in it?

I have tried with blockarray like

\begin{align*}
B=
\left[\begin{blockarray}{ccccc}
a_{s_0} & a_{s_0+1} & \cdots &\cdots &a_{s_0+n}\\
%\begin{blockarray}{cccccc}
%\begin{block}{ccccc|c}
\begin{block}{cccc|c}
\cline{1-4}
a_{s_0+1} & a_{s_0+2}&\cdots &\cdots &a_{s_0+n+1}\\
\vdots & \vdots &     &  &  \\
0 & 0  &\cdots & 0  & b \\
\vdots & \vdots &     &  &  \\
a_{s_0+n} &a_{s_0+n+1} &\cdots &\cdots & a_{s_0+2n}\\
%\end{block}
%\end{blockarray}
\end{block}
\end{blockarray}\right]
\end{align*}


but I'm not able to handle the vertical line.

You don't really need blkarray for that: an ordinary array will do:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{align*}
B=
\left[\begin{array}{c|ccc|c}
a_{s_0} & a_{s_0+1} & \cdots & \multicolumn{1}{c}{\cdots} &a_{s_0+n}\\
\cline{1-4}
a_{s_0+1} & a_{s_0+2}&\cdots &\cdots &a_{s_0+n+1}\\
\vdots & \vdots & & & \vdots \\
0 & 0 &\cdots & 0 & b \\
\vdots & \vdots & & & \vdots \\
\cline{2-5}
\multicolumn{1}{c}{a_{s_0+n}} &a_{s_0+n+1} &\cdots &\cdots & a_{s_0+2n}\\
\end{array}\right]
\end{align*}

\end{document}


• You mean we can use "\multicolumn" to eliminate the vertical line in each row ,that's a good idea,thanks! – mbfkk Apr 29 at 11:09
• @mbfkk Consider accepting this answer if it helps. – user156344 May 7 at 4:28

Here is a solution using TikZ:

\documentclass[margin=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
$B$ = \begin{tikzpicture}[baseline=(current  bounding  box.center)]
\matrix [matrix of math nodes,
nodes in empty cells,
left delimiter = [,right delimiter={]},
align = center,
text width = 2.5em,
text depth = 0.25em,
](m){
a_{s_0+1} & a_{s_0+2}&\cdots &\cdots &a_{s_0+n+1}\\
\vdots & \vdots &     &  &  \\
0 & 0  &\cdots & 0  & b \\
\vdots & \vdots &     &  &  \\
a_{s_0+n} &a_{s_0+n+1} &\cdots &\cdots & a_{s_0+2n}\\
};
% Drawing the lines
\draw[draw, thick] (m-1-1.north east) -- (m-4-1.south east); % Left vertical
\draw[draw, thick] (m-1-4.south east) -- (m-5-4.south east); % Right vertical
\draw[draw, thick] (m-1-1.south west) -- (m-1-4.south east); % Upper horizontal
\draw[draw, thick] (m-4-1.south east) -- (m-4-5.south east); % Lower horizontal
\end{tikzpicture}
\end{document}

• Thanks! Tikz is powerful! – mbfkk May 8 at 4:00