
Ich möchte diese Figur zeichnen und dies ist mein Code und das Ergebnis. Ich möchte, dass die Größe der Blöcke und ihr Abstand mit der Originalfigur übereinstimmen. Außerdem sollte „Netzwerk“ innerhalb der gepunkteten Linie liegen
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,fit}
\usetikzlibrary{arrows,calc,positioning}
\usetikzlibrary{shapes,arrows,positioning,calc}
\begin{document}
\newlength\estilength
\settowidth\estilength{$estimator$}
\tikzset{
block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em,text width=\estilength,align=center},
tmp/.style = {coordinate},
sum/.style= {draw, fill=white, circle, node distance=1cm},
input/.style = {coordinate},
output/.style= {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}
},
point/.style = {draw, fill=black, circle, minimum size=0.8mm, node distance=1.5cm, inner sep=0pt},
dashed node/.style={draw,dashed,inner sep=7.5pt,rounded corners},
}%
\begin{tikzpicture}[auto, node distance=15mm,>=latex']
\node [block] (act) {$Actuator$};
\node [block, right=2 of act ] (plant) {Plant};
\node [block, right= 2 of plant] (c) {$sensor$};
\node [block, below=15mm of c] (delay) {$Delay$};
\node [block, below=30mmof plant] (control) {$controller$};
\node [block, below=15mm of act] (me) {$measur$};
\draw [->] (act) --(plant);
\draw [->] (plant) -- (c);
\draw [->] (c) -- (delay);
\draw [->] (delay) |- (control);
\draw [->] (control) -| (me);
\draw [->] (me) -- (act);
\node [dashed node,fit=(me)(delay),label=above:{network}] {};
\end{tikzpicture}
\end{document}
Antwort1
So was?
Dieses Etikett fürNetzwerkwirklich in der Mitte des Knotens sein wird, sollten Sie es als Label schreiben (siehe MWE unten}.
In MWE habe ich die Knotennamen gekürzt, chains
eine Bibliothek hinzugefügt und \tikzset{...}
nur die in Bildern verwendeten Stile berücksichtigt:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
fit}
\begin{document}
\newlength\estilength
\settowidth\estilength{\emph{controller}}
\tikzset{
arr/.style = {-Latex, semithick},
every edge/.append style = {draw, arr},
FIT/.style args = {#1/#2}{draw, densely dashed, inner sep=1em,
label = {[font=\large]center:#1},
fit=#2,
},
N/.style = {draw, fill=white, align=center, font=\itshape,
minimum height=5ex, minimum width=\estilength,
text width=\pgfkeysvalueof{/pgf/minimum width}+2*\pgfkeysvalueof{/pgf/inner xsep},
},
P/.style = {N, font=\textrm\large, on chain},
}
\begin{tikzpicture}[auto,
node distance = 10mm and 15mm,
start chain = going right]
\begin{scope}[nodes={N, on chain, join=by arr}]
\node (act) {Actuator};
\node (plant) [P] {Plant};
\node (c) {sensor};
\end{scope}
\node (delay) [N, below=of c] {Delay};
\node (msr) [N, below=of act] {measure};
\node (cntrl) [N, below = of msr.south -| plant] {controller};
%
\node [FIT= network/(msr)(delay)] {};
%
\draw[arr] (msr) edge (act)
(c) to (delay);
\draw [arr] (delay) |- (cntrl);
\draw [arr] (cntrl) -| (msr);
\end{tikzpicture}
\end{document}
Nachtrag:
Offenbar fehlt mir das erste Bild und ich verlange, dass MWE es reproduzieren soll. Das neue MWE unten ermöglicht dies:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
fit}
\begin{document}
\newlength\estilength
\settowidth\estilength{\emph{controller}}
\tikzset{
arr/.style = {-Latex, semithick},
every edge/.append style = {draw, arr},
FIT/.style args = {#1/#2}{draw, densely dashed, inner sep=1em,
label = {[font=\large]center:#1},
fit=#2,
},
N/.style = {draw, semithick, align=center, font=\itshape,
minimum height=5ex, minimum width=#1,
text width=\pgfkeysvalueof{/pgf/minimum width}+2*\pgfkeysvalueof{/pgf/inner xsep},
},
N/.default = \estilength,
P/.style = {N, font=\textrm\large, on chain},
}
\begin{tikzpicture}[auto,
node distance = 10mm and 15mm,
start chain = going right]
\begin{scope}[nodes={N, on chain, join=by arr}]
\node (act) {Actuator};
\node (plant) [P] {Plant};
\node (c) {sensor};
\end{scope}
\node (delay) [N=2*\estilength, below=of c] {Actuation\\ Delay}; % here is adjusted width of node's shape
\node (msr) [N=2*\estilength, below=of act] {Measurement\\ Delay}; % here is adjusted width of node's shape
\node (cntrl) [N, below = of msr.south -| plant] {controller};
%
\node [FIT= network/(msr)(delay)] {};
%
\draw[arr] (msr) edge (act)
(c) to (delay);
\draw [arr] (delay) |- (cntrl);
\draw [arr] (cntrl) -| (msr);
\end{tikzpicture}
\end{document}