[Tex/LaTex] Drawing an arrow tip to every node of a path

tikz-pgf

I want to draw an arrow tip to every node/coordinate in a path. But tikz draws them only to the first and last point. Is there an option for that purpose? Or have I to splitt the path into its single parts?

Here is an example:

enter image description here

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    % What should I add to this:
    \draw  [|<->|] (0.4,2.4) to node[right] {$L$} ++(0,-1.5)
            to node[right] {$d$} ++(0,-1)
            to node[right] {$h$} ++(0,-1);
    % To get:
    \draw  [|<->|] (0.8,2.4) to node[right] {$L$} (0.8,0.9);
    \draw  [|<->|] (0.8,0.9) to node[right] {$d$} (0.8,-0.1);
    \draw  [|<->|] (0.8,-0.1) to node[right] {$h$} (0.8,-1.1);

    \end{tikzpicture}
\end{document}

Best Answer

Your first command only creates one path and TikZ will apply the arrowheads to the end of that path. So you need to create separate paths for the individual bits. One relatively quick way to insert subpaths into a statement is the edge command:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \path[|<->|]
             (0.4,2.4) edge node[right] {$L$} +(0,-1.5)
            ++(0,-1.5) edge node[right] {$d$} +(0,-1)
            ++(0,-1)   edge node[right] {$h$} +(0,-1);
    \end{tikzpicture}
\end{document}

The only drawback is that edge doesn't advance the current position, so that you have to repeat the coordinates. Also you need to use \path instead of \draw to avoid the drawing of an empty path with arrowheads.