[Tex/LaTex] Draw consecutive arrows with TikZ

tikz-arrowstikz-pgf

In this question the OP needs to draw with a single line of code a series of arrows and labeled nodes.

Let's instead assume that a single uniform line from (0,0) to (10,0) has to be drawn; the dash arrow -| must be placed in positions (2,0), (7,0) and another type of arrow -> at the right end of the line. This is to realize a coordinate-x axis with a vertical dash only in the specified abscissa points.

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

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}

\node (a) at (0,0) {};
\node (b) at (2,0) {};
\node (c) at (7,0) {};
\node (d) at (10,0) {};

\draw [-|] (a) edge (b) (b) edge (c) (c) edge (d);

\end{tikzpicture}
\end{document}

This is the solution provided by the linked question: the line is stopped, with blank spaces, at every node.

Even before considering the ending arrow, ->, if I try

\draw [-|] (0,0) edge (2,0) edge (7,0) edge (10,0);

a single dash before the beginning of the line appears (zoom to see it) and it is undesired.

How to realize a continuous drawned line with -| at the specified positions, ending with ->, and possibly with a single line of code? (If a solution is available even without defining the nodes, it is ok: they are not strictly needed here).

Best Answer

If you use \coordinate instead of \node, you won't get the gaps. And you can set different arrow tips for the different edges, so try

\draw (a) edge[-|] (b)  edge[-|] (c)  edge[->] (d);

I added a markings version as well, for reference.

output of code

\documentclass[tikz,border=5pt]{standalone}    
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}

\coordinate (a) at (0,0);
\coordinate (b) at (2,0);
\coordinate (c) at (7,0);
\coordinate (d) at (10,0);

\draw (a) edge[-|] (b)  edge[-|] (c)  edge[->] (d);

\end{tikzpicture}

\begin{tikzpicture}[
 decoration={markings,
             mark=at position 0.2 with \arrow{|},
             mark=at position 0.7 with \arrow{|}}
]
\coordinate (a) at (0,0);
\coordinate (d) at (10,0);

\draw [->,postaction={decorate}] (0,0) -- (10,0);

\end{tikzpicture}
\end{document}