7

My problem is that I have crossing lines/arrows in my diagram and during my search, I just found answers like here which do not suit for my problem. Maybe someone can help me out with this. The arrow from the Firms to the Government has to cross the arrows between the CB and the Banks but in such a way that one can read the text. Is it possible to put the arrow on different layers or something?

\tikzset{
    %Define standard arrow tip
    >=stealth',
    %Define style for boxes
    punkt/.style={
           rectangle,
           rounded corners,
           draw=black, very thick,
           text width=6.5em,
           minimum height=3.5em,
           text centered}
}


\begin{tikzpicture}[node distance=1cm, auto, description/.style={fill=white,inner sep=2pt}]

 %nodes
 \node[punkt]                      (Banks)  {Banks ($B_b$)};
 \node[left=4cm of Banks]          (dummy1) {};
 \node[right=4cm of Banks]         (dummy2) {};
 \node[punkt, above=4cm of dummy1] (CB)     {CB};
 \node[punkt, below=4cm of dummy1] (Gov)    {Government};
 \node[punkt, above=4cm of dummy2] (Firms)  {Firms ($F_f$)};
 \node[punkt, below=4cm of dummy2] (HH)     {HH ($HH_{hh}$)};


\path[->, >=latex, thick]
  (Gov.20)      edge[] node[below, rotate=48]  {\small Bonds}                       (Banks.220)
  (Banks.200)   edge[] node[above, rotate=48]  {\small Deposits}                    (Gov.40)
  (Firms.250)   edge[] node[above, rotate=90]  {\small wage, dividends}             (HH.110)
  (HH.70)       edge[] node[below, rotate=90]  {\small equity, consumption}         (Firms.290)
  (Gov.350)     edge[] node[below]             {\small unempl. benefit}             (HH.190)
  (HH.170)      edge[] node[above]             {\small Taxes}                       (Gov.10)
  (CB.325)      edge[] node[below, rotate=-50] {\small interest, OSDF}              (Banks.160)
  (Banks.143)   edge[] node[above, rotate=-50] {\small interest, IDL, OMO, OSLF}    (CB.345)
  (Firms.200)   edge[] node[above, rotate=48]  {\small principal/interest payments} (Banks.40)
  (Banks.20)    edge[] node[below, rotate=48]  {\small Loans, interest}             (Firms.220)
  (HH.143)      edge[] node[above, rotate=-50]  {\small equity}                     (Banks.345)
  (Banks.325)   edge[] node[below, rotate=-50]  {\small interest, dividends}        (HH.160)
  (Banks.west)  edge[out=200, in=340, looseness=5] node[below]  {\small interbank loans} (Banks.east)
  (Firms.170)   edge[bend right=35]                node[above, near end, rotate=60]  {\small Taxes}               (Gov.120);
\end{tikzpicture}

enter image description here

6

I'm a friend of simple solutions: (1) draw the crossing edge, (2) draw a semi-transparent white rectangle to fade it in the background, (3) draw other stuff on top of it.

\path[->, >=latex, thick](Firms.170)   edge[bend right=35]   node[above, near end, rotate=60]  {\small Taxes}               (Gov.120);

\path[fill=white, opacity=0.8] (-3.2,1) rectangle +(1.5,2);

\path[->, >=latex, thick]
  (Gov.20)      edge[] node[below, rotate=48]  {\small Bonds}                            (Banks.220)
[...]
  (Banks.west)  edge[out=200, in=340, looseness=5] node[below]  {\small interbank loans} (Banks.east);

enter image description here

7

An alternative approach using the background layer:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning}
\usetikzlibrary{backgrounds}     %new code
\tikzset{
    %Define standard arrow tip
    >=stealth,
    %Define style for boxes
    punkt/.style={
           rectangle,
           rounded corners,
           draw=black, very thick,
           text width=6.5em,
           minimum height=3.5em,
           text centered}
}

\begin{document}
\begin{tikzpicture}[node distance=1cm, auto, description/.style={fill=white,inner sep=2pt}]

 %nodes
 \node[punkt]                      (Banks)  {Banks ($B_b$)};
 \node[left=4cm of Banks]          (dummy1) {};
 \node[right=4cm of Banks]         (dummy2) {};
 \node[punkt, above=4cm of dummy1] (CB)     {CB};
 \node[punkt, below=4cm of dummy1] (Gov)    {Government};
 \node[punkt, above=4cm of dummy2] (Firms)  {Firms ($F_f$)};
 \node[punkt, below=4cm of dummy2] (HH)     {HH ($HH_{hh}$)};


\path[->, >=latex, thick]
  (Gov.20)      edge[] node[below, rotate=48]  {\small Bonds}                       (Banks.220)
  (Banks.200)   edge[] node[above, rotate=48]  {\small Deposits}                    (Gov.40)
  (Firms.250)   edge[] node[above, rotate=90]  {\small wage, dividends}             (HH.110)
  (HH.70)       edge[] node[below, rotate=90]  {\small equity, consumption}         (Firms.290)
  (Gov.350)     edge[] node[below]             {\small unempl. benefit}             (HH.190)
  (HH.170)      edge[] node[above]             {\small Taxes}                       (Gov.10)
  (CB.325)      edge[] node[fill=white,below, sloped] {\small interest, OSDF}              (Banks.160)     %new code
  (Banks.143)   edge[] node[fill=white,above, sloped] {\small interest, IDL, OMO, OSLF}    (CB.345)        %new code
  (Firms.200)   edge[] node[above, rotate=48]  {\small principal/interest payments} (Banks.40)
  (Banks.20)    edge[] node[below, rotate=48]  {\small Loans, interest}             (Firms.220)
  (HH.143)      edge[] node[above, rotate=-50]  {\small equity}                     (Banks.345)
  (Banks.325)   edge[] node[below, rotate=-50]  {\small interest, dividends}        (HH.160)
  (Banks.west)  edge[out=200, in=340, looseness=5] node[below]  {\small interbank loans} (Banks.east);

\begin{scope}[on background layer]   %new code
   \path[->, >=latex, thick]  (Firms.170)   edge[bend right=35]                node[above, near end, rotate=60]  {\small Taxes}               (Gov.120);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

The scoped path goes behind the main path

  • The answer of Harald was what I was searching for, but thanks also for yours since I'm gonna need this in a another diagram. Is there a possibility to define more than one (background) layer? – Mikkel Sep 22 '14 at 9:50
  • 2
    for multiple layers see section 109 of the TikZ manual, the macros you are looking for are \pgfdeclarelayer{>name>}, \pgfsetlayer{>name>}, etc. – Nico Boni Sep 22 '14 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.