# Special Matrices

Good morning

My Professor wrote this matrices on LaTeX, but I don't understand how he succeded in.

Could someone help me? Please, Thanks. P.S.: I state that I use stix and \documentclass{book} and I'd like to learn TikZ.

• Take a look at the very easy-to-use package nicematrix. Commented Jun 28, 2021 at 7:30

This is easy with standard LaTeX but as projetmbc suggests, take a look at the nicematrix package too, it offers many more possibilities.

Something like this:

\documentclass{article}

\begin{document}
$A=\left(\begin{array}{cccc|ccc} 0 & 0 & \cdots &\multicolumn{1}{c}{1} & a_{1(j+1)} & \cdots & a_{1n_{\mathstrut}}\\\cline{5-7} 0 & 0 & \cdots & 0 & & & \\ \vdots & \vdots & \ddots & \vdots & & A' & \\ 0 & 0 & \cdots & 0 & & & \end{array}\right)$
\end{document}


Edit: As Mico suggested I changed a_{1n} for a_{1n_{\mathstrut}} that sets a better vertical spacing.

• +1. I'd be tempted, though, to change a_{1n} in row 1 to a_{1n_{\mathstrut}} to increase the vertical separation to the \cline rule ever so subtly.
– Mico
Commented Jun 28, 2021 at 9:21
• @Mico, I agree. I just made an edit :-P Commented Jun 28, 2021 at 9:59
• \def\arraystretch{1.2} or \$1pt] achieve the same effect. Commented Jun 28, 2021 at 16:03 • @JohnKormylo, I prefer Mico's solution or \\[1pt] because it's only the space in the first line which needs to be slightly changed. Commented Jun 28, 2021 at 17:01 With {pNiceMatrix} of nicematrix. \documentclass{article} \usepackage{nicematrix} \begin{document} \[ A=\begin{pNiceMatrix}[right-margin] 0 & 0 & \cdots & 1 & a_{1(j+1)} & \cdots & a_{1n}\\ 0 & 0 & \cdots & 0 & \Block[borders={top,left}]{3-3}<\Large>{A'} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 0 \\ \end{pNiceMatrix}$
\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

• Several compilations?? How many, more or less? Under the hood, what do you mean with HOOD?? Thx.
– Puck
Commented Jun 28, 2021 at 8:43
• LaTeX gives a message when another compilation is needed. Some tools, such as latexmk automatically do the right number of compilations. "under the hood" is a English expression. Here I mean that nicematrix uses PGF/Tikz nodes even if the final user does not see those nodes and even has never used Tikz explicitely. Commented Jun 28, 2021 at 9:52
• Ok, Thank you so much. Best Regards
– Puck
Commented Jun 28, 2021 at 14:10

With +pmatrix from tabularray package:

\documentclass{article}
\usepackage{geometry}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\begin{document}
$A= \begin{+pmatrix}[vline{5}={2-Z}{solid},hline{2}={5-Z}{solid}] 0 & 0 & \cdots & 1 & a_{1(j+1)} & \cdots & a_{1n}\\ 0 & 0 & \cdots & 0 & \SetCell[r=3,c=3]{c,m} A'\\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 0 \\ \end{+pmatrix},\quad B= \begin{+pmatrix}[vline{5}={2-Z}{solid},hline{2}={5-Z}{solid}] 0 & 0 & \cdots & 1 & b_{1(j+1)} & \cdots & b_{1n}\\ 0 & 0 & \cdots & 0 & \SetCell[r=3,c=3]{c,m} B'\\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 0 \\ \end{+pmatrix}$
\end{document}