谢谢Peter Grill 的回答我能够获得使用-|
或|-
使用 Bond Graph 箭头(f_out
或e_out
)绘制的正确路径(乍一看这并不简单,在Peter Grill 的回答,使用 ) 将路径“分解为两个部分” \coordinate
。
因此,我得到了这个:
但是,为了获得这个,我想“移动”顶部箭头的末端相对于相对坐标 - 类似的东西($(node2.north west)!0.15!(node2.north)$)
(警告:最终结果中不需要红色的东西,这只是为了解释目的):
我想知道我怎样才能实现这个目标?
以下是 MWE(改编自Peter Grill 的回答):
\documentclass{article}
\usepackage{tikz}
\usepackage{bondgraphs}
\usetikzlibrary{calc}
\tikzset{no bond/.style={thick}}% <-- to get similar appearange of bond arrows
\begin{document}%
\begin{tikzpicture}%
\node (node1) [draw, text width=5em, minimum height=8em] {node1};%
\path (node1.east)+(3,0) node (node2) [draw, text width=3em, minimum height=3em] {node2};%
\draw [no bond, e_out] ( $ (node1.north east)!0.15!(node1.east) $ ) -| node [above, pos=0.2] {label1} (node2.north);% <-- changed style
% Top arrow label 1
\coordinate (X1) at ( $ (node1.north east)!0.15!(node1.east) $ );
\coordinate (Y1) at ($(node2.north)!(X1)!(node2.north)$);
\draw [no bond] (X1) -- (Y1);
\draw [bond, e_out] (Y1) -- (node2.north);
% Bottom arrow label 2
\coordinate (Y2) at ($(node1.south east)!0.15!(node1.east)$);
\coordinate (X2) at ($(node2.south)!(Y2)!(node2.south)$);
\draw [no bond, f_out] (node2.south) -- (X2);
\draw [bond] (X2) -- node [below, pos=0.6] {label2} (Y2);
\end{tikzpicture}%
\end{document}
答案1
有多种方法可以移动节点的位置,包括:
您可以应用
xshift=
来移动点(node2.north)
。例如,您可以使用([xshift=-0.25cm]node2.north)
。您可以指定“角度”位置,类似于
(node2.120)
。
使用xshift=
收益率:
代码:
\documentclass{article}
\usepackage{tikz}
\usepackage{bondgraphs}
\usetikzlibrary{calc}
\tikzset{no bond/.style={thick}}% <-- to get similar appearance of bond arrows
\begin{document}%
\begin{tikzpicture}%
\node (node1) [draw, text width=5em, minimum height=8em] {node1};
\coordinate (X1) at ($ (node1.north east)!0.15!(node1.east) $);
\path (node1.east)+(3,0) node (node2) [draw, text width=3em, minimum height=3em] {node2};
\coordinate (X2) at ([xshift=-0.25cm]node2.north);
\draw [no bond, e_out] (X1) -| node [above, pos=0.2] {label1} (X2);
% Top arrow label 1
\coordinate (Y1) at ($(X2)!(X1)!(X2)$);
\draw [no bond] (X1) -- (Y1);
\draw [bond, e_out] (Y1) -- (X2);
% Bottom arrow label 2
\coordinate (Y2) at ($(node1.south east)!0.15!(node1.east)$);
\coordinate (X2) at ($(node2.south)!(Y2)!(node2.south)$);
\draw [no bond, f_out] (node2.south) -- (X2);
\draw [bond] (X2) -- node [below, pos=0.6] {label2} (Y2);
\end{tikzpicture}%
\end{document}