TiKz에서 여러 입력을 사용하여 블록 다이어그램을 올바르게 그리는 방법

TiKz에서 여러 입력을 사용하여 블록 다이어그램을 올바르게 그리는 방법

다음 블록 다이어그램을 다시 만들고 싶습니다. 그러나 블록과 화살표를 올바르게 배치하는 방법에 대해서는 여전히 성공하지 못했습니다. 나는 여러 가지를 시도했고 이것이 지금까지 내가 가진 것입니다. 어떤 도움이라도 대단히 감사하겠습니다.

f 및 g 블록 다이어그램

\documentclass{beamer}
\usetheme{Boadilla}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, positioning, calc}

\begin{document}

\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]

\begin{frame}{}

\begin{center}
\begin{tikzpicture}
    \node (input) at (0,0) {$\mathbf{x}$};
    \node [draw, fill=blue!20, rectangle, 
    minimum height=3.0em, minimum width=4.5em, right = 1cm of input, name=f]{$\mathbf{f}$};
    \node [draw, fill=blue!20, rectangle, 
    minimum height=3.0em, minimum width=4.5em, above right = -5mm and 4.5cm of input, name=g]{$\mathbf{g}$};
    \node [output, right = 1cm of g, name=z]{};
    \node [right = 0.1cm of z]{$\mathbf{z}$};
    \node (input) [above left = 0.3cm and 0.6cm of g, name=w]{$\mathbf{w}$};

    % Draw the connecting arrows and labels
    \draw [->, very thick] (input) -- (f);
    \draw [->, very thick] (f) -- (g) node [midway, above] {$\mathbf{y}$};
    \draw [->, very thick] (g) -- (z);
    \draw [->, very thick] (w) -- (g);
\end{tikzpicture}
\end{center}

\end{frame}

\end{document}

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

답변1

다음 솔루션이 귀하에게 적합한지 확인하십시오.

\documentclass[border=3mm,tikz]{standalone}
\usepackage{bm}
\usetikzlibrary{shapes, arrows, positioning, calc}
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{document}
\begin{tikzpicture}
    \node (input) at (0,0) {$\mathbf{x}$};
    \node [draw, fill=blue!20, rectangle, 
    minimum height=3.0em, minimum width=4.5em, right = 1cm of input, name=f]{$\mathbf{f}$};
    \node [draw, fill=blue!20, rectangle, 
    minimum height=3.0em, minimum width=4.5em, right = 4.5cm of input, name=g]{$\mathbf{g}$};
    \node [output, right = 1cm of g, name=z]{};
    \node [right = 0.1cm of z]{$\mathbf{z}$};

    % Draw the connecting arrows and labels
    \draw [->, very thick] (input) -- (f);
    \draw [->, very thick] (f) -- (g) node [midway, below] {$\mathbf{y}$};
    \draw [->, very thick] (g) -- (z);
    \begin{scope}[transform canvas={yshift=+3mm}]
        \draw [->, very thick] ($(f)!0.4!(g)$) -- (g) node [midway, above] {$\mathbf{w}$};
    \end{scope}
\end{tikzpicture}
\end{document}

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

답변2

이와 같이?

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

\documentclass{beamer}
\usetheme{Boadilla}
%\usepackage[utf8]{inputenc}
%\usepackage{amsmath}
\usepackage{bm}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                calc, 
                positioning,
                quotes}

\begin{document}
\begin{frame}
\frametitle{Block diagram}
\begin{center}
    \begin{tikzpicture}[
node distance = 4mm and 16mm,
   arr/.style = {very thick, -Latex},
   box/.style = {draw, semithick, fill=blue!20, 
                 minimum height=3.0em, minimum width=4.5em},
                        ]
\coordinate (in);
\node (f) [box, right=of in]                    {$\bf{f}$};
\node (g) [box, above right=of f.south east]    {$\bf{g}$};
\coordinate[right = of g]    (out);
%
\draw[arr]   (in) to ["$\bm{x}$"]   (f);
\draw[arr]   (f)  to ["$\bm{y}$" '] (f -| g.west);
\draw[arr]   (g)  to ["$\bm{z}$"]   (out);
%  
\coordinate[left=12mm of g.west]     (w);
\draw[arr]   (w)  to ["$\bm{w}$"]   (g);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

답변3

또 다른 대안

\documentclass[border=3mm,tikz]{standalone}
\usepackage{bm}
\usetikzlibrary{arrows, positioning, calc}
\begin{document}
\begin{tikzpicture}[
    box/.style={draw, fill=blue!20, minimum height=3em, minimum width=4.5em},
    link/.style={->,very thick}]
    \node [box] (f) {$\mathbf{f}$};
    \node [box, right=2cm of f] (g) {$\mathbf{g}$};
     \draw[link, <-] (f.west)--++(180:1cm) node[left]{$\mathbf{x}$};
     \draw[link] (f)--($(f)!.5!(g)$) coordinate (aux1)|- node[below, pos=.75]{$\mathbf{y}$}($(g.south west)!.3333!(g.north west)$);
     \coordinate (aux2) at ($(g.north west)!.3333!(g.south west)$);
     \draw[link] (aux1|-aux2) --  node[above]{$\mathbf{w}$} (aux2);
     \draw[link] (g.east)--++(0:1cm) node[right]{$\mathbf{z}$};
     \end{tikzpicture}
\end{document}

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

답변4

다른 것

\documentclass{beamer}
\usetheme{Boadilla}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, positioning, calc}

\begin{document}

\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]

\begin{frame}{}

\begin{center}
\begin{tikzpicture}
    \node (input) at (0,0) {$\mathbf{x}$};
    \node [draw, fill=blue!20, rectangle, 
    minimum height=3.0em, minimum width=4.5em, right = 1cm of input, name=f]{$\mathbf{f}$};
    \node [draw, fill=blue!20, rectangle, 
    minimum height=3.0em, minimum width=4.5em, above right = -5mm and 4.5cm of input, name=g]{$\mathbf{g}$};
    \node [output, right = 1cm of g, name=z]{};
    \node [right = 0.1cm of z]{$\mathbf{z}$};
    \node (input) [above left = 0.3cm and 0.6cm of g, name=w]{$\mathbf{w}$};

    % Draw the connecting arrows and labels
    \draw [->, very thick] (input) -- (f);
    \draw [->, very thick] (f) -|($(f)!0.5!(g.190)$) |- (g.190) node [pos=0.2, below] {$\mathbf{y}$}; %modif1
    \draw [->, very thick] (g) -- (z);
    \draw [->, very thick] (w) |- (g.160);  %modif2
\end{tikzpicture}
\end{center}

\end{frame}

\end{document}

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

관련 정보