我有以下链:
\begin{tikzpicture}[start chain=going right,>=latex,node distance=0pt]
\node[draw,rectangle,on chain,minimum size=1cm] (rr) {$I$};
\node[draw,rectangle,on chain,draw=white,minimum width=0.8cm]{};
% the rectangular shape with vertical lines
\node[rectangle split, rectangle split parts=3,
draw, rectangle split horizontal,text height=0.5cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa.north west)
rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa.south);
% the circle
\node[draw,circle,on chain,minimum size=1cm] (se) {$U_1$};
\node[draw,diamond,on chain,minimum size=0.2cm,xshift=0.7cm] (see) {};
{ [start branch=numbers going below] } % just a declaration,
\node[draw,rectangle,on chain,draw=white,minimum width=0.7cm]{};
% rect2
\node[rectangle split, rectangle split parts=3,
draw, rectangle split horizontal,text height=0.5cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa2) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa2.north west)
rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa2.south);
% the circle 2
\node[draw,circle,on chain,minimum size=1cm] (se2) {$U_2$};
% the arrows and labels
\draw[->] (se.east) -- +(20pt,0) node[midway,above] {$\mu_1$};
\draw[->] (see.east) -- +(20pt,0) node[midway,above] {$\mu_1$};
\draw[->] (se2.east) -- +(20pt,0) node[midway,above] {$\mu_2$};
\draw[<-] (wa.west) -- +(-20pt,0) node[midway,above] {$\lambda$};
\end{tikzpicture}
如图所示,这是两个队列之间的连接:
但是我想在菱形下方添加另一个带箭头的节点。该怎么做?我搜索了一些解决方案,但它们并不适合我的代码……
答案1
首先,你必须加载scopes
tikz 的库,因此在你的序言中(你应该在上面发布过),你应该添加
\usetikzlibrary{scopes}
然后,按如下方式编辑链的开头:
\begin{tikzpicture}[>=latex,node distance=0pt]
{ [start chain=going right]
最后,将分支放在链的末尾(并相应地编辑标签):
% the branch
{[continue branch=numbers]
\node[draw,circle,on chain,minimum size=1cm,yshift=-0.7cm] (se3) {$U_3$};
\draw[->] (see.south) -- +(0,-20pt) node[midway,left] {$\mu_3$};
}
} % closing brace from above
\end{tikzpicture}
答案2
请注意,如果您愿意,也可以不使用,scopes
只需使用第二个链和chainin
。但是,出于某种原因,正确定位非常困难。我猜这是因为代码中有很多移位等,但我并不确定。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,shapes}% both are needed for the original code in the question
\begin{document}
\begin{tikzpicture}[start chain,>=latex,node distance=0pt]
{ [start chain=trunk going right]
\node[draw,rectangle,on chain,minimum size=1cm] (rr) {$I$};
\node[draw,rectangle,on chain,draw=white,minimum width=0.8cm]{};
% the rectangular shape with vertical lines
\node[rectangle split, rectangle split parts=3,
draw, rectangle split horizontal,text height=0.5cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa.north west)
rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa.south);
% the circle
\node[draw,circle,on chain,minimum size=1cm] (se) {$U_1$};
\node[draw,diamond,on chain,minimum size=0.2cm,xshift=7mm] (see) {};
\node[draw,rectangle,on chain,draw=white,minimum width=0.7cm]{};
% rect2
\node[rectangle split, rectangle split parts=3,
draw, rectangle split horizontal,text height=0.5cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa2) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa2.north west)
rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa2.south);
% the circle 2
\node[draw,circle,on chain,minimum size=1cm] (se2) {$U_2$};
}
% the branch
{ [start chain=numbers going below]
\chainin (see);
\node[draw,diamond,on chain,minimum size=.2cm,yshift=-1cm,xshift=-4.75mm] (branchnode) {};
}
% the arrows and labels
\draw[->] (se.east) -- +(7mm,0) node[midway,above] {$\mu_1$};
\draw[->] (see.east) -- +(7mm,0) node[midway,above] {$\mu_1$};
\draw[->] (se2.east) -- +(7mm,0) node[midway,above] {$\mu_2$};
\draw[<-] (wa.west) -- +(-7mm,0) node[midway,above] {$\lambda$};
\draw[->] (see.south) -- (branchnode);
\end{tikzpicture}
\end{document}