# How to put a label at the beginning of an arrow?

I came with the following code to display the graph below:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
actor/.style={
rectangle,
draw=black,
minimum size=10mm
},
arrow/.style={
-latex,
thick,
shorten <=2pt,
shorten >=2pt
}
}

\begin{document}

\begin{tikzpicture}[node distance=0mm and 20mm]
\node (A)[actor] {A};
\node (B)[actor,right=of A] {B};
\node (C)[actor, right=of B] {C};
\node (Fake) [right=of C] {};
\node [right=of A,  xshift=-20mm, yshift=2mm] {1};
\draw[arrow] (A) -- node[font=\small, auto] {$200/s$} (B);
\draw[arrow] (B) -- node[font=\small, auto] {$100/s$} (C);
\draw[arrow] (C) -- node[font=\small, auto] {$100/s$} (Fake);
\end{tikzpicture}

\end{document}


As you can see I used a dirty hack to place the "1" value on top of the beginning of the arrow between A and B. How can I do this properly ?

-
please add a minimum working example. –  oerpli Jul 26 at 9:58
sorry, it should be ok now –  Manuel Selva Jul 26 at 10:08
one more thing, I just saw that my post was edited by @egreg to have proper indentation. is there any automatic way to have this ? –  Manuel Selva Jul 26 at 10:09
@ManuelSelva No, there's no automatic way. I feel that good indentation helps in reading the code, so I took the liberty to fix some of the spacings –  egreg Jul 26 at 10:11
@egreg and I thank you for doing it, because I was to lazy to do it myself. My first version was properly indented, but adding the code around to have a minimum working example break this indentation. The code statement of XXXoverflow.com sites is really hard to use. –  Manuel Selva Jul 26 at 10:26
show 1 more comment

You can to this with node[pos=x] where x is in the range between 0 and 1 for a node placement on the way between beginning and ending of a path. You can choose higher values to move it even before/after that.

If you want it higher/lower you can give above an argument (above = x, left, right,... also).

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{
actor/.style={
rectangle,
draw=black,
minimum size=10mm
},
arrow/.style={
-latex,
thick,
shorten <=2pt,
shorten >=2pt
}
}

\begin{tikzpicture}[node distance=3cm, thick]

\node[actor] (1) {A};
\node[actor] (2) [right of=1] {B};
\node[actor] (3) [right of=2] {C};
\node[] (4) [right of=3] {};

\draw[arrow]    (1) to node[pos=0.1,above]{1}node [font=\small,above] {$200/s$} (2);
\draw[arrow]    (2) to node [font=\small,above] {$100/s$} (3);
\draw[arrow]    (3) to node [font=\small,above] {$100/s$} (4);
\end{tikzpicture}
\end{document}


-
Thanks, all I needed and I have to learn how to search in tikz documentation: "16.8 Placing Nodes on a Line or Curve Explicitly" –  Manuel Selva Jul 26 at 10:47
Glad i could help. Don't forget to accept the answer if it solved the problem. –  oerpli Jul 26 at 13:04