I used the code below to add the text besides the line, however, it is very near to the bottom node, I wish to add the text besides the center of the line. May someone help me on this?

The code is :

\path [line] (s8) -- node [left]{hotel}(s9);

Now the result is:

enter image description here


1 Answer 1


You can specify the position either by description such as midway, or by pos= syntax, and control the node position by above, right, etc.

enter image description here


There are numerous other options, refer to the tikz/pgf manual.



\begin{tikzpicture}[thick, blue, -latex]
    \draw (0,0) -- (3,-2) node [red, below] {A};
    \draw (2,0) -- (5,-2) node [red, midway, right] {A};
    \draw (4,0) -- (7,-2) node [red, pos=0.1, above] {A};

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .