이 다이어그램 블록을 수정하는 방법은 무엇입니까?

이 다이어그램 블록을 수정하는 방법은 무엇입니까?

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

\tikzstyle{block} = [draw, fill=blue!20, rectangle, 
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controller};
\node [block, right of=controller, pin={[pinstyle]above:Disturbances},
node distance=3cm] (system) {System};
% We draw an edge between the controller and system block to 
% calculate the coordinate u. We need it to place the measurement block. 
\draw [->] (controller) -- node[name=u] {$u$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=system] (measurements) {Measurements};
\node [block, left of=measurements ] (sensor) {Sensor};
\draw [<-] (measurements) -- node[name=k] {$k$} (sensor);
% Once the nodes are placed, connecting them is easy. 
\draw [draw,->] (input) -- node {$r$} (sum);
\draw [->] (sum) -- node {$e$} (controller);
\draw [->] (system) -- node [name=y] {$y$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (sensor) -| node[pos=0.99] {$-$} 
node [near end] {$y_m$} (sum);
\end{tikzpicture}

답변1

left of=measurements로 교체하세요 below=of controller.

세 가지 사소한 참고사항:

  • left of, etc 키 right of는 더 이상 사용되지 않습니다. 이제 등 left=of ...대신 사용하는 것이 좋습니다 left of=.... 이를 위해서는 \usetikzlibrary{positioning}. 이 변화는 글자를 바꾸는 것 이상입니다. 새로운 포지셔닝은 이전 방식보다 더 강력하고 유연합니다.

  • 대신에 block/.style = {...}(에 대한 옵션 tikzpicture또는 인수로 ) 쓸 수 있습니다 . 제가 이해한 바로는 (아래에서도 사용한) 첫 번째 방법이 현재 tikz 규칙에 더 부합합니다. 두 번째 방법은 tikz의 다른 곳에서는 사용되지 않는 다소 특이한 구문입니다.\tikzset\tikzstyle{block} = [...]

  • Zarko가 주석에서 언급했듯이 노드 거리는 eg 를 지정하여 x 및 y 방향에서 다르게 선택할 수 있습니다 node distance=1cm and 2cm.

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

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\tikzset
  {block/.style =
    {draw, fill=blue!20, rectangle, minimum height=3em, minimum width=6em},
   sum/.style = {draw, fill=blue!20, circle, node distance=1cm},
   input/.style = {coordinate},
   output/.style = {coordinate},
   pinstyle/.style = {pin edge={to-,thin,black}}
  }

\begin{document}
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=1cm and 2cm,>=latex']
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right=of input] (sum) {};
\node [block, right=of sum] (controller) {Controller};
\node [block, right=of controller, pin={[pinstyle]above:Disturbances},
node distance=3cm] (system) {System};
% We draw an edge between the controller and system block to 
% calculate the coordinate u. We need it to place the measurement block. 
\draw [->] (controller) -- node[name=u] {$u$} (system);
\node [output, right=of system] (output) {};
\node [block, below=of system] (measurements) {Measurements};
\node [block, below=of controller] (sensor) {Sensor};
\draw [<-] (measurements) -- node[name=k] {$k$} (sensor);
% Once the nodes are placed, connecting them is easy. 
\draw [draw,->] (input) -- node {$r$} (sum);
\draw [->] (sum) -- node {$e$} (controller);
\draw [->] (system) -- node [name=y] {$y$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (sensor) -| node[pos=0.99] {$-$} 
node [near end] {$y_m$} (sum);
\end{tikzpicture}
\end{document}

답변2

보충으로게르노(아니요) "자세한" 답변이 더 간결해지기를 바랍니다. :) 여기서는 다음을 사용 calc하고 quotes라이브러리를 사용합니다.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, calc, positioning, quotes}
\tikzset{
     block/.style = {rectangle, draw, fill=blue!20, minimum height=3em, minimum width=6em},
       sum/.style = {circle, draw, fill=blue!20},
 every pin/.style = {pin edge={<-,black}},
                > = latex'
        }

\begin{document}
    \begin{tikzpicture}[auto, 
    node distance = 6mm and 12mm]
% placing the blocks
\coordinate (in);
\node (sum)             [sum, right=of in] {};
\node (controller)      [block, right=of sum]           {Controller};
\node (system)          [block, pin=above:Disturbances, 
                         right=of controller]           {System};
\coordinate[right=of system] (out);
\node (measurement)     [block, below=of controller]    {Measurements};
\node (sensor)          [block, below=of system]        {Sensor};
% edges between blocks
\draw[->]   (in)            edge ["$r$"] (sum)
            (sum)           edge ["$e$"] (controller)
            (controller)    edge["$u$"]  (system)
            (system)        edge["$y$"]  (out)
            (sensor)        edge["$k$"] (measurement)
            (measurement)   -|  (sum)
                            node [pos=0.75] {$y_m$}
                            node [pos=0.95] {$-$};
\draw[->]   ($(system.east)!0.5!(out)$) |- (sensor);
\end{tikzpicture}
\end{document}

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

편집하다:변화를 고려하다자동차LaTeX댓글, 코드의 댓글이 이제 더 의미가 있습니다. 나는 여전히 내가 제안한 "센서" 및 "측정" 블록 순서가 정확하다고 믿습니다. 그러나 이러한 블록이 선형이 될 때까지 순서는 중요하지 않습니다. :)

답변3

TikZ를 사용할 수도 있다고 생각합니다 matrix.

라이브러리 는 arrows더 이상 사용되지 않습니다. TikZ & PGF 매뉴얼에서 para. 16.1:

비고: 라이브러리 arrows 및 arrows.spaced는 더 이상 사용되지 않습니다. 대신/추가로 arrows.meta를 사용하면 기존 라이브러리가 제공하는 모든 기능과 그 이상을 수행할 수 있습니다. 그러나 이전 라이브러리는 여전히 작동하며 이전 화살표 팁과 새 화살표 팁을 혼합할 수도 있습니다. 단, 이전 화살표 팁은 이 섹션의 나머지 부분에 설명된 방식으로 구성할 수 없습니다. 라텍스 화살표에 대해 scale=2를 지정하는 것은 효과가 없습니다. 예를 들어 라텍스 화살의 경우 예상대로 크기가 두 배로 늘어납니다.)

게다가, gernot이 이미 말했듯이, \tikzset대신에 \tikzstyle(참조:여기).

\documentclass{book}
\usepackage{tikz}   
\usetikzlibrary{arrows.meta,matrix,positioning}

\begin{document}

\tikzset{%
    block/.style={draw, fill=blue!20, rectangle, 
    minimum height=3em, text width=7em,align=center},
    sum/.style={draw, fill=blue!20, circle},
    pinstyle/.style={pin edge={latex-,thin,black}},
    mylabup/.style={midway,above},
    >=latex,
    }   
\begin{tikzpicture}
    \matrix[column sep=3em, row sep=4ex]{%
    \coordinate (input);
    &
    \node [sum] (sum) {};
    &
    \node [block] (controller) {Controller};
    &
    \node [block, pin={[pinstyle]above:Disturbances}] (system) {System};
    &
    \coordinate (output);
\\
    &
    &
    \node [block] (sensor) {Sensor};
    &
    \node [block] (measurements) {Measurements};
    \\
    };
    \draw [->] (controller) -- node[mylabup] {$u$} (system);
    \draw [->] (measurements) -- node[mylabup] {$k$} (sensor);
    \draw [->] (input) -- node[mylabup] {$r$} (sum);
    \draw [->] (sum) -- node[mylabup] {$e$} (controller);
    \draw [->] (system) -- node [name=y,mylabup] {$y$} (output);
    \draw [->] (y) |- (measurements);
    \draw [->] (sensor) -| 
node [near end, left] {$y_m$} (sum);

\node[below left = -2pt and -1pt of sum] {$-$};
\end{tikzpicture}
\end{document}

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

관련 정보