TikZ: Is \tikztonodes incompatible with arc? [closed]

Consider the following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.text, decorations.pathmorphing, decorations.markings, positioning, shapes}
\usetikzlibrary{}
\usetikzlibrary{calc}

\tikzset{
fermion/.style = {draw = black, postaction = {decorate},decoration = {markings,mark = at position .55 with {\arrow{>}}}},
vertex/.style = {draw,shape = circle,fill = black,minimum size = 2pt,inner sep = 0pt},
semiloop/.style = {to path={
let
\p1 = ($(\tikztotarget)-(\tikztostart)$),
\n1 = {atan2(\y1,\x1)},
\n2 = {0.5*veclen(\x1,\y1)}
in
arc[start angle=(\n1+180), delta angle=(-180), radius=(\n2)] (\tikztotarget) \tikztonodes
}},
}

\begin{document}

\begin{tikzpicture}[node distance = 1cm and 1cm]
\coordinate[vertex] (v1);
\coordinate[vertex, right = of v1] (v2);
\coordinate[vertex, right = of v2] (v3);
\coordinate[vertex, right = of v3] (v4);
\draw[fermion] (v2) to[semiloop] node[above=0.1cm] {$q$} (v3);
\end{tikzpicture}

\end{document}

It fails with

Errors:

./tex-stackexchange-question.tex:27: Missing number, treated as zero. [... to[semiloop] node[above=0.1cm] {$q$} (v3)]
./tex-stackexchange-question.tex:27: Illegal unit of measure (pt inserted). [... to[semiloop] node[above=0.1cm] {$q$} (v3)]
./tex-stackexchange-question.tex:27: Missing number, treated as zero. [... to[semiloop] node[above=0.1cm] {$q$} (v3)]
./tex-stackexchange-question.tex:27: Illegal unit of measure (pt inserted). [... to[semiloop] node[above=0.1cm] {$q$} (v3)]

If I then replace arc[...] with --, the code typesets fine. If I keep arc[...] but remove \tikztonodes, it typesets fine too. Is this a bug? Is there a workaround?

I used MacTeX 2014.

Thanks in advance for any help.

Update

First, I forgot to mention I used pdflatex and that my distro has tikz/pgf version 3, according to the documentation.

Then, thanks to @percusse and @cfr, the syntax error is gone but now the placement is not working. It has nothing to do with \tikztonodes or even with styles actually, as demonstrated by the following snippet where the half loop is drawn "by hand". I added labels to the vertices and contrasted two approaches which should be equivalent imho.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.text, decorations.pathmorphing, decorations.markings, positioning, shapes}
\usetikzlibrary{}
\usetikzlibrary{calc}

\tikzset{
fermion/.style = {draw = black, postaction = {decorate},decoration = {markings,mark = at position .55 with {\arrow{>}}}},
vertex/.style = {draw,shape = circle,fill = black,minimum size = 2pt,inner sep = 0pt},
}

\begin{document}

\begin{tikzpicture}[node distance = 1cm and 1cm]
\coordinate[vertex, label = below:$v_1$] (v1);
\coordinate[vertex, right = of v1, label = below:$v_2$] (v2);
\coordinate[vertex, right = of v2, label = below:$v_3$] (v3);
\coordinate[vertex, right = of v3, label = below:$v_4$] (v4);
\draw[fermion]
let
\p1 = ($(v3)-(v2)$),
\n1 = {atan2(\y1,\x1)},
\n2 = {0.5*veclen(\x1,\y1)}
in
(v2) arc[start angle={\n1+180}, delta angle=-180, radius=\n2] node[midway, above=0.1cm] {$q$} (v3);
\end{tikzpicture}

\begin{tikzpicture}[node distance = 1cm and 1cm]
\coordinate[vertex, label = below:$v_1$] (v1);
\coordinate[vertex, right = of v1, label = below:$v_2$] (v2);
\coordinate[vertex, right = of v2, label = below:$v_3$] (v3);
\coordinate[vertex, right = of v3, label = below:$v_4$] (v4);
\draw[fermion] (v2) arc[start angle=180, delta angle=-180, radius=0.55cm] node[midway, above=0.1cm] {$q$} (v3);
\end{tikzpicture}

\end{document}

The version with let ... in ... and the version without do not put the label q at the same place as shown on the following rendering. This is a bug, surely?

Update (bis)

For future reference, here is the list of all loaded packages with their version:

pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2014.9.23)

• everyshi 2001/05/15 v3.00 EveryShipout Package (MS)
• graphics 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
• graphicx 2014/04/25 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
• keyval 2014/05/08 v1.15 key=value parser (DPC)
• pgf 2013/12/18 v3.0.0 (rcs-revision 1.14)
• pgfcomp-version-0-65 2007/07/03 v3.0.0 (rcs-revision 1.7)
• pgfcomp-version-1-18 2007/07/23 v3.0.0 (rcs-revision 1.1)
• pgfcore 2010/04/11 v3.0.0 (rcs-revision 1.7)
• pgffor 2013/12/13 v3.0.0 (rcs-revision 1.25)
• pgfrcs 2013/12/20 v3.0.0 (rcs-revision 1.28)
• pgfsys 2013/11/30 v3.0.0 (rcs-revision 1.47)
• tikz 2013/12/13 v3.0.0 (rcs-revision 1.142)
• trig 1999/03/16 v1.09 sin cos tan (DPC)
• xcolor 2007/01/21 v2.11 LaTeX color extensions (UK)

I have filled a bug report. Thanks a lot to all of you who have given answers.

My conclusion: the Tikz is too brittle to base my work on it. I will try to develop a solution based on the PGF basic layer instead.

closed as off-topic by Paul Gessler, Jesse, user13907, Masroor, GuidoJan 21 '15 at 3:20

• 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! Try node[above=0.1cm of nodename]? – cfr Dec 9 '14 at 0:19
• Thanks @cfr but node[above=0.1cm of v2] for example gives me the same errors. – user67681 Dec 9 '14 at 0:34
• Only the 2nd fix works for me. Replacing the arc gets the same compilation error. – cfr Dec 9 '14 at 1:16
• Use arc[start angle={\n1+180}, delta angle=-180, radius=\n2] it will fix the errors but the nodes are placed wrongly. So I'll try to check it later. – percusse Dec 9 '14 at 1:47
• I think this may be off-topic because it is about a bug that has been fixed in a subsequent release of pgf. – Paul Gessler Jan 21 '15 at 1:45