I have drawn some block elements with tikz and named them A and B.
I am trying to draw a line between them with
\path [line] (requested) -- (processing);
but I also want some text above the line.
\path [line] (requested) -- node [above,midway] {Some text} (processing);
works but if the text is very long it just keeps running without breaking the line.
How can I make sure the text wont be wider than the line itself?
Edit
With
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes,arrows,chains}
\begin{document}
\tikzstyle{block} = [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\begin{tikzpicture}[node distance=1cm, auto]
\node (init) {};
\node [block] (A) {A};
\node [block, right=of A] (B) {B};
\path [line] (A) -- node [text width=2.5cm,midway,above] {My very looooooong text which is wider than the arrow below} (B);
\end{tikzpicture}
\end{document}
I get
How can I in a smarter way make sure there is room for the text? I have multiple boxes.
Best Answer
two possibilities - Specifying the distance above - By separating the blocks
if you want center the text