我想绘制此框图,但第一行中的所有箭头和最后一个块都出现问题。有人能帮我吗?
这是我现在所拥有的。
\documentclass[border=0.2cm]{standalone}
% More defined colors
\usepackage[dvipsnames]{xcolor}
% Required package
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,backgrounds,patterns,fadings,matrix,arrows,calc,
intersections,decorations.markings,
positioning,external,arrows.meta}
\tikzset{
block/.style = {draw, rectangle,
minimum height=1cm,
minimum width=2cm},
input/.style = {coordinate,node distance=1cm},
output/.style = {coordinate,node distance=6cm},
arrow/.style={draw, -latex,node distance=2cm},
pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
sum/.style = {draw, circle, node distance=1cm},
}
\begin{document}
\begin{tikzpicture}
\node[input, name=input] {};
\node[sum, right=2cm of input, line width=0.25mm,] (sum) {};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
right=1.5cm of sum
] (controller) {$A(s)$};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
right=1.5cm of controller
] (system1) {$B(s)$};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
right=1.5cm of system1
] (system) {$C(s)$};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
right=1.5cm of system
] (system3) {$D(s)$};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
above = 1cm of system1
] (sensor) {$E(s)$};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
above = 1cm of system
] (sensor) {$F(s)$};
\node [draw,
minimum width=2cm,
minimum height=1.2cm,
above = 1cm of system3
] (sensor3) {};
\draw[-stealth] (controller.east) -- (system1.west) node[midway,above]{$x$};
\draw[-stealth] (system1.east) -- (system.west) node[midway,above]{$x$};
\draw[-stealth] (system1.east) -- (system.west) node[midway,above]{$x$};
\draw[-stealth] (system.east) -- (system3.west) node[midway,above]{$x$};
\end{tikzpicture}
\end{document}
答案1
欢迎来到 TeX.SE 社区!
抱歉,但您的草图不太清晰,所以我省略了最右上方节点的内容,只是猜测节点之间的一些联系。
在绘制上面的框图时,我使用chains
库将节点放置在图的主分支中,对于某些箭头使用ext.paths.ortho
库:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
ext.paths.ortho, % defined in the tikz-ext package,
% https://ctan.org/pkg/tikz-ext?lang=en
positioning,
quotes}
\tikzset{
node distance = 8mm and 6mm,
start chain = A going right,
arr/.style = {-Straight Barb},
block/.style = {draw, thick, minimum height=11mm, minimum width=22mm},
dot/.style = {circle, fill, inner sep=1.2pt, node contents={}},
sum/.style = {circle, draw, thick, inner sep=6pt, node contents={}}
}
\begin{document}
\begin{tikzpicture}
% main branch
\begin{scope}[nodes = {on chain=A, join=by arr}]
\coordinate (in);
\node[sum]; % A-2
\node[block] {$A(s)$};
\node[block] {$B(s)$};
\node[block] {$C(s)$};
\node[dot];
\node[block] {$D(s)$};
\node[dot]; % A-7
\coordinate (out);
\end{scope}
\path[draw=none] (A-8) to["$x$"] (out);
% top branch
\node [block, above=of A-4] (sensor1) {$E(s)$};
\node [block, above=of A-5] (sensor2) {$F(s)$};
\node [block, above=of A-7] (sensor3) {};
% arrows not considered in the join macro
\draw[arr] (sensor3) edge (sensor2)
(sensor2) edge (sensor1);
\draw[arr] ([xshift=-3mm] sensor1.south) |-| (A-3);
\draw[arr] ([xshift=+3mm] sensor1.south) |-| ([xshift=-3mm] A-5.north);
\draw[arr] ([xshift=+3mm] A-5.north) |-| (sensor3);
\draw[arr] (A-6) |- ([yshift=-6mm] sensor3.south)
r-rl ([yshift=-2mm] sensor3.east);
\draw[arr] (A-8) |- ([yshift=2mm] sensor3.east);
\draw[->] (A-8) r-du (A-2);
\end{tikzpicture}
\end{document}
附录:
再猜一下,稍微改进一下代码:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
ext.paths.ortho, % defined in the tikz-ext package,
% https://ctan.org/pkg/tikz-ext?lang=en
positioning,
quotes}
\tikzset{
node distance = 8mm and 6mm,
start chain = A going right,
arr/.style = {-Straight Barb},
block/.style = {draw, thick, minimum height=11mm, minimum width=22mm},
dot/.style = {suspend join,
circle, draw, fill, inner sep=1.2pt, node contents={}}, % changed
sum/.style = {circle, draw, thick, inner sep=2pt, node contents={\huge +}} % changed
}
\makeatletter
\tikzset{suspend join/.code={\def\tikz@after@path{}}} % new
\makeatother
\begin{document}
\begin{tikzpicture}
% main branch
\begin{scope}[nodes = {on chain=A, join=by arr}]
\coordinate (in);
\node[sum]; % A-2
\node[block] {$A(s)$};
\node[block] {$B(s)$};
\node[block] {$C(s)$};
\node[dot, join=by -]; % changed
\node[block] {$D(s)$};
\node[dot, join=by -]; % A-7, changed
\coordinate (out);
\end{scope}
\path[draw=none] (A-8) to["$x$"] (out);
% top branch
\node [block, above=of A-4] (sensor1) {$E(s)$};
\node [block, above=of A-5] (sensor2) {$F(s)$};
\node [block, above=of A-7] (sensor3) {};
% arrows not considered in the join macro
\draw[arr] (sensor3) edge (sensor2)
(sensor2) edge (sensor1);
\draw[arr] ([xshift=-3mm] sensor1.south) |-| (A-3);
\draw[arr] ([xshift=+3mm] sensor1.south) |-| ([xshift=-3mm] A-5.north);
\draw[arr] (sensor3) |-| ([xshift=+3mm] A-5.north); % changed
\draw[arr] (A-6) |- ([yshift=-6mm] sensor3.south)
r-rl ([yshift=-2mm] sensor3.east);
\draw[arr] (A-8) |- ([yshift=2mm] sensor3.east);
\draw[->] (A-8) r-du (A-2);
\end{tikzpicture}
\end{document}