我的代码
\documentclass[]{article}
\usepackage{tikz}
\usepackage{nicematrix}
\begin{document}
\begin{NiceMatrixBlock}[auto-columns-width]
\NiceMatrixOptions
{
delimiters/max-width,
light-syntax,
last-col, code-for-last-col = \color{blue}\scriptstyle,
}
\setlength{\extrarowheight}{1mm}
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
1 -2 4 3 ;
3 -5 -1 -2 ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 4 -7 1 { L_2 \gets L_1-L_2
} ;
0 11 -8 14 { L_3 \gets 3L_1-L_3
} ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 { L_2 \gets 4L_2
} ;
0 44 -32 56 { L_3 \gets 4L_3
} ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 { L_2 \gets 4L_2
} ;
0 0 -45 -45 { L_3 \gets L_2 - L_3
} ;
\end{pNiceArray}$
\end{NiceMatrixBlock}
$\begin{NiceArray}{ccc@{}w{c}{5mm}@{}ccc}
& & && 1 & 2 & -3\\
& & && 0 & 44 & -77 \\
& & && 0 & 0 & -45 \\
\CodeAfter
\NewDocumentCommand{\MyDraw}{}{\tikz \draw [blue] (2-|1) -| (3-|2) -| (4-|3) ;}
\SubMatrix({1-5}{3-7})[code = \MyDraw]
\end{NiceArray}$
\end{document}
答案1
您只须在\CodeAfter
最后一条线中画出您想要的线即可{pNiceArray}
。
\documentclass{article}
\usepackage{tikz}
\usepackage{nicematrix}
\begin{document}
\begin{NiceMatrixBlock}[auto-columns-width]
\NiceMatrixOptions
{
delimiters/max-width,
light-syntax,
last-col, code-for-last-col = \color{blue}\scriptstyle,
}
\setlength{\extrarowheight}{1mm}
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
1 -2 4 3 ;
3 -5 -1 -2 ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 4 -7 1 { L_2 \gets L_1-L_2
} ;
0 11 -8 14 { L_3 \gets 3L_1-L_3
} ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 { L_2 \gets 4L_2
} ;
0 44 -32 56 { L_3 \gets 4L_3
} ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 { L_2 \gets 4L_2
} ;
0 0 -45 -45 { L_3 \gets L_2 - L_3
} ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 ;
0 0 -45 -45 ;
\CodeAfter
\tikz \draw [blue] ([xshift=1mm]2-|1) -| (3-|2) -| (4-|3) ;
\end{pNiceArray}$
\end{NiceMatrixBlock}
\end{document}
答案2
pNicearray
为 final 数组创建一个似乎有点过分。下面是一个使用“普通”的解决方案array
。
\documentclass{article}
\usepackage{tikz}
\usepackage{nicematrix}
\setlength{\extrarowheight}{1mm}
\newlength\mylen
\settowidth\mylen{$-44$}
\addtolength\mylen{0.3pt} % column width in 'array' env.
\newcommand\0{\multicolumn{1}{r|}{0}} % handy shortcut command
\begin{document}
\begin{NiceMatrixBlock}[auto-columns-width]
\NiceMatrixOptions
{ delimiters/max-width,
light-syntax,
last-col,
code-for-last-col = \color{blue}\scriptstyle,
}
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
1 -2 4 3 ;
3 -5 -1 -2 ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 4 -7 1 { L_2 \gets L_1-L_2 } ;
0 11 -8 14 { L_3 \gets 3L_1-L_3 } ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 { L_2 \gets 4L_2 } ;
0 44 -32 56 { L_3 \gets 4L_3 } ;
\end{pNiceArray}$
\smallskip
$\begin{pNiceArray}{rrr|r}
1 2 -3 4 {} ;
0 44 -77 11 { L_2 \gets 4L_2 } ;
0 0 -45 -45 { L_3 \gets L_2 - L_3 } ;
\end{pNiceArray}$
\end{NiceMatrixBlock}
\smallskip
$\left( \begin{array}{@{} *{3}{wr{\mylen}}| wr{\mylen} @{}}
1 & 2 & -3 & 4 \\ \cline{1-1}
\0 & 44 & -77 & 11 \\ \cline{2-2}
0 & \0 & -45 & -45
\end{array} \right)$
\end{document}