
Me gustaría hacer un diagrama usando tikz que se vea así
Me gustaría que tuviera dos filas. La primera fila es la reducción de filas de matrices, y la segunda fila es para reunir algunas columnas de matrices de reducción de filas en la primera fila y tiene flechas que se conectan (por ejemplo, la primera columna de la primera matriz de la primera fila se conecta a la primera columna de L en la segunda fila (supongo que esto necesita tikz). Me pregunto si esto se puede lograr en látex. Si no, probablemente simplemente escanearía esta ecuación.
A continuación se muestra un código de muestra:
\[
\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}
\]
Gracias.
Respuesta1
Aquí hay una posibilidad usando nicematrix
y tikzmark
. Tenga en cuenta que debe compilar 3 veces.
\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}
Respuesta2
Esta solución es sólo una ligera variación de la (muy buena) solución de Sandy G. Muestra cómo es posible obtener el mismo resultado utilizando los nodos creados por nicematrix
(sin 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}
Como es habitual nicematrix
, necesitas varias compilaciones.
Respuesta3
Supongo que estás buscando algo como esto:
\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}
Para obtener más información sobre cómo escribir matemáticas en LaTeX, consultewiki, matemáticas básicas, especialwiki, matemáticas avanzadasy otros textos introductorios.
Editar:
- (Hasta ahora) no proporciona información sobre dónde debe comenzar y terminar la flecha deseada.
- Entonces, a continuación es una locura adivinar lo que buscas.
- Si mi suposición es incorrecta, al menos se da un principio de cómo se pueden dibujar flechas entre los elementos de la ecuación usando
tikzmark
la biblioteca deltikz
paquete.
\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}