如何在矩阵中绘制这些线?

如何在矩阵中绘制这些线?

我尝试这样做:

]http://www7.pic-upload.de/19.12.13/547iej1463a4.jpg

怎么办?你能帮我吗?

这是没有线条的矩阵的代码:

\left [
\begin{matrix}
    r_{11} & r_{12} & \dots & r_{1i} & r_{1,i+1} & \dots & r_{1n} & c_1\\
    \lambda_{21} & r_{22} & \dots & r_{2i} & r_{2,i+1} & \dots & r_{2n} & c_2\\
    \lambda_{31} & \lambda_{32} & & r_{3i} & r_{3,i+1} & \dots & r_{3n} & c_3\\
    \vdots & \vdots & \ddots & \vdots & \vdots & & \vdots & \vdots \\
    \lambda_{i1} & \lambda_{i2} & & r_{ii} & r_{i,i+1} & \dots & r_{in} & c_i\\
    \lambda_{i+1,1} & \lambda_{1+2,2} & & \lambda_{i+1,i} & a_{i+1,i+1}^{(i)} & \dots & a_{i+1,n}^{(i)} & b_{i+1}^{(i)}\\
    \vdots & \vdots & & \vdots & \vdots & & \vdots & \vdots \\
   \lambda_{n,1} & \lambda_{n,2} & \dots & \lambda_{n,i} & a_{n,i+1}^{(i)} & \dots & a_{n,n}^{(i)} & b_n^{(i)}\\
\end{matrix}
\right ]

太感谢了。

答案1

有了array它就很容易了:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\left [
%\begin{matrix}
\begin{array}{*7{c}|c}
    r_{11} & r_{12} & \dots & r_{1i} & r_{1,i+1} & \dots & r_{1n} & c_1\\
\cline{1-1}
   \multicolumn{1}{c|}{ \lambda_{21}} & r_{22} & \dots & r_{2i} & r_{2,i+1} & \dots & r_{2n} & c_2\\
\cline{2-2}
    \lambda_{31} &    \multicolumn{1}{c|}{\lambda_{32}} & & r_{3i} & r_{3,i+1} & \dots & r_{3n} & c_3\\
    \vdots & \vdots & \ddots & \vdots & \vdots & & \vdots & \vdots \\
    \lambda_{i1} & \lambda_{i2} & &  \multicolumn{1}{|c}{r_{ii}} & r_{i,i+1} & \dots & r_{in} & c_i\\
\cline{4-8}
    \lambda_{i+1,1} & \lambda_{1+2,2} & & \lambda_{i+1,i} & a_{i+1,i+1}^{(i)} & \dots & a_{i+1,n}^{(i)} & b_{i+1}^{(i)}\\
    \vdots & \vdots & & \vdots & \vdots & & \vdots & \vdots \\
    \lambda_{n,1} & \lambda_{n,2} & \dots & \lambda_{n,i} & a_{n,i+1}^{(i)} & \dots & a_{n,n}^{(i)} & b_n^{(i)}\\
%\end{matrix}
\end{array}
\right ]
\]

\end{document}

在此处输入图片描述

一些额外的垂直校正将会很有用。

编辑:这是步骤线的可能含义的逻辑,但是 egreg 建议的生成列的逻辑是一个很好的替代方案。

答案2

使用{bNiceArray}。该环境与经典(包)nicematrix类似,但在单元格、行和列下创建 PGF/Tikz 节点。可以使用这些节点与 Tikz 在环境中绘制您想要的任何规则。{array}array\CodeAfter

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

$\begin{bNiceArray}{ccccccc|c}[margin]
    r_{11} & r_{12} & \dots & r_{1i} & r_{1,i+1} & \dots & r_{1n} & c_1\\
    \lambda_{21} & r_{22} & \dots & r_{2i} & r_{2,i+1} & \dots & r_{2n} & c_2\\
    \lambda_{31} & \lambda_{32} & & r_{3i} & r_{3,i+1} & \dots & r_{3n} & c_3\\
    \vdots & \vdots & \ddots & \vdots & \vdots & & \vdots & \vdots \\
    \lambda_{i1} & \lambda_{i2} & & r_{ii} & r_{i,i+1} & \dots & r_{in} & c_i\\
    \lambda_{i+1,1} & \lambda_{1+2,2} & & \lambda_{i+1,i} & a_{i+1,i+1}^{(i)} & \dots & a_{i+1,n}^{(i)} & b_{i+1}^{(i)}\\
    \vdots & \vdots & & \vdots & \vdots & & \vdots & \vdots \\
   \lambda_{n,1} & \lambda_{n,2} & \dots & \lambda_{n,i} & a_{n,i+1}^{(i)} & \dots & a_{n,n}^{(i)} & b_n^{(i)}\\
\CodeAfter
  \tikz \draw (2-|1) -| (3-|2) -| (4-|3) (5-|4) |- (6-|last) ; 
\end{bNiceArray}$

\end{document}

您需要多次编译(因为 PGF/Tikz 节点)。

上述代码的输出

相关内容