everyone!
I am plotting some diagrams and encountered a problem. Here is my code
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta, positioning, quotes, shadows}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usetikzlibrary{patterns}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{calc,intersections}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,chains}
\usetikzlibrary[calc]
\begin{document}
\begin{tikzpicture}[auto,>=stealth,
node distance = 25mm and 10mm,
box/.style = {draw, rounded corners, fill=blue!6,
minimum width=22mm, minimum height=5mm, align=center},
squarednode/.style={rectangle, draw=black!0, fill=blue!1, very thick, minimum size=1mm},
> = {Straight Barb[angle=60:2pt 3]},
bend angle = 15,
auto = right,
]
\node (node1) [box,draw,name path=node1] {\large{Heat} \ \large{market}};
\node (node2) [box,draw,name path=node2, above right=of node1] {\large{Combined Heat and Power Plants, }\\large{Power-to-Heat units}};
\node (node3) [box, draw, name path=node3, below right=of node2] {\large{Electricity} \ \large{market}};
\node (node4) [box, left =of node2] {};
\path [name path=node12] let \p1 = ($(node2)-(node1)$)
in (node1) ($(node1)!5pt!($(node1)+(-\y1,\x1)$)$) to +(\p1);
\path [name path=node21] let \p1 = ($(node2)-(node1)$)
in (node1) ($(node1)!-5pt!($(node1)+(-\y1,\x1)$)$) to +(\p1);
\path [name path=node23] let \p1 = ($(node3)-(node2)$)
in (node2) ($(node2)!5pt!($(node2)+(-\y1,\x1)$)$) to +(\p1);
\path [name path=node32] let \p1 = ($(node3)-(node2)$)
in (node2) ($(node2)!-5pt!($(node2)+(-\y1,\x1)$)$) to +(\p1);
\node [name intersections={of=node1 and node12}] (start) at (intersection-1){};
\draw [<-,very thick,name intersections={of=node2 and node12}]
(start.center) -- node[text width=3.5cm,sloped,swap,midway,above, align=center] {1. Heat offer} (intersection-1);
\node [name intersections={of=node2 and node21}] (start) at (intersection-1){};
\draw [<-,very thick,name intersections={of=node1 and node21}]
(start.center) -- node[text width=3cm,sloped, align=center] {2. Heat dispatch and price} (intersection-1);
\node [name intersections={of=node2 and node23}] (start) at (intersection-1){};
\draw [<-,very thick,name intersections={of=node3 and node23}]
(start.center) -- node[text width=3cm,sloped,swap,midway,above, align=center] {4. Electricity dispatch and price} (intersection-1);
\node [name intersections={of=node3 and node32}] (start) at (intersection-1){};
\draw [<-,very thick,name intersections={of=node2 and node32}]
(start.center) -- node[sloped] {3. Electricity offer} (intersection-1);
\draw [->] (node4) --node[text width=3cm, above, midway] {Electricity price forecast} (node2);
\end{tikzpicture}
\end{document}
First I plot some nodes, then I calculate distances to plot parallel lines as in https://tex.stackexchange.com/a/232828/262804. Then, I am plotting the text above the line as in https://tex.stackexchange.com/a/249540/262804 with the following line
\draw [->] (node4) --node[text width=3cm, above, midway] {Electricity price forecast} (node2);
And then I am getting this result
How can I make "Electricity price forecast" text node be always between node4 and node2 and never cross them?


\node (node4) [box, left = 3cm of node2] {};– SebGlav Apr 30 '22 at 12:36