pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.15k stars 108 forks source link

TikZ creates <-> arrow when -> is specified when using node angles #1343

Closed el-sambal closed 5 months ago

el-sambal commented 5 months ago

Brief outline of the bug

I tried drawing a -> arrow between two specified points (at angles w.r.t. a node), but a <-> arrow was created instead. The MWE produces this:

image

An arrowhead appears both in the top and the bottom of the arrow, but my intended result was that it would only appear in the bottom.

(The use case is to produce two parallel edges, in a way similar to the first solution contained in user121799's answer to this question.)

Thank you!

Minimal working example (MWE)

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \node[circle,fill=cyan] (a) at (0,1) {$a$};
    \node[circle,fill=cyan] (b) at (0,-1) {$b$};
    \draw[->] (a.-120) edge (b.120);
\end{tikzpicture}

\end{document}
el-sambal commented 5 months ago

I noticed that changing \draw[->] (a.-120) edge (b.120); to \draw (a.-120) edge[->] (b.120); fixes the issue.

But I don't think this is how TikZ should behave; please correct me if I'm wrong.

ilayn commented 5 months ago

edge is a special path with its own settings. If you don't need it just use the regular path command which is --.

hmenke commented 5 months ago

You need to use \path[->] (a.-120) edge (b.120);. Otherwise you are drawing a path with no segments. To see what I mean, try \draw[->] (a.-120) edge[red] (b.120); and observe that the “wrong” arrow tip remains black.

el-sambal commented 5 months ago

Ah I see, thanks a lot for your help!