-|
当我尝试在 Tikzpicture 中使用或|-
与 Bond Graph 箭头(f_out
或)绘制路径时,e_out
我得到了这个(红色圆圈显示箭头末端的错误位置):
我更喜欢这样:
这里是 MWE:
\documentclass{article}
\usepackage{tikz}
\usepackage{bondgraphs}
\usetikzlibrary{calc}
\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 [bond, e_out] ( $ (node1.north east)!0.15!(node1.east) $ ) -| node [above, pos=0.2] {label1} (node2.north);%
\draw [bond, f_out] (node2.south) |- node [below, pos=0.8] {label2} ( $ (node1.south east)!0.15!(node1.east) $ );%
\end{tikzpicture}%
\end{document}
有人能帮我解决这个问题吗?
答案1
看起来bondgraph
不能正确处理使用-|
或绘制的路径|-
。我能提供的最简单的解决方案
使用
no bond
样式在您不想要的部分获得相同的厚度bond
。将路径分成两个部分,并
no_bond
在第一个和bond
第二个部分使用:\draw [no bond, f_out] (node2.south) -- (X); \draw [bond] (X) -- (Y);
其中
(X)
和(Y)
是中间点。
代码:
\documentclass{article}
\usepackage{tikz}
\usepackage{bondgraphs}
\usetikzlibrary{calc}
\tikzset{no bond/.style={thick}}% <-- to get similar appearange
\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
%\draw [bond, f_out] (node2.south) |- node [below, pos=0.8] {label2} ( $ (node1.south east)!0.15!(node1.east) $ );%
\coordinate (Y) at ($(node1.south east)!0.15!(node1.east)$);
\coordinate (X) at ($(node2.south)!(Y)!(node2.south)$);
\draw [no bond, f_out] (node2.south) -- (X);
\draw [bond] (X) -- (Y);
\end{tikzpicture}
\end{document}