![当使用带有 [grow right sep] 选项的图库时,如何指定节点链之间的垂直距离?](https://linux22.com/image/456999/%E5%BD%93%E4%BD%BF%E7%94%A8%E5%B8%A6%E6%9C%89%20%5Bgrow%20right%20sep%5D%20%E9%80%89%E9%A1%B9%E7%9A%84%E5%9B%BE%E5%BA%93%E6%97%B6%EF%BC%8C%E5%A6%82%E4%BD%95%E6%8C%87%E5%AE%9A%E8%8A%82%E7%82%B9%E9%93%BE%E4%B9%8B%E9%97%B4%E7%9A%84%E5%9E%82%E7%9B%B4%E8%B7%9D%E7%A6%BB%EF%BC%9F.png)
我想使用该graphs
库绘制框图,到目前为止运行良好。但是,我想通过添加另一个节点链来向下面的框图添加另一个输入。正如您在下面的最小工作示例中所看到的,占位符节点链1 -> 2 -> 3;
和a -> b -> c;
应该更低,但我找不到任何选项来增加节点链之间的垂直距离pgfmanual.pdf
。有人知道使用该选项时在图形中指定节点链之间垂直距离的选项grow right sep
吗?
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{graphs,calc}
\begin{document}
\begin{tikzpicture}[
,sum/.style={
,draw
,circle
,inner sep=0pt
,minimum size=2mm
,graphs/empty nodes
}
,point/.style={
,draw
,circle,
,inner sep=0pt
,minimum size=1mm
,fill=black
,graphs/empty nodes
}
,block/.style={
,draw
,rectangle % shape
,minimum size = 6mm % size
,semithick % border
}
,mblock/.style={ % block with \displaystyle
,block
,font=\everymath\expandafter{\the\everymath\displaystyle}
}
,mblockfeedback/.style 2 args={to path={
node[mblock] (b) at ($(\tikztostart)!0.5!(\tikztotarget)+(0,#1)$){#2}
-- ++(0,#1)
-- (b)
-- (b -| \tikztotarget)
-- (\tikztotarget)\tikztonodes
}
}
,minus/.style = {edge node={node[#1]{$-$}}}
,mblock/.append style={text height=3.25ex, text depth=2ex}
]
\graph[grow right sep=1cm] {
"$X(s)$"
-> s1[sum]
-> "$K$"[mblock]
-> "$\frac{1}{s}$"[mblock]
-- p1[point]
-> "$Y(s)$";
p1 ->[mblockfeedback={-1.5cm}{$\frac{1}{K}$},minus={pos=0.9,right}] s1;
1 -> 2 -> 3;
a -> b -> c;
}
;
\end{tikzpicture}
\end{document}
答案1
使用branch down
。
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{graphs,calc}
\begin{document}
\begin{tikzpicture}[
,sum/.style={
,draw
,circle
,inner sep=0pt
,minimum size=2mm
,graphs/empty nodes
}
,point/.style={
,draw
,circle,
,inner sep=0pt
,minimum size=1mm
,fill=black
,graphs/empty nodes
}
,block/.style={
,draw
,rectangle % shape
,minimum size = 6mm % size
,semithick % border
}
,mblock/.style={ % block with \displaystyle
,block
,font=\everymath\expandafter{\the\everymath\displaystyle}
}
,mblockfeedback/.style 2 args={to path={
node[mblock] (b) at ($(\tikztostart)!0.5!(\tikztotarget)+(0,#1)$){#2}
-- ++(0,#1)
-- (b)
-- (b -| \tikztotarget)
-- (\tikztotarget)\tikztonodes
}
}
,minus/.style = {edge node={node[#1]{$-$}}}
,mblock/.append style={text height=3.25ex, text depth=2ex}
]
\graph[grow right sep=1cm, branch down=3cm] {
"$X(s)$"
-> s1[sum]
-> "$K$"[mblock]
-> "$\frac{1}{s}$"[mblock]
-- p1[point]
-> "$Y(s)$";
p1 ->[mblockfeedback={-1.5cm}{$\frac{1}{K}$},minus={pos=0.9,right}] s1;
1 -> 2 -> 3;
a -> b -> c;
}
;
\end{tikzpicture}
\end{document}