我正在尝试使用以下结构的代码绘制多输入多输出样式图:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\tikzset{packet/.style={rectangle, draw, very thick, minimum size=8mm, rounded corners=1mm, fill=blue!50!white!30}}
\tikzset{mixing/.style={rectangle, draw, very thick, minimum width=35ex, rounded corners=1mm, fill=red!70!orange!30,rotate=90}}
\node[packet] (A) at (0,0) {Node A};
\node[packet] (B) [right=2cm of A] {Node B};
\node[mixing] (pro) at ($(A) !.5! (B) + (0.0,-1.0)$) {Multiple Input Multiple Output process};
\node[packet] (C) at (0.0,-2.1) {Node C};
\node[packet] (D) [right=2cm of C] {Node D};
\draw[->] (A.east) -- (B.west);
\draw[->] (C.east) -- (D.west);
\end{tikzpicture}
\end{document}
生成下图:
我想知道的是如何绘制箭头,以便“多输入多输出过程”将线一分为二,从而将其分成两部分,因此有一个箭头进入左侧的过程(例如从节点 A 开始),另一个箭头从右侧出去(例如到节点 B)。
我知道将线的入口/出口设置为节点的符号(类似于 name_of_node.180,其中 180 指定相对于节点中心的节点入口/出口角度),例如这里框图 TikZ 中的多输入 - 多输出组件
但是,是否可以强制“流程”节点的箭头的入口点和出口点与一对节点(A 和 B,或 C 和 D)“齐平”。(实际上,在下图中,就像流程节点将箭头一分为二,将它们一分为二,如前所述)。
答案1
您可以使用垂直坐标系:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\tikzset{packet/.style={rectangle, draw, very thick, minimum size=8mm, rounded corners=1mm, fill=blue!50!white!30}}
\tikzset{mixing/.style={rectangle, draw, very thick, minimum width=35ex, rounded corners=1mm, fill=red!70!orange!30,rotate=90}}
\node[packet] (A) at (0,0) {Node A};
\node[packet] (B) [right=2cm of A] {Node B};
\node[mixing] (pro) at ($(A) !.5! (B) + (0.0,-1.0)$)
(mult) {Multiple Input Multiple Output process};
\node[packet] (C) at (0.0,-2.1) {Node C};
\node[packet] (D) [right=2cm of C] {Node D};
\draw[->] (A.east) -- (mult.north|-A.east);
\draw[->] (mult.south|-A.east) -- (B.west);
\draw[->] (C.east) -- (mult.north|-C.east);
\draw[->] (mult.south|-C.east) -- (D.west);
\end{tikzpicture}
\end{document}
更好的选择是使用:
\draw[->] (A.east) -- (mult.north|-A.east);
\draw[->] (mult.south|-A.east) -- (B.west|-A.east);
\draw[->] (C.east) -- (mult.north|-C.east);
\draw[->] (mult.south|-C.east) -- (D.west|-C.east);