1

I started learning Tikz using the Tikz PGF manual and so far everything has been very intuitive and easy to follow.

When learning about commands I decided to do a simple test:

\begin{tikzpicture}
  \draw[fill] (0,0) circle (2pt) -- (4,0) circle (2pt) -- (8,0) circle (8,0);
\end{tikzpicture}

And that returns the expected three circles joined by a line

3 circles joined by a line

Now, I wanted those three circles joined by a line with an arrow so I changed the code to be like this:

\begin{tikzpicture}
  \draw[->] (0,0) circle (2pt) -- (4,0) circle (2pt) -- (8,0) circle (2pt);
\end{tikzpicture}

But my surprise, the three circles are joined by a line but without an arrow tip!

I tried using the [arrows=->] option and nothing. I noticed as well the lines are getting up to the center of the circle, not outside, what am I doing wrong? what did I misunderstand?

Thanks a lot for your help to this Tikz noob :)

2
  • Welcome! The last path in the path is a circle. At which point should the arrow be attached in your opinion? There is no arrow because in \draw[-stealth] (0,0) circle[radius=1cm]; there is also no arrow.
    – user194703
    Apr 13 '20 at 19:50
  • Thanks @Schrödinger'scat your comment was enough to see my mistake! Tikz doesn't know where the circle starts or end so I tried again with a node instead of a circle (in reality a node drawn with a circle) and that made the trick.
    – cprieto
    Apr 14 '20 at 11:26
1

@OP: You are right about this "... everything has been very intuitive and easy to follow", and leraning by testing is surely a good way. However, TikZ has its own features that you need to be famimilar with: node, style, +, ++, ...

Here is what I guess you might want to archive. Hope you enjoy with TikZ!

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \i in {0,1,2}
\path (4*\i,0) node (A\i) [circle,draw=red,minimum size=2pt]{};

\draw[->] (A0)--(A1);
\draw[->] (A1)--(A2);
\end{tikzpicture}   
\end{document}

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.