我有以下矩阵,我想让它们更美观地对齐。有人能推荐一个好方法吗?
$
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
-1 & 2 & 0 & 4z-5 \\
1 & 0 & -1 & z-3 \\
1 & 2 & 0 & 8z-7
\end{matrix}\right]
R_2-(-1)R_1->R_2
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 3 & 1 & 10z-7 \\
1 & 0 & -1 & z-3 \\
1 & 2 & 0 & 8z-7
\end{matrix}\right]
R_3-1R_1->R_3
$ \bigskip
$
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 3 & 1 & 10z-7 \\
0 & -1 & -2 & -5z-1 \\
1 & 2 & 0 & 8z-7
\end{matrix}\right]
R_4-1R_1->R_4
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 3 & 1 & 10z-7 \\
0 & -1 & -2 & -5z-1 \\
0 & 1 & -1 & 2z-5
\end{matrix}\right]
R_2/(3)->R_2
$ \bigskip
$
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 1 & \frac{1}{3} & \frac{10z-7}{3} \\
0 & -1 & -2 & -5z-1 \\
0 & 1 & -1 & 2z-5
\end{matrix}\right]
R_3-(-1)R_2->R_3
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 1 & \frac{1}{3} & \frac{10z-7}{3} \\
0 & 0 & \frac{-5}{3} & \frac{-5z-10}{3} \\
0 & 1 & -1 & 2z-5
\end{matrix}\right]
R_4-1R_2->R_4
$ \bigskip
$
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 1 & \frac{1}{3} & \frac{10z-7}{3} \\
0 & 0 & \frac{-5}{3} & \frac{-5z-10}{3} \\
0 & 0 & \frac{-4}{3} & \frac{-4z-8}{3}
\end{matrix}\right]
R_3/((-5)/3)->R_3
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 1 & \frac{1}{3} & \frac{10z-7}{3} \\
0 & 0 & 1 & z+2 \\
0 & 0 & \frac{-4}{3} & \frac{-4z-8}{3}
\end{matrix}\right]
R_4-((-4)/3)R_3->R_4
$ \bigskip
$
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 1 & \frac{1}{3} & \frac{10z-7}{3} \\
0 & 0 & 1 & z+2 \\
0 & 0 & 0 & 0
\end{matrix}\right]
R_2-(1/3)R_3->R_2
\left[\begin{matrix}
1 & 1 & 1 & 6z-2 \\
0 & 1 & 0 & 3z-3 \\
0 & 0 & 1 & z+2 \\
0 & 0 & 0 & 0
\end{matrix}\right]
R_1-1R_3->R_1
$ \bigskip
$
\left[\begin{matrix}
1 & 1 & 0 & 5z-4 \\
0 & 1 & 0 & 3z-3 \\
0 & 0 & 1 & z+2 \\
0 & 0 & 0 & 0
\end{matrix}\right]
R_1-1R_2->R_1
\left[\begin{matrix}
1 & 0 & 0 & 2z-1 \\
0 & 1 & 0 & 3z-3 \\
0 & 0 & 1 & z+2 \\
0 & 0 & 0 & 0
\end{matrix}\right]
$
$
\left[\begin{matrix}
x_1 & = & 2z-1 \\
x_2 & = & 3z-3 \\
x_3 & = & z+2
\end{matrix}\right]
$
答案1
我想我会使用nicematrix
包:https://ctan.org/pkg/nicematrix。您可以看到矩阵都是相同的。在每一行上,您可以按行和列进行转换,就像我向您展示的最小示例一样。我不知道这是否符合您所寻找的内容。
\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{nicematrix}
\usepackage[left=.1in, right=.5in]{geometry}
\begin{document}
\[
\begin{matrix}
\begin{bNiceArrayC}{CCCC}
1 & 1 & 1 & 6z-2 & \\
-1 & 2 & 0 & 4z-5 & R_2-(-1)R_1\rightarrow R_2 \\
1 & 0 & -1 & z-3 & \\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} & \hspace{4cm} \begin{bNiceArrayC}{CCCC}
1 & 1 & 1 & 6z-2 & \\
0 & 3 & 1 & 10z-7 & \\
1 & 0 & -1 & z-3 & R_3-1R_1\rightarrow R_3\\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} \\[2cm]
\begin{bNiceArrayC}{CCCC}
1 & 1 & 1 & 6z-2 & \\
-1 & 2 & 0 & 4z-5 & R_2-(-1)R_1\rightarrow R_2 \\
1 & 0 & -1 & z-3 & \\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} & \hspace{4cm} \begin{bNiceArrayC}{CCCC}
1 & 1 & 1 & 6z-2 & \\
0 & 3 & 1 & 10z-7 & \\
1 & 0 & -1 & z-3 & R_3-1R_1\rightarrow R_3\\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} \\[2cm]
\begin{bNiceArrayC}{CCCC}
1 & 1 & 1 & 6z-2 & \\
-1 & 2 & 0 & 4z-5 & R_2-(-1)R_1\rightarrow R_2 \\
1 & 0 & -1 & z-3 & \\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} & \hspace{4cm} \begin{bNiceArrayC}{CCCC}
1 & 1 & 1 & 6z-2 & \\
0 & 3 & 1 & 10z-7 & \\
1 & 0 & -1 & z-3 & R_3-1R_1\rightarrow R_3\\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} \\
\end{matrix}
\]
\end{document}
或者您可以使用矩阵调整此代码:
\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{nicematrix}
\usepackage[left=.1in, right=.5in]{geometry}
\begin{document}
\[
\begin{matrix}
\begin{bNiceArrayC}{CCC|C}
1 & 1 & 1 & 6z-2 & \\
-1 & 2 & 0 & 4z-5 & R_2-(-1)R_1\rightarrow R_2 \\
1 & 0 & -1 & z-3 & \\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} & \hspace{4cm} \begin{bNiceArrayC}{CCC|C}
1 & 1 & 1 & 6z-2 & \\
0 & 3 & 1 & 10z-7 & \\
1 & 0 & -1 & z-3 & R_3-1R_1\rightarrow R_3\\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} \\[2cm]
\begin{bNiceArrayC}{CCC|C}
1 & 1 & 1 & 6z-2 & \\
-1 & 2 & 0 & 4z-5 & R_2-(-1)R_1\rightarrow R_2 \\
1 & 0 & -1 & z-3 & \\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} & \hspace{4cm} \begin{bNiceArrayC}{CCC|C}
1 & 1 & 1 & 6z-2 & \\
0 & 3 & 1 & 10z-7 & \\
1 & 0 & -1 & z-3 & R_3-1R_1\rightarrow R_3\\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} \\[2cm]
\begin{bNiceArrayC}{CCC|C}
1 & 1 & 1 & 6z-2 & \\
-1 & 2 & 0 & 4z-5 & R_2-(-1)R_1\rightarrow R_2 \\
1 & 0 & -1 & z-3 & \\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} & \hspace{4cm} \begin{bNiceArrayC}{CCC|C}
1 & 1 & 1 & 6z-2 & \\
0 & 3 & 1 & 10z-7 & \\
1 & 0 & -1 & z-3 & R_3-1R_1\rightarrow R_3\\
1 & 2 & 0 & 8z-7 & \\
\end{bNiceArrayC} \\
\end{matrix}
\]
\end{document}
答案2
这是一个 Ti钾Z解决方案:
\documentclass{article}
\usepackage{amsmath,showframe}
\usepackage{mathtools} % for mathmakebox
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
% Having all the cells to be equal in width is taken from Gonzalo Medina:
% https://tex.stackexchange.com/a/191240/167081
% The next is used to make the arrow fit the longest formula width.
% Copied from: Stefan Kottwitz, https://tex.stackexchange.com/a/6840/167081
\newlength{\arrow}
\settowidth{\arrow}{\tiny$R_4-(\frac{-4}{3})R_3$}% Longest formula
\newcommand*{\matrixArrow}[1]{\xrightarrow{\mathmakebox[\arrow]{#1}}}
\newcommand\mymatrix[3]{%
\noindent
\begin{tikzpicture}
\matrix[ampersand replacement=\&,matrix of math nodes,left delimiter = {[},
right delimiter ={]}, inner xsep=0pt,inner ysep=3pt, outer xsep=0pt,
align = center,font=\footnotesize,
every node/.style={anchor=base,text depth=.5ex,text height=2ex,text width=2.6em},
nodes={execute at begin node=$, execute at end node=$}] (m){#1};
\node[right=0.5ex of m] (b) {$\matrixArrow{\textcolor{red}{#2}#3}$};
\end{tikzpicture}
}
\begin{document}
% How to use:
% Place the matrix (delimited by \&) in the first argument.
% Place the row that will be changed in the second (to be shown in red).
% Place rest of the formula of the row reduction in the 3rd and last arugment.
% Row 1
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
-1 \& 2 \& 0 \& 4z - 5 \\
1 \& 0 \& -1 \& z - 3 \\
1 \& 2 \& 0 \& 8z - 7 \\
}{R_2}{- (-1)R_1}
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 3 \& 1 \& 10z - 7 \\
1 \& 0 \& -1 \& z - 3 \\
1 \& 2 \& 0 \& 8z - 7 \\
}{R_3}{- 1R_1}\\[2ex]
% Row 2
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 3 \& 1 \& 10z - 7 \\
0 \& -1 \& -2 \& -5z - 1 \\
1 \& 2 \& 0 \& 8z - 7 \\
}{R_4}{- R_1}
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 3 \& 1 \& 10z - 7 \\
0 \& -1 \& -2 \& -5z - 1 \\
0 \& 1 \& -1 \& 2z - 5 \\
}{R_2}{/3}\\[2ex]
% Row 3
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 1 \& \frac{1}{3} \& \frac{10z-7}{3} \\
0 \& -1 \& -2 \& -5z - 1 \\
0 \& 1 \& -1 \& 2z - 5 \\
}{R_3}{-(-1)R_2}
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 1 \& \frac{1}{3} \& \frac{10z-7}{3} \\
0 \& 0 \& \frac{-5}{3} \& \frac{-5z-10}{3} \\
0 \& 1 \& -1 \& 2z - 5 \\
}{R_4}{-1R_2}\\[2ex]
% Row 4
\mymatrix{
1 \& 1 \& 1 \& 6z-2 \\
0 \& 1 \& \frac{1}{3} \& \frac{10z-7}{3} \\
0 \& 0 \& \frac{-5}{3} \& \frac{-5z-10}{3} \\
0 \& 0 \& \frac{-4}{3} \& \frac{-4z-8}{3} \\
}{R_3}{/(\frac{-5}{3})}
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 1 \& \frac{1}{3} \& \frac{10z-7}{3} \\
0 \& 0 \& \frac{-5}{3} \& \frac{-5z-10}{3} \\
0 \& 1 \& -1 \& 2z - 5 \\
}{R_4}{-(\frac{-4}{3})R_3}\\[2ex]
% Row 5
\mymatrix{
1 \& 1 \& 1 \& 6z - 2 \\
0 \& 1 \& \frac{1}{3} \& \frac{10z-7}{3} \\
0 \& 0 \& 1 \& z + 2 \\
0 \& 0 \& 0 \& 0 \\
}{R_1}{-1R_3}
\mymatrix{
1 \& 1 \& 0 \& 5z - 4 \\
0 \& 1 \& 0 \& 3z - 3 \\
0 \& 0 \& 1 \& z + 2 \\
0 \& 0 \& 0 \& 0 \\
}{R_1}{-1R_2}\\[2ex]
% Row 6 One matrix only
\[
\begin{matrix}
x_1 & = & 2z-1 \\
x_2 & = & 3z-3 \\
x_3 & = & z+2
\end{matrix}
\]
\end{document}