[Tex/LaTex] Distance between arrow and text above arrow in tikz

tikz-pgf

I am drawing two nodes and an arrow between these nodes with

\documentclass[tikz,border=5pt]{standalone}

\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[node distance=5cm]

% nodes
\node [draw] (A) {A};
\node [draw, right=of A] (B) {B};

% arrows
\draw [->] (A) -- node [above, midway] {Some text} (B);

\end{tikzpicture}

\end{document}

Using \draw [->] (A) -- node [above, midway] {Some text} (B); I can write text above the arrow; however, the text doesn't respect the configured node distance. Can I set the distance between the arrow and the text?

Best Answer

You will have to shift the label. They are not controlled by the node distance.

Chose one approach:

% arara: pdflatex

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning}

\begin{document}    
    \begin{tikzpicture}[node distance=5cm]
    \node [draw] (A) {A};
    \node [draw, right=of A] (B) {B};
    \node [draw, right=of B] (C) {C};
    \node [draw, right=of C] (D) {D};
    \draw [->] (A) -- node [above=5cm] {Some text} (B); 
    \draw [->] (B) -- node [label={[yshift=5cm]Some text}] {} (C);  
    \draw [->] (C) -- node [label={[label distance=5cm]90:Some text}] {} (D);   
    \end{tikzpicture}   
\end{document}

The one you like, you might apply be adding e.g. \begin{tikzpicture}[every label/.append style={above=5cm}]