3

How to create this matrix in latex?enter image description here

  • 2
    Please clarify your question. Do you have the matrix already, and just want to add some annotations? Or do you expect those who consider answering this to punch in everything from the screen shot? – user194703 Dec 28 '19 at 23:13
  • 2
    Please post a minimal working example showing what you have tried so far. This is not a just-do-it-for-me site, we are not doing the formatting for your books for free. – fractal Dec 28 '19 at 23:43
4

Since this is very quick to do (except for punching in the entries) here is a version with nicematrix. I agree with @fractal, though, that this is not the purpose of the site.

\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{nicematrix}
\usetikzlibrary{calc}
\begin{document}
\[\mathbf{B}=\left[\;\begin{NiceArray}{CCCC|C}[name=B]
    1 & 0 & 2 & 0 & -1 \\
    0 & 1& 0 & 3 & 4\\
    0 & 0& 0 & 1 & 2\\
    0 & 0& 0 & 0 & 0\\
\end{NiceArray}\;\right]
\begin{tikzpicture}[remember picture, overlay,
c/.style={fit={(B-#1)},circle,draw,thick,inner sep=0.6pt,node contents={}}]
\path foreach \X in {1-1,2-2,3-4} {node [c=\X]};
\draw[very thin,gray] let \p1=($(B-1-2.south west)-(B-2-1.north east)$) in
 ([xshift=-\x1/2,yshift=-2*\y1/3]B-1-1.south west) 
 -| ([xshift=-\x1/2,yshift=-2*\y1/3]B-2-2.south west)
 -| ([xshift=-\x1/2,yshift=-2*\y1/3]B-3-4.south west)
 -- ([xshift=\x1/3,yshift=-2*\y1/3]B-3-4.south east)
 ([xshift=-\x1/2,yshift=-2*\y1/3]B-3-5.south west)
 -- ([xshift=\x1/2,yshift=-2*\y1/3]B-3-5.south east);
\end{tikzpicture}
\]
\end{document}

enter image description here

There are zillions of alternatives, some will require less packages at the expense of having less control, others will criticize the spacing here (but it is to reproduce the screen shot) and so on and so forth. The question whether such matrices really help the reader to understand what's going on is off-topic, this is merely to say that if you really need to it is easy to create such things.

| improve this answer | |
6

A solution with the new circledsteps package and hhline:

\documentclass[svgnames, table]{article}
\usepackage{amsmath}%
\usepackage{array, hhline}
\usepackage{circledsteps, tikz}
\tikzset{/csteps/inner ysep=6pt, /csteps/inner xsep=6pt}

\begin{document}

\[
\setlength{\extrarowheight}{3pt}
 \mathbf {B} = \begin{bmatrix}\begin{array}{@{}cccc|c@{}}
\Circled{\textbf{1}} & 0 & 2 & 0 & -1 \\[0.5ex]\noalign{\vspace*{-0.4pt}}
\hhline{>{\arrayrulecolor{Gainsboro}}-~>{\arrayrulecolor{black}~~~}}
\multicolumn{1}{@{}c!{\color{Gainsboro}\vrule}}{0 }& \Circled{\textbf{1}} &3 & 0 & 4 \\[0.2ex]
\hhline{~>{\arrayrulecolor{Gainsboro}}|--~>{\arrayrulecolor{black}}~}\noalign{\vspace*{-0.4pt}}
0 & 0 & \multicolumn{1}{c!{\color{Gainsboro}\vrule}}{0} & \Circled{\textbf{1}} &2 \\[0.2ex]
\hhline{~~~>{\arrayrulecolor{Gainsboro}}|->{\arrayrulecolor{black}}|>{\arrayrulecolor{Gainsboro}}-}
0 & 0 & 0 & \multicolumn{1}{c!{\color{black}\vrule}}{0 } & 0
\end{array}
\end{bmatrix} \]

\end{document} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.