10

They say a picture says more than a thousand words. enter image description here

Is there a good reason why TikZ draws the arrows as skewed as in the left image? Is there any easy way to get good-looking, symmetric arrows as in the right picture without manually positioning the arrow tips?

Note: The line overlaps the fine tip of the arrows in the right image. This is not intentional, but adding shorten >=2pt also messes with the bend of the line.

Here's the code that produces the image above (without the captions).

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[>=latex]
    \node[draw,circle] at (0,0) (A) {A};
    \node[draw,circle] at (1,0) (B) {B};
    \draw[->] (A) to[out=45, in=135] (B);
    \draw[->] (B) to[out=-135, in=-45] (A);
    \draw[help lines] (0.5,0.5) -- (0.5,-0.5);
\end{tikzpicture}
\begin{tikzpicture}[>=latex]
    \node[draw,circle] at (0,0) (A) {A};
    \node[draw,circle] at (1,0) (B) {B};

    \draw (A) to[out=45, in=135] (B);    % Draw nice line
    \draw[<-] (B.135) -- ++(-0.1,0.066); % Add arrow tip

    \draw (A) to[out=-45, in=-135] (B);  % Draw nice line
    \draw[<-] (A.-45) -- ++(0.1,-0.066); % Add arrow tip

    \draw[help lines] (0.5,0.5) -- (0.5,-0.5);
\end{tikzpicture}

\end{document}
  • Your comment about shorten is spot on. When pgf draws an arrow, it shortens the line. But it shortens it by displacing the end-point not by shortening the actual line as the latter is computationally more difficult. I think we've had a similar question, but not sure how similar. – Loop Space Jul 6 '12 at 16:56
  • A question: Why do you add the arrow tip separately? – Alenanno Jul 6 '12 at 16:56
  • Not an answer, but have you considered using XY-pic? Its syntax for drawing small diagrams like the ones in your examples is much more concise than TikZ's, and I think its curved arrows are symmetric (although I haven't looked closely). – sampablokuper Jul 6 '12 at 18:20
  • @Alenanno I added it separately because adding it the normal way screws up the lines (as seen in the left example). It's just a hack to show how it should look approximately. – Fritz Jul 6 '12 at 21:10
  • @sampablokuper Since I already include TikZ in virtually all my documents, the XY syntax looks a bit arcane (at first glance) and learning a new language (that can do less than TikZ) doesn't sound that appealing... No, I haven't considered it ;-). But thanks for the suggestion. – Fritz Jul 6 '12 at 21:44
6

The choice latex is a bad idea because it's not possible to get a correct result. The size of the arrow is to big . Look at the result of your "fine" attempt

enter image description here

\begin{tikzpicture}[>=to]
  \node[draw,circle] at (0,0) (A) {A};
  \node[draw,circle] at (1,0) (B) {B};
  \draw[->] (A) to[out=45, in=135] (B);
  \draw[->] (B) to[out=-135, in=-45] (A);
  \draw[help lines] (0.5,0.5) -- (0.5,-0.5);
 \end{tikzpicture}    

enter image description here

In the next code outer sep=0pt is necessary

 \begin{tikzpicture}[>=to]
   \node[draw,circle,outer sep=0pt] at (0,0) (A) {A};
   \node[draw,circle,outer sep=0pt] at (1,0) (B) {B};
   \draw (A) to[out=45, in=135] (B);
   \draw[<-] (B.135) -- ++(-0.001,0.0009);
   \draw (A) to[out=-45, in=-135] (B);
   \draw[<-] (A.-45) -- ++(0.001,-0.0009);
 \end{tikzpicture}  

enter image description here

  • 2
    Yes I know that my second example is not perfext (I just wanted to make a point), sorry for that. And yes, I know I could use a different arrow tip, but I want to use the latex shape because I like it much better than the default one you suggest. If it were a bad idea to use latex like you say, then why is it in TikZ? – Fritz Jul 6 '12 at 21:08
  • It's a bad idea for me because the arrow tip latex is too long and the arc to short so It's impossible to place the head of the tip on the line and to keep the tail on the line too. The only solution is to reduce the size of the tip. – Alain Matthes Jul 7 '12 at 5:28
3

A crazy(?) idea:

\usetikzlibrary{decorations.markings}
\begin{tikzpicture}[>=latex, decoration={
      markings, mark=at position 1.0 with {\arrow{>}}}
    ]
    \node[draw,circle] at (0,0) (A) {A};
    \node[draw,circle] at (1,0) (B) {B};
    \draw[postaction={decorate}] (A) to[out=45,   in=135] (B); 
    \draw[postaction={decorate}] (B) to[out=-135, in=-45] (A);
    \draw[help lines] (0.5,0.5) -- (0.5,-0.5);
\end{tikzpicture}

enter image description here

Now the angle of the arrows is wrong, but perhaps this is preferable to the original asymmetric arc.

Also note that the asymmetry or skew is more or less noticeable depending on the kind of arrow tip used. With default arrow tips it looks perfect. With stealth arrow tips the problem appears, but less acute than with latex arrow tips.

Update If the arrowtip is allowed to overlap a bit the destination node, the result is better IMHO:

\usetikzlibrary{decorations.markings}
\begin{tikzpicture}[>=latex, decoration={
      markings, mark=at position 1 with {\draw[->] (-0.01,0) -- (0.07,0);}}
    ]
    \node[draw,circle] at (0,0) (A) {A};
    \node[draw,circle] at (1,0) (B) {B};
    \draw[postaction={decorate}] (A) to[out=45,   in=135] (B); 
    \draw[postaction={decorate}] (B) to[out=-135, in=-45] (A);
    \draw[help lines] (0.5,0.5) -- (0.5,-0.5);
\end{tikzpicture}

enter image description here

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.