2

When I tried to make paths drawn using -| or |- with a Bond Graph arrow (f_out or e_out) in a Tikzpicture I obtain this (the red circles show the wrong location of the end of the arrows):

enter image description here

I would prefer this:

enter image description here

Here the 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}

Could anyone help me fix this?

0

1 Answer 1

4

It looks like bondgraph does not properly handle paths drawn using -| or |-. The simplest solution I can offer

  1. Use the no bond style to get the same thickness on the portions where you don't want the bond.

  2. Break the path into two components and use no_bond on the first and bond on the second:

    \draw [no bond, f_out] (node2.south) -- (X);
    \draw [bond] (X) -- (Y);
    

    where (X) and (Y) are the intermediate points.

enter image description here

Code:

\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}
3
  • Tanks a lot for your answer, It meets my need. However, do you know by chance how can I "shift" the end of the top arrow regarding relative coordinate - with something like ($(node2.north west)!0.15!(node2.north)$) (see the first edit of my question for more details). Thanks again !
    – zetyty
    Commented Feb 11, 2022 at 10:06
  • You have several options: 1. You could apply a xshift= to move the point (node2.north). For example, you could use ([xshift=-0.25cm]node2.north). 2. You could specify the "angle" position, something like (node2.120). In general, it is a good idea to keep questions to be specfic to one particular issue. That way, when others have a similar issue in the future, they are more likely to be able to find it. In this case, somone looking to move a node to the left will probably ignore a question about bond graphs. Commented Feb 14, 2022 at 17:34
  • Ok I have posted another answer here. Thanks a lot for your comment.
    – zetyty
    Commented Feb 14, 2022 at 20:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .