I am trying to draw a state diagram for a DFA in LaTeX using the automata library from the tikz package but am having trouble drawing some of the edges: Whenever the edge goes diagonally between two nodes, the arrowhead seemingly refuses to show up!

For example, this code


\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}

 \begin{tikzpicture}[shorten >=1pt, node distance=2cm,auto]
  \node[state,initial] (q0) {$q_0$};
  \node[state] (q1) [right of=q0] {$q_1$};
  \node[state,accepting] (q2) [below of=q1] {$q_2$};
   \path[->] (q0) edge [loop above] node {a} ()
             (q0) edge node {b} (q1)
             (q1) edge node {a} (q2)
             (q1) edge [loop above] node {b} (q1)
             (q2) edge [loop right] node {a} ()
             (q2) edge node {b} (q0);


enter image description here

which is fine except the edge between nodes q2 and q0 is lacking an arrowhead indicating that the path goes from q2 to q0.

In fact, if I adjust the position of q2 so that it is instead below q0:

      \node[state,accepting] (q2) [below of=q1] {$q_2$};
   -> \node[state,accepting] (q2) [below of=q0] {$q_2$};

now this edge has the arrowhead drawn just fine, but the edge from q1 to q2 is missing the arrowhead instead!

enter image description here

I am unsure if this is simply a limitation of tikz or of my editor (I am using AuCTeX in emacs, displaying the pdf in evince), or if I am simply not drawing the tikzpicture correctly.

Is there a simple solution for this?

closed as off-topic by TeXnician, Stefan Pinnow, Maarten Dhondt, CarLaTeX, diabonas Sep 20 '17 at 8:14

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • welcome to tex. se! in your code is missing \begin{document}. adding it and test your code i obtain expected result: all edges have arrowhead. – Zarko Sep 13 '17 at 17:58
  • @Zarko I can verify you observation. I use Miktex, Texworks and the internal PDF-viewer. No difference using Adobe Reader. – Sveinung Sep 13 '17 at 18:07
  • @Zarko @Sveinung Yep, you're both right, the real solution is that I should get a better PDF reader than evince. I just checked out the pdf auctex in xpdf instead and arrowhead rendered perfectly. Thanks, sorry for trivial question. – Adam Camilli Sep 14 '17 at 17:21
  • 1
  • 4
    I'm voting to close this question because it deals with a viewer issue. – TeXnician Sep 20 '17 at 4:10

I used the below test:



 \begin{tikzpicture}[shorten >=1pt, node distance=2cm,auto]
             \draw[->] (0,0)--(7,0);
             \draw[->] (0,0)--(7,2);
             \draw[->] (0,0)--(7,3);
             \draw[->] (0,0)--(7,4);
             \draw[->] (0,0)--(7,5);
             \draw[->] (0,0)--(7,5.5);
             \draw[->] (0,0)--(7,6);
             \draw[->] (0,0)--(6,7);
             \draw[->] (0,0)--(5,7);
             \draw[->] (0,0)--(4,7);
             \draw[->] (0,0)--(3.5,7);
             \draw[->] (0,0)--(3,7);
             \draw[->] (0,0)--(2,7);
             \draw[->] (0,0)--(1,7);
             \draw[->] (0,0)--(0,7);

             \draw[->] (0,0)--(-7,0);
             \draw[->] (0,0)--(-7,2);
             \draw[->] (0,0)--(-7,3);
             \draw[->] (0,0)--(-7,4);
             \draw[->] (0,0)--(-7,5);
             \draw[->] (0,0)--(-7,5.5);
             \draw[->] (0,0)--(-7,6);
             \draw[->] (0,0)--(-6,7);
             \draw[->] (0,0)--(-5,7);
             \draw[->] (0,0)--(-4,7);
             \draw[->] (0,0)--(-3.5,7);
             \draw[->] (0,0)--(-3,7);
             \draw[->] (0,0)--(-2,7);
             \draw[->] (0,0)--(-1,7);

             \draw[->] (0,0)--(-7,-2);
             \draw[->] (0,0)--(-7,-3);
             \draw[->] (0,0)--(-7,-4);
             \draw[->] (0,0)--(-7,-5);
             \draw[->] (0,0)--(-7,-5.5);
             \draw[->] (0,0)--(-7,-6);
             \draw[->] (0,0)--(-6,-7);
             \draw[->] (0,0)--(-5,-7);
             \draw[->] (0,0)--(-4,-7);
             \draw[->] (0,0)--(-3.5,-7);
             \draw[->] (0,0)--(-3,-7);
             \draw[->] (0,0)--(-2,-7);
             \draw[->] (0,0)--(-1,-7);

             \draw[->] (0,0)--(7,-2);
             \draw[->] (0,0)--(7,-3);
             \draw[->] (0,0)--(7,-4);
             \draw[->] (0,0)--(7,-5);
             \draw[->] (0,0)--(7,-5.5);
             \draw[->] (0,0)--(7,-6);
             \draw[->] (0,0)--(6,-7);
             \draw[->] (0,0)--(5,-7);
             \draw[->] (0,0)--(4,-7);
             \draw[->] (0,0)--(3.5,-7);
             \draw[->] (0,0)--(3,-7);
             \draw[->] (0,0)--(2,-7);
             \draw[->] (0,0)--(1,-7);

And the result for zoom=125% is:

enter image description here

But with zoom=175%:

enter image description here

Other tested pdf viewers works as expected. So, it is an unreleted problem with TeX-LaTeX and it is viewer specific but I think the answer is usefull to see what and when happens because evince is the default pdf viewer in many linux distributions and many latex users use linux.

Another question with the same issue is this one :Arrow indicating cycle between two pictures using TikZ -- missing arrowheads

So the current is a duplicate of the first and I will mark it as a duplicate of the earlier I mentioned.

I would suggest to change the title of the first even if we have to mark it as off-topic (the earlier) but not to delete it because many linux users will need it.

The problem that my example shows it that the arrow tip disappears for zooms less than 175% and directions close to any diagonal direction.

Off-topic:I will try to use this answer to fill a bug for evince and I will add the link below for anyone want to say that it affects him.

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