TikZ: \tikztonodes 是否与 arc 不兼容?

TikZ: \tikztonodes 是否与 arc 不兼容?

考虑以下代码:

\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}

它失败了

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)]

如果我用 -- 替换 arc[...],代码排版会很好。如果我保留 arc[...] 但删除 \tikztonodes,排版也会很好。这是错误吗?有解决方法吗?

我使用了 MacTeX 2014。

在此先感谢您的帮助。

更新

首先,我忘了说我使用了 pdflatex,并且根据文档,我的发行版有 tikz/pgf 版本 3。

然后,感谢 @percusse 和 @cfr,语法错误消失了,但现在放置不起作用了。它实际上与 \tikztonodes 甚至与样式无关,如以下代码片段所示,其中半循环是“手工”绘制的。我在顶点上添加了标签,并对比了两种方法,在我看来,这两种方法应该是等效的。

\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}

带标签的版本let ... in ...和不带标签的版本均不贴标签与下图所示的位置相同。

渲染

这肯定是一个错误吧?

更新(之二)

为了将来参考,这里是所有已加载包及其版本的列表:

pdfTeX,版本 3.14159265-2.6-1.40.15(TeX Live 2014)(预加载格式=pdflatex 2014.9.23)

  • everyshi 2001/05/15 v3.00 EveryShipout 包 (MS)
  • 图形 2009/02/05 v1.0o 标准 LaTeX 图形 (DPC,SPQR)
  • graphicx 2014/04/25 v1.0g 增强型 LaTeX 图形 (DPC,SPQR)
  • keyval 2014/05/08 v1.15 键=值解析器(DPC)
  • pgf 2013/12/18 v3.0.0(rcs-修订版 1.14)
  • pgfcomp-version-0-65 2007/07/03 v3.0.0(rcs-修订版 1.7)
  • pgfcomp-version-1-18 2007/07/23 v3.0.0(rcs-修订版 1.1)
  • pgfcore 2010/04/11 v3.0.0 (rcs-修订版 1.7)
  • pgffor 2013/12/13 v3.0.0 (rcs-修订版 1.25)
  • pgfrcs 2013/12/20 v3.0.0 (rcs-修订版 1.28)
  • pgfsys 2013/11/30 v3.0.0 (rcs-修订版 1.47)
  • tikz 2013/12/13 v3.0.0 (rcs-修订版 1.142)
  • trig 1999/03/16 v1.09 正弦余弦正切 (DPC)
  • xcolor 2007/01/21 v2.11 LaTeX 颜色扩展(英国)

我已经填写了错误报告。非常感谢所有给出答案的人。

我的结论是:Tikz 太脆弱,不适合作为我的工作基础。我将尝试开发基于 PGF 基础层的解决方案。

相关内容