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


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};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.