![如何使矩阵始终看起来保持不变?](https://linux22.com/image/415276/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%9F%A9%E9%98%B5%E5%A7%8B%E7%BB%88%E7%9C%8B%E8%B5%B7%E6%9D%A5%E4%BF%9D%E6%8C%81%E4%B8%8D%E5%8F%98%EF%BC%9F.png)
我试图让以下矩阵始终看起来不变,即不改变其大小。第三个矩阵有问题。
您建议我用什么来代替或者改变它?
First, we write this system using matrices.
\[
\left[
\begin{array}{ccc|c}
1 & 2 & 3 & 4\\
7 & 5 & 3 & 1\\
-2 & -3 & -4 & -5\\
\end{array}
\right]
\]
We preform $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} - 7\mathbf{R_{1}}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} + 2\mathbf{R_{1}}$
\[
\left[
\begin{array}{ccc|c}
1 & 2 & 3 & 4\\
0 & -9 & -18 & -27\\
0 & 1 & 2 & 3\\
\end{array}
\right]
\]
Next we $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} \times -\frac{1}{9}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} - \mathbf{R_{2}}$, for final
\[
\left[
\begin{array}{ccc|c}
1 & 2 & 3 & 4\\
0 & 1 & 2 & 3\\
0 & 0 & 0 & 0\\
\end{array}
\right]
\]
答案1
该包nicematrix
可以为您计算文档部分中所有矩阵的最宽条目的宽度,并将该宽度分配给所有列。
为此,您必须使用{NiceMatrixBlock}
带有密钥的环境auto-columns-width
。
您需要多次编译。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
First, we write this system using matrices.
\begin{NiceMatrixBlock}[auto-columns-width]
\[
\begin{bNiceArray}{rrr|r}
1 & 2 & 3 & 4\\
7 & 5 & 3 & 1\\
-2 & -3 & -4 & -5\\
\end{bNiceArray}
\]
We preform $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} - 7\mathbf{R_{1}}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} + 2\mathbf{R_{1}}$
\[
\begin{bNiceArray}{rrr|r}
1 & 2 & 3 & 4\\
0 & -9 & -18 & -27\\
0 & 1 & 2 & 3\\
\end{bNiceArray}
\]
Next we $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} \times -\frac{1}{9}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} - \mathbf{R_{2}}$, for final
\[
\begin{bNiceArray}{rrr|r}
1 & 2 & 3 & 4\\
0 & 1 & 2 & 3\\
0 & 0 & 0 & 0\\
\end{bNiceArray}
\]
\end{NiceMatrixBlock}
\end{document}
答案2
nicematrix
允许您设置列宽。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
First, we write this system using matrices.
\[
\begin{bNiceArray}[columns-width = 2em]{RRR|R}
1 & 2 & 3 & 4\\
7 & 5 & 3 & 1\\
-2 & -3 & -4 & -5\\
\end{bNiceArray}
\]
We preform $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} - 7\mathbf{R_{1}}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} + 2\mathbf{R_{1}}$
\[
\begin{bNiceArray}[columns-width = 2em]{RRR|R}
1 & 2 & 3 & 4\\
0 & -9 & -18 & -27\\
0 & 1 & 2 & 3\\
\end{bNiceArray}
\]
Next we $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} \times -\frac{1}{9}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} - \mathbf{R_{2}}$, for final
\[
\begin{bNiceArray}[columns-width = 2em]{RRR|R}
1 & 2 & 3 & 4\\
0 & 1 & 2 & 3\\
0 & 0 & 0 & 0\\
\end{bNiceArray}
\]
\end{document}
您还可以测量最宽的入口并使用其宽度。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\setbox0\hbox{$-27$}%
\edef\mywd{\the\wd0}%
First, we write this system using matrices.
\[
\begin{bNiceArray}[columns-width=\mywd]{RRR|R}
1 & 2 & 3 & 4\\
7 & 5 & 3 & 1\\
-2 & -3 & -4 & -5\\
\end{bNiceArray}
\]
We preform $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} - 7\mathbf{R_{1}}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} + 2\mathbf{R_{1}}$
\[
\begin{bNiceArray}[columns-width=\mywd]{RRR|R}
1 & 2 & 3 & 4\\
0 & -9 & -18 & -27\\
0 & 1 & 2 & 3\\
\end{bNiceArray}
\]
Next we $\mathbf{R_{2}} \rightarrow \mathbf{R_{2}} \times -\frac{1}{9}$ and $\mathbf{R_{3}} \rightarrow \mathbf{R_{3}} - \mathbf{R_{2}}$, for final
\[
\begin{bNiceArray}[columns-width=\mywd]{RRR|R}
1 & 2 & 3 & 4\\
0 & 1 & 2 & 3\\
0 & 0 & 0 & 0\\
\end{bNiceArray}
\]
\end{document}
答案3
下面我将其定义gaussmat
为一个类似矩阵的构造/环境,它设置了一个 3 x 3 高斯消元矩阵。列条目都相同,捕获其参数并将其传递给来自的测量方案eqparbox
。这将找到列条目的最宽长度,从而创建所有列的统一外观。gaussmat
如果需要,可选参数允许您使用不同的标签重置测量值。
\documentclass{article}
\usepackage{mleftright,eqparbox,collcell}
\newcolumntype{R}{>{\collectcell\matcell}r<{\endcollectcell}}
\newcommand{\matcell}[1]{\eqmakebox[\matcelllabel][r]{$#1$}}
\newenvironment{gaussmat}[1][cw]{%
\def\matcelllabel{#1}%
\mleft[\begin{array}{ R R R | R }
}{%
\end{array}\mright]
}
\begin{document}
First, we write this system using matrices:
\[
\begin{gaussmat}
1 & 2 & 3 & 4 \\
7 & 5 & 3 & 1 \\
-2 & -3 & -4 & -5 \\
\end{gaussmat}
\]
We preform $\mathbf{R_2} \rightarrow \mathbf{R_2} - 7\mathbf{R_1}$ and $\mathbf{R_3} \rightarrow \mathbf{R_3} + 2\mathbf{R_1}$:
\[
\begin{gaussmat}
1 & 2 & 3 & 4 \\
0 & -9 & -18 & -27 \\
0 & 1 & 2 & 3 \\
\end{gaussmat}
\]
Next we $\mathbf{R_2} \rightarrow \mathbf{R_2} \times -\frac{1}{9}$ and $\mathbf{R_3} \rightarrow \mathbf{R_3} - \mathbf{R_2}$:
\[
\begin{gaussmat}
1 & 2 & 3 & 4 \\
0 & 1 & 2 & 3 \\
0 & 0 & 0 & 0 \\
\end{gaussmat}
\]
\end{document}
对于 中最宽元素的每次更改,您都需要至少编译两次gaussmat
。