# Arrows, coordinates and labels

\documentclass[border=3mm,
tikz,
preview]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[
LM/.style = {
very thin,
{Bar[width=3.4mm]Straight Barb[]}-%
{Straight Barb[]Bar[width=3.4mm]}
},
every pin/.style = {
inner sep=1pt, align=center, text=teal!20!black,
font=\footnotesize\sffamily,
pin edge={{Straight Barb[]}-, solid, black}
},
]
\draw[LM] (0,0) -- node[pin=right:text] {}              + (0,0.5);
\draw[LM] (0,1) -- node[coordinate,pin=right:text] {}   + (0,0.5);
\draw[LM] (0,2) -- coordinate[pin=right:text] (a)       + (0,0.5);
\draw[LM] (0,3) -- node[inner sep=0pt,pin=right:text] {}+ (0,0.5);

\draw[LM] (2,0) -- node[pin=above:text] {}              + (0.5,0);
\draw[LM] (3,0) -- node[coordinate,pin=above:text] {}   + (0.5,0);
\draw[LM] (4,0) -- coordinate[pin=above:text] (a)       + (0.5,0);

\draw[<->]  (2,1) -- node[pin=above:text] {}              + (0.5,0);
\draw[<->]  (3,1) -- node[coordinate,pin=above:text] {}   + (0.5,0);
\draw[<->]  (4,1) -- coordinate[pin=above:text] (a)       + (0.5,0);
\end{tikzpicture}
\end{document}


Why arrows are deform when in node is present option coordinate or instead node is used coordinate with pin option?

• So far I understood that coordinate is shape with zero size, i.e. all node coordinates is merged into shape "center" coordinate. But why this damage arrows layout? I expected that size of shape should not have influence on arrows. – Zarko Mar 27 '16 at 19:53
• Coordinate is placed in expected (advertised) position, however, arrow on which lie coordinate, is damaged, as you can see from picture in my question. – Zarko Mar 27 '16 at 20:51
• Did you ever report this at sourceforge.net/p/pgf/bugs/?source=navbar? I mean, it looks like something wrong happens, so could be a bug as you say yourself. – Torbjørn T. Feb 28 '17 at 11:20
• @TorbjørnT. No, I didn't. I was not sure, if my suspicion is righteous or my understanding, how this should work, is wrong. Also I don't know, is some CVS release of TikZ already solved this. – Zarko Feb 28 '17 at 11:50
• Are there CVS releases nowadays? I think you should report it though. You can even shorten the example to \documentclass[border=3mm,tikz]{standalone} \begin{document} \begin{tikzpicture} \draw[<->] (1,1) -- node[pin=above:A] {} + (0.5,0); \draw[<->] (2,1) -- coordinate[pin=above:B] (a) + (0.5,0); \end{tikzpicture} \end{document} if needed. – Torbjørn T. Feb 28 '17 at 12:00

Let us fix the notation.

\draw[<->](A)--node[pin=Dpin]{Conline}(B);

TikZ will

• process the line (A)--(B), push it into the buffer;
• create the node Conline;
• create the node Dpin;
• process the line (Conline)edge(Dpin), draw it immediately;
• (A)--(B) is still in the buffer;
• add arrows to the last subpath in the buffer;
• so (A)<->(B) is drawn.

In the scenario above edge is handled separately so TikZ does append arrows to the right subpath.

If Conline happens to be a coordinate, then TikZ will

• process the line (A)--(B), push it into buffer;
• create the coordinate Conline;
• create the node Dpin;
• process the line (Conline)edge(Dpin), draw it immediately;
• (Conline) fires a moveto token;
• now the buffer becomes (A)--(B) (Conline);
• add arrows to the last subspath in the buffer;
• so (A)--(B) (Conline)^ is drawn.

Here ^ indicates that TikZ is trying to append arrows to a subspath consisting of a single point. Everytime it does so the arrow is always pointing upward.

In order to prevent a coordinate from firing a moveto token, you can sqap the order of (Conline) and (Dpin). That is,

\documentclass[border=3mm,tikz]{standalone}
\usetikzlibrary{arrows.meta}

\makeatletter
\long\def\tikz@@parse@pin@nonactive[#1]#2:#3:\pgf@nil{%
\tikzset{%
append after command = {%
\bgroup
[current point is local = true]
\pgfextra{\let\tikz@save@last@node=\tikzlastnode\tikz@node@is@a@labelfalse}%
node [every pin,
tikz@label@angle = #2,
anchor=@auto,
#1,
append after command = {%
(\tikzlastnode)               %%%% swap this node
edge [every pin edge,
tikz@pre@pin@edge,
tikz@pin@options]
(\tikz@save@last@node)},      %%%% with this node
tikz@label@post = \tikz@pin@distance,
tikz@pin@post] {#3}
\egroup}}}

\begin{document}

\begin{tikzpicture}[
LM/.style = {
very thin,
{Bar[width=3.4mm]Straight Barb[]}-%
{Straight Barb[]Bar[width=3.4mm]}
},
every pin/.style = {
inner sep=1pt, align=center, text=teal!20!black,
font=\footnotesize\sffamily,
pin edge={{Straight Barb[]}-, solid, black}
},
]
\draw[LM] (0,0) -- node[pin=right:text] {}              + (0,0.5);
\draw[LM] (0,1) -- node[coordinate,pin=right:text] {}   + (0,0.5);
\draw[LM] (0,2) -- coordinate[pin=right:text] (a)       + (0,0.5);
\draw[LM] (0,3) -- node[inner sep=0pt,pin=right:text] {}+ (0,0.5);

\draw[LM] (2,0) -- node[pin=above:text] {}              + (0.5,0);
\draw[LM] (3,0) -- node[coordinate,pin=above:text] {}   + (0.5,0);
\draw[LM] (4,0) -- coordinate[pin=above:text] (a)       + (0.5,0);

\draw[<->]  (2,1) -- node[pin=above:text] {}              + (0.5,0);
\draw[<->]  (3,1) -- node[coordinate,pin=above:text] {}   + (0.5,0);
\draw[<->]  (4,1) -- coordinate[pin=above:text] (a)       + (0.5,0);
\end{tikzpicture}
\end{document}


Of course this means that now pin edge={->} is pointing to Conline. This is definitely not backward-compatible. But I believe that changing the behavior of a coordinate is even more dangerous.

• sorry, i didn't notice your answer before. thank you for nice explanation, that is going on in drawing of "simple" edge (arrow) label. it is somehow unexpected that handling of coordinates is so different from nodes. from my perspective this features doesn't consider all possible use of coordinates. – Zarko Mar 31 '18 at 8:53