tikz in Zeilenreduzierung und Spalten sammeln

tikz in Zeilenreduzierung und Spalten sammeln

Ich möchte mit Tikz ein Diagramm erstellen, das so aussieht Bildbeschreibung hier eingeben

Ich hätte gerne zwei Zeilen. Die erste Zeile ist eine Matrixzeilenreduktion, und die zweite Zeile dient zum Sammeln einiger Spalten von Zeilenreduktionsmatrizen in der ersten Zeile und hat verbindende Pfeile (z. B. verbindet die erste Spalte in der ersten Matrix in der ersten Zeile die erste Spalte von L in der zweiten Zeile (ich nehme an, dafür ist Tikz erforderlich). Ich frage mich, ob dies in Latex möglich ist. Wenn nicht, würde ich diese Gleichung wahrscheinlich einfach überfliegen.

Nachfolgend ist ein Beispielcode aufgeführt:

  \[
      \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}
  \]

Danke.

Antwort1

Hier ist eine Möglichkeit mit nicematrixund tikzmark. Beachten Sie, dass Sie 3 mal kompilieren müssen.

Bildbeschreibung hier eingeben

\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}

Antwort2

Diese Lösung ist nur eine leichte Abwandlung der (sehr guten) Lösung von Sandy G. Sie zeigt, wie es möglich ist, durch Verwendung der von nicematrix(ohne tikzmark) erstellten Knoten dasselbe Ergebnis zu erzielen.

\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}

Wie bei üblich nicematrix, sind mehrere Zusammenstellungen erforderlich.

Ausgabe des obigen Codes

Antwort3

Ich vermute, dass Sie nach so etwas suchen:

Bildbeschreibung hier eingeben

\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}

Weitere Informationen zum Schreiben von Mathematik in LaTeX finden Sie unterWiki, grundlegende Mathematik, besondersWiki, Höhere Mathematikund andere Einführungstexte.

Bearbeiten:

  • Sie machen (bisher) keine Angaben dazu, wo Ihr gewünschter Pfeil beginnen und enden soll.
  • Nachfolgend finden Sie eine wilde Vermutung, wonach Sie suchen.
  • Wenn meine Vermutung falsch ist, wird zumindest ein Prinzip vermittelt, wie man mithilfe tikzmarkder Paketbibliothek Pfeile zwischen Gleichungselementen zeichnen kann 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}

Bildbeschreibung hier eingeben

verwandte Informationen