행 축소 및 열 수집의 tikz

행 축소 및 열 수집의 tikz

tikz를 사용하여 다음과 같은 다이어그램을 만들고 싶습니다. 여기에 이미지 설명을 입력하세요

두 줄이 있었으면 좋겠어요. 첫 번째 행은 행렬 행 축소이고, 두 번째 행은 첫 번째 행에서 행 축소 행렬의 일부 열을 모으는 것이며 화살표가 연결되어 있습니다(예: 첫 번째 행의 첫 번째 행렬의 첫 번째 열은 L의 첫 번째 열에 연결됩니다). 두 번째 행(나는 이것이 tikz가 필요하다고 가정합니다.) 이것이 라텍스에서 달성 가능한지 궁금합니다. 그렇지 않다면 아마도 이 방정식을 스캔할 것입니다.

샘플 코드는 다음과 같습니다.

  \[
      \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다음은 and 를 사용하는 가능성입니다 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}

여기에 이미지 설명을 입력하세요

관련 정보