please help me to create this in LaTeX:
[Tex/LaTex] Determinant of 3×3 matrix by cofactor expansion
matricestikz-matrix
Related Solutions
I do not see the need of defining something new. With following approach, LyX will make use of the vmatrix
environment automatically.
Use "Insert > Math > Matrix..." or alternatively, in math mode the toolbar to create an empty 3x3 matrix possible with some decoration like "|...|
". Then you can copy and paste this matrix (either empty or already filled) to other locations in the document.
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}
\usepackage{tikz}
\usetikzlibrary{calc, fit}
\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}
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.
Best Answer
A simple code with
pstricks
andmathtools
:Ensure you have
--enable-write18
in your LaTeX command/engine so thatauto-pst-pdf
works.