Tikz의 두 노드 사이에 그리기

Tikz의 두 노드 사이에 그리기

노드 사이 중앙에 수평으로 파란색 실선을 그릴 수 없는 이유를 알아내려고 노력하고 있습니다???

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node(X)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=-6cm]
          {\large Input \textcolor{red}{$2$}};%
\node(Y)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=-.5cm]
          {\large $\begin{aligned}[t] g(\textcolor{red} 
    {2})&=\textcolor{red}{2}^{2}+1\\ &=5\end{aligned}$\\ 
    \large The output of $g$, \textcolor{blue}{$5$},is\\ 
    \large the input to $f$};%
\node (Z)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=6cm]
         {\large $\begin{aligned}[t] f(\textcolor{blue} 
     {5})&=4(\textcolor{blue}{5})-3\\ &=17\end{aligned}$};%
\end{tikzpicture}
\end{center}

\begin{tikzpicture}
\draw[blue,thick,-latex] (X.east) to ( Y.west);
\end{tikzpicture}
\end{document}

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

답변1

두 개의 별도 s를 갖고 싶다고 가정하면 각각 및 를 tikzpicture추가해야 합니다 .remember pictureoverlay,remember picture

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{center}
\begin{tikzpicture}[remember picture]
\node(X)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=-6cm]
          {\large Input \textcolor{red}{$2$}};%
\node(Y)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=-.5cm]
          {\large $\begin{aligned}[t] g(\textcolor{red} 
    {2})&=\textcolor{red}{2}^{2}+1\\ &=5\end{aligned}$\\ 
    \large The output of $g$, \textcolor{blue}{$5$},is\\ 
    \large the input to $f$};%
\node (Z)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=6cm]
         {\large $\begin{aligned}[t] f(\textcolor{blue} 
     {5})&=4(\textcolor{blue}{5})-3\\ &=17\end{aligned}$};%
\end{tikzpicture}
\end{center}

\begin{tikzpicture}[overlay,remember picture]
\draw[blue,thick,-latex] (X.east) to ( Y.west);
\end{tikzpicture}
\end{document}

물론 하나만 사용해도 됩니다 tikzpicture.

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node(X)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=-6cm]
          {\large Input \textcolor{red}{$2$}};%
\node(Y)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=-.5cm]
          {\large $\begin{aligned}[t] g(\textcolor{red} 
    {2})&=\textcolor{red}{2}^{2}+1\\ &=5\end{aligned}$\\ 
    \large The output of $g$, \textcolor{blue}{$5$},is\\ 
    \large the input to $f$};%
\node (Z)[draw,rectangle, rounded corners,draw=black, 
          fill=white,align=center,xshift=6cm]
         {\large $\begin{aligned}[t] f(\textcolor{blue} 
     {5})&=4(\textcolor{blue}{5})-3\\ &=17\end{aligned}$};%
\draw[blue,thick,-latex] (X.east) to ( Y.west);  
\end{tikzpicture}
\end{center}

\end{document}

두 코드의 출력은 다음과 같습니다.

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

답변2

슈뢰딩거의 고양이에 대한 답변의 두 번째 예에서 영감을 받았습니다. 라이브러리 chains와 매크로를 사용하여 join모든 노드에 대한 공통 스타일을 배치하고 정의합니다.

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{chains,
                positioning}

\begin{document}
    \begin{center}
\begin{tikzpicture}[
    node distance = 22mm,
      start chain = going right,
       box/.style = {draw, rounded corners, font=\large,
                     align=center, on chain},
every join/.style = {blue,thick,-latex}
              ]
\node (X) [box] {Input \textcolor{red}{$2$}};%
\node (Y) [box, join] 
                {$\begin{aligned}[t] 
                g(\textcolor{red}{2})   & = \textcolor{red}{2}^{2}+1\\ 
                                        & = 5               
                \end{aligned}$\\
                The output of $g$, \textcolor{blue}{$5$}, \\
                is the input to $f$};   
\node (Z) [box] {$\begin{aligned}[t] 
                f(\textcolor{blue}{5})  & = 4(\textcolor{blue}{5})-3\\ 
                                        & = 17
                \end{aligned}$};%
\end{tikzpicture}
    \end{center}
\end{document}

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

관련 정보