5

About this code I'd like that only between $a_{11}$ and $a_{12}$ there isn't the vertical line. How can I do? I'd desire to have three solutions, one with normal \begin-\end array, another with pNiceMatrix and the last with tabularray. Furthermore is there a way to color the block matrix rectangle of vertices $a_{22},b_2,a_{n2},b_n$? Thank you so much

\documentclass{book}
\usepackage{mathtools}
\usepackage{nicematrix}
\usepackage{stix}
\usepackage{tabularray}
\usepackage{xcolor,color}

\newcommand{\Tonde}[1]{\left(#1\right)}

\begin{document}

\begin{equation}
\Tonde{\begin{array}{c|ccc|c}a_{11}&a_{12}&\cdots&a_{1n}&b_1\\\cline{2-5}a_{21}&a_{22}&\cdots&a_{2n}&b_2\\\vdots&\vdots&\ddots&\vdots&\vdots\\a_{n1}&a_{n2}&\cdots&a_{nn}&b_n\end{array}}
\end{equation}   

\end{document}
2
  • Your code is not compilable. You have not defined Tonde. Commented Sep 5, 2021 at 10:16
  • Ops... You are right, Sorry. In the first answer \Tonde is correctly defined, sorry again and Thank you for it. I edited my question
    – Puck
    Commented Sep 5, 2021 at 10:25

3 Answers 3

8

With {pNiceMatrix} of nicematrix.

You won't see thin white lines between the cells of the block whatever PDF viewer you use.

\documentclass{book}
\usepackage{mathtools}
\usepackage{nicematrix,tikz}
\usepackage{stix}
\usepackage{xcolor}

\begin{document}

\begin{equation}
\begin{pNiceMatrix}[margin]
  a_{11} & a_{12}  & \cdots & a_{1n} & b_1\\
  a_{21} & \Block[fill=red!15,borders={top,left,right}]{3-3}{}
            a_{22} & \cdots & a_{2n} & b_2\\
  \vdots & \vdots  & \ddots & \vdots & \vdots\\
  a_{n1} & a_{n2}  & \cdots & a_{nn} & b_n
\CodeAfter \tikz \draw (1-|5) |- (2-|last) ; 
\end{pNiceMatrix}
\end{equation}   

\end{document}

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

Output of the above code

8

I will give an solution with tblr environment of tabularray package:

\documentclass{book}

\usepackage{mathtools}
\usepackage{nicematrix}
\usepackage{stix}
\usepackage{tabularray}
\usepackage{xcolor}

\newcommand{\Tonde}[1]{\left(#1\right)}

\begin{document} 

\begin{equation}
\Tonde{\begin{tblr}{
  colspec = {@{}cccc|c@{}},
  colsep = 3pt,
  vline{2} = {2-4}{solid},
  cell{2-4}{2-4} = {red9},
}
  a_{11}&a_{12}&\cdots&a_{1n}&b_1\\
  \cline{2-5}
  a_{21}&a_{22}&\cdots&a_{2n}&b_2\\
  \vdots&\vdots&\ddots&\vdots&\vdots\\
  a_{n1}&a_{n2}&\cdots&a_{nn}&b_n
\end{tblr}}
\end{equation}

\end{document}

enter image description here

5

A way with basic tools (colortbl, hhline, &c.):

\documentclass[table, svgnames]{book}
\usepackage{mathtools}
\usepackage{nicematrix}
\usepackage{stix}
\usepackage{tabularray}
\usepackage{xcolor}
\usepackage{hhline}

\newcommand{\Tonde}[1]{\left(#1\right)}

\begin{document}

\begin{equation}
\Tonde{\begin{array}{c|*{3}{>{\columncolor{Lavender!40}}c}|c}
\rowcolor{white}\multicolumn{1}{c}{a_{11}}&a_{12}&\cdots&a_{1n}&b_1\\\hhline{~|---|-|}
a_{21}&a_{22}&\cdots&a_{2n}&b_2\\
\vdots&\vdots&\ddots&\vdots&\vdots\\
a_{n1}&a_{n2}&\cdots&a_{nn}&b_n
\end{array}}
\end{equation}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .