
2 行にしたいと思います。最初の行は行列の行削減で、2 行目は最初の行の行削減行列のいくつかの列を収集し、矢印で接続します (例: 最初の行の最初の行列の最初の列は、2 行目の L の最初の列に接続します (これには tikz が必要だと思います))。これは LaTeX で実現できるかどうか疑問です。そうでない場合は、おそらくこの方程式をスキャンするだけです。
サンプルコードを以下に示します。
\[
\begin{pmatrix}
2 & 4 & -1 & 5 & -2 \\
-4 & -5 & 3 & 8 & 1 \\
2 & -5 & -4 & 1 & 8 \\
-6 & 0 & 7 & -3 & 1
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & & \\
& 3 & & \\
& -9 & & \\
& 12 & &
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & 4 & 7
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & & 5
\end{pmatrix}
= U
\]
%%%% how to add arrows between the two rows?
\[
L = \begin{pmatrix}
1 & 0 & 0 & 0 \\
-2 & 1 & 0 & 0 \\
1 & -3 & 1 & 0 \\
3 & 4 & 2 & 1 \\
\end{pmatrix}
\]
ありがとう。
答え1
nicematrix
ここではと を使用する可能性がありますtikzmark
。3 回コンパイルする必要があることに注意してください。
\documentclass{article}
\usepackage{amsmath, nicematrix, tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[
\begin{pNiceMatrix}[left-margin=.5em]
\Block[tikz={draw, thick, dashed, red}]{4-1}{}2 & 4 & -1 & 5 & -2 \\
-4 & -5 & 3 & 8 & 1 \\
2 & -5 & -4 & 1 & 8 \\
\tikzmarknode{a1}{-6} & 0 & 7 & -3 & 1
\end{pNiceMatrix}
\sim
\begin{pNiceMatrix}
2 & 4 & & \\
& \Block[tikz={draw, thick, dashed, red}]{3-1}{}3 & & \\
& -9 & & \\
& \tikzmarknode{a2}{12} & &
\end{pNiceMatrix}
\sim
\begin{pNiceMatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & \Block[tikz={draw, thick, dashed, red}]{2-1}{}2 & 1 \\
& & & \tikzmarknode{a3}{4} & 7
\end{pNiceMatrix}
\sim
\begin{pNiceMatrix}[right-margin=.5em]
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & & \Block[tikz={draw, thick, dashed,red}]{1-1}{}\tikzmarknode{a4}{5}
\end{pNiceMatrix}
= U
\]
\vspace{1cm}
\[
L = \begin{pNiceMatrix}
\tikzmarknode{b1}{1} & \tikzmarknode{b2}{0} & \tikzmarknode{b3}{0} & \tikzmarknode{b4}{0} \\
-2 & 1 & 0 & 0 \\
1 & -3 & 1 & 0 \\
3 & 4 & 2 & 1 \\
\end{pNiceMatrix}
\]
\begin{tikzpicture}[remember picture, overlay]
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](a1) to[out=south, in=north] (b1);
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](a2) to[out=south, in=north] (b2);
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](a3.west) to[out=west, in=north] (b3);
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](a4) to[out=south, in=north] (b4);
\end{tikzpicture}
\end{document}
答え2
nicematrix
このソリューションは、Sandy G の (非常に優れた) ソリューションのわずかなバリエーションにすぎません。 ( なしtikzmark
)で作成されたノードを使用して、同じ出力を取得する方法を示しています。
\documentclass{article}
\usepackage{nicematrix, tikz}
\begin{document}
\[
\begin{pNiceMatrix}[left-margin=.5em,name=A1]
\Block[tikz={draw, thick, dashed, red}]{4-1}{}2 & 4 & -1 & 5 & -2 \\
-4 & -5 & 3 & 8 & 1 \\
2 & -5 & -4 & 1 & 8 \\
-6 & 0 & 7 & -3 & 1
\end{pNiceMatrix}
\sim
\begin{pNiceMatrix}[name=A2]
2 & 4 & & \\
& \Block[tikz={draw, thick, dashed, red}]{3-1}{}3 & & \\
& -9 & & \\
& 12 & &
\end{pNiceMatrix}
\sim
\begin{pNiceMatrix}[name=A3]
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & \Block[tikz={draw, thick, dashed, red}]{2-1}{} 2 & 1 \\
& & & 4 & 7
\end{pNiceMatrix}
\sim
\begin{pNiceMatrix}[right-margin=.5em,name=A4]
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & & \Block[tikz={draw, thick, dashed,red}]{1-1}{} 5
\end{pNiceMatrix}
= U
\]
\vspace{1cm}
\[
L = \begin{pNiceMatrix}[name=B]
1 & 0 & 0 & 0 \\
-2 & 1 & 0 & 0 \\
1 & -3 & 1 & 0 \\
3 & 4 & 2 & 1 \\
\end{pNiceMatrix}
\]
\begin{tikzpicture}[remember picture, overlay]
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](A1-4-1) to[out=south, in=north] (B-1-1);
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](A2-4-2) to[out=south, in=north] (B-1-2);
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](A3-4-4.west) to[out=west, in=north] (B-1-3);
\draw[red, ->, shorten <=1.5mm, shorten >=1mm](A4-4-5) to[out=south, in=north] (B-1-4);
\end{tikzpicture}
\end{document}
通常の と同様にnicematrix
、複数のコンパイルが必要です。
答え3
次のようなものを探しているのではないでしょうか:
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\lipsum[66]
\begin{gather*}
\begin{multlined}
\begin{pmatrix}
2 & 4 & -1 & 5 & -2 \\
-4 & -5 & 3 & 8 & 1 \\
2 & -5 & -4 & 1 & 8 \\
-6 & 0 & 7 & -3 & 1
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & \\
& 3 & \\
& -9 & \\
& 12 &
\end{pmatrix} \\ % <---
\sim
\begin{pmatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & 4 & 7
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & & 5
\end{pmatrix} = U
\end{multlined} \\ % <---
%
L = \begin{pmatrix}
1 & 0 & 0 & 0 \\
-2 & 1 & 0 & 0 \\
1 & -3 & 1 & 0 \\
3 & 4 & 2 & 1 \\
\end{pmatrix}
\end{gather*}
\end{document}
LaTeXで数式を書く方法の詳細については、ウィキ、基本的な数学、特別なウィキ、高度な数学その他の入門テキスト。
編集:
- (今のところ)希望する矢印の開始位置と終了位置に関する情報が提供されていません。
- だから、以下はあなたが何を求めているかを推測するだけです
- 私の推測が間違っていたとしても、少なくともパッケージ
tikzmark
のライブラリを使用して方程式の要素間に矢印を描く方法の原理は示されていますtikz
。
\documentclass{article}
\usepackage{lipsum}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
fit,
tikzmark} % <---
\tikzset{FIT/.style = {fit=#1, node contents={},
draw=red, rounded corners, thick,
inner sep=1pt}
}
\begin{document}
\lipsum[66]
\begin{gather*}
\begin{multlined}
\begin{pmatrix}
\tikzmarknode{a}{2}
& 4 & -1 & 5 & -2 \\
-4 & -5 & 3 & 8 & 1 \\
2 & -5 & -4 & 1 & 8 \\
\tikzmarknode{b}{-6}
& 0 & 7 & -3 & 1
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & \\
& 3 & \\
& -9 & \\
& 12 &
\end{pmatrix} \\ % <---
\sim
\begin{pmatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & 4 & 7
\end{pmatrix}
\sim
\begin{pmatrix}
2 & 4 & -1 & 5 & 2 \\
& 3 & 1 & 2 & -3 \\
& & & 2 & 1 \\
& & & & 5
\end{pmatrix} = U
\end{multlined} \\ % <---
%
L = \begin{pmatrix}
\tikzmarknode{c}{1}
~ & 0 & 0 & 0 \\
\tikzmarknode{d}{-2}
& 1 & 0 & 0 \\
1 & -3 & 1 & 0 \\
\tikzmarknode{e}{3}
& 4 & 2 & 1 \\
\end{pmatrix}
%
\begin{tikzpicture}[overlay, remember picture]
\node (A) [FIT=(a) (b)];
\node (B) [FIT=(c) (d) (e)];
\draw[red!50,ultra thick, -{Stealth[scale=0.8]}] (A) -- (B);
\end{tikzpicture}
\end{gather*}
\lipsum[66]
\end{document}