编辑

编辑

我已经用 TikZ 画费曼图有一段时间了,但我从来没用过画圆环。现在我被迫处理它们,问题就来了。我玩了一下,并受到其他问题的启发,使用该calc包来画出漂亮的圆环。

这是我能做的最好的事情。请注意,在第一张图中,圆圈是乱七八糟的,而在第二张图中(没有附加标签),圆圈是正常的。理想情况下,每个半圆应该带有一个单独的标签,标签的位置应该是可调的(或者应该自动调整,具体取决于样条线的方向)。

\documentclass{article}
\usepackage{pgfplots}

\usetikzlibrary{positioning,arrows,patterns}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc} 

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

\newcommand{\semiloop}[4][]{%
        \draw[#1] let \p1 = ($(#3)-(#2)$) in (#3) arc (#4:({#4+180}):({0.5*veclen(\x1,\y1)});)
}         

\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);
\coordinate[above right=of v4,label=right:$f$] (f1);
\coordinate[below right=of v4,label=right:$f$] (f2);
\coordinate[above left =of v1,label=left :$e^+$] (e1);
\coordinate[below left =of v1,label=left :$e^-$] (e2);
\draw[fermion] (e1) -- (v1);
\draw[fermion] (v1) -- (e2);
\draw[photon] (v1) -- (v2) node[midway,above=0.1cm] {$Z$};
\draw[photon] (v3) -- (v4) node[midway,above=0.1cm] {$Z$};
\draw[fermion] (f1) -- (v4);
\draw[fermion] (v4) -- (f2);
% the next two lines are causing the mess
\semiloop[fermion]{v2}{v3}{0}  node[midway,above=0.1cm] {$f$};
\semiloop[fermion]{v3}{v2}{180} node[midway,above=0.1cm] {$\bar{f}$};
\end{tikzpicture}

\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);
\coordinate[above right=of v4,label=right:$f$] (f1);
\coordinate[below right=of v4,label=right:$f$] (f2);
\coordinate[above left =of v1,label=left :$e^+$] (e1);
\coordinate[below left =of v1,label=left :$e^-$] (e2);
\draw[fermion] (e1) -- (v1);
\draw[fermion] (v1) -- (e2);
\draw[photon] (v1) -- (v2) node[midway,above=0.1cm] {$Z$};
\draw[photon] (v3) -- (v4) node[midway,above=0.1cm] {$Z$};
\draw[fermion] (f1) -- (v4);
\draw[fermion] (v4) -- (f2);
% the next two lines behave fine, but don't have any labels
\semiloop[fermion]{v2}{v3}{0};
\semiloop[fermion]{v3}{v2}{180};
\end{tikzpicture}

\end{document}

如果有人能告诉我这里出了什么问题,或者能向我展示一种通过两点绘制圆的更优雅的方法,同时能够使用预定义的线条样式,我会非常高兴。

编辑

根据已接受的答案出现的问题,这是\listfiles

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
pgfplots.sty    2013/10/03 v1.9 Data Visualization (1.9)
    tikz.sty    2010/10/13 v2.10 (rcs-revision 1.76)
     pgf.sty    2008/01/15 v2.10 (rcs-revision 1.12)
  pgfrcs.sty    2010/10/25 v2.10 (rcs-revision 1.24)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v2.10 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
  pgfsys.sty    2010/06/30 v2.10 (rcs-revision 1.37)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v2.10 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v2.10 (rcs-revision 1.1)
  pgffor.sty    2010/03/23 v2.10 (rcs-revision 1.18)
 pgfkeys.sty    
 pgfkeys.code.tex
  pgffor.code.tex
    tikz.code.tex
  xparse.sty    2013/12/31 v4634 L3 Experimental document command parser
   expl3.sty    2014/01/07 v4646 L3 Experimental code bundle wrapper
 l3names.sty    2014/01/04 v4640 L3 Namespace for primitives
l3bootstrap.sty    2014/01/04 v4640 L3 Experimental bootstrap code
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
l3basics.sty    2014/01/04 v4642 L3 Basic definitions
 l3expan.sty    2014/01/04 v4642 L3 Argument expansion
    l3tl.sty    2013/12/27 v4625 L3 Token lists
   l3seq.sty    2013/12/14 v4623 L3 Sequences and stacks
   l3int.sty    2013/08/02 v4583 L3 Integers
 l3quark.sty    2013/12/14 v4623 L3 Quarks
   l3prg.sty    2014/01/04 v4642 L3 Control structures
 l3clist.sty    2013/07/28 v4581 L3 Comma separated lists
 l3token.sty    2013/08/25 v4587 L3 Experimental token manipulation
  l3prop.sty    2013/12/14 v4623 L3 Property lists
   l3msg.sty    2013/07/28 v4581 L3 Messages
  l3file.sty    2013/10/13 v4596 L3 File and I/O operations
  l3skip.sty    2013/07/28 v4581 L3 Dimensions and skips
  l3keys.sty    2013/12/08 v4614 L3 Experimental key-value interfaces
    l3fp.sty    2014/01/04 v4642 L3 Floating points
   l3box.sty    2013/07/28 v4581 L3 Experimental boxes
l3coffins.sty    2013/12/14 v4624 L3 Coffin code layer
 l3color.sty    2012/08/29 v4156 L3 Experimental color support
l3luatex.sty    2013/07/28 v4581 L3 Experimental LuaTeX-specific functions
l3candidates.sty    2014/01/06 v4643 L3 Experimental additions to l3kernel
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
supp-pdf.mkii
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 ***********

答案1

不会node起作用,因为你已经在定义;中使用了\semiloop。实际上

\semiloop[fermion]{v2}{v3}{0}  node[midway,above=0.1cm] {$f$};

将扩大到

\draw[fermion] let \p1 = ($(v3)-(v2)$) in (v3) arc (0:({0+180}):({0.5*veclen(\x1,\y1)});) node[midway,above=0.1cm] {$f$};

node没有\( \node)。您可以借助xparse包重新定义该命令,如下所示:

\NewDocumentCommand\semiloop{O{black}mmmO{}O{above}}
{%
\draw[#1] let \p1 = ($(#3)-(#2)$) in (#3) arc (#4:({#4+180}):({0.5*veclen(\x1,\y1)})node[midway, #6] {#5};)
}
%% Syntax
%\semiloop[fermion][<draw options>]{<first node>}{<second node>}{<angle>}[<label>][<below, default: above>];

完整代码:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{xparse}

\usetikzlibrary{positioning,arrows,patterns}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}

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

\NewDocumentCommand\semiloop{O{black}mmmO{}O{above}}
{%
\draw[#1] let \p1 = ($(#3)-(#2)$) in (#3) arc (#4:({#4+180}):({0.5*veclen(\x1,\y1)})node[midway, #6] {#5};)
}
%% Syntax
%\semiloop[fermion][<draw options>]{<first node>}{<second node>}{<angle>}[<label>][<below, default: above>];


\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);
\coordinate[above right=of v4,label=right:$f$] (f1);
\coordinate[below right=of v4,label=right:$f$] (f2);
\coordinate[above left =of v1,label=left :$e^+$] (e1);
\coordinate[below left =of v1,label=left :$e^-$] (e2);
\draw[fermion] (e1) -- (v1);
\draw[fermion] (v1) -- (e2);
\draw[photon] (v1) -- (v2) node[midway,above=0.1cm] {$Z$};
\draw[photon] (v3) -- (v4) node[midway,above=0.1cm] {$Z$};
\draw[fermion] (f1) -- (v4);
\draw[fermion] (v4) -- (f2);
% the next two lines are causing the mess
\semiloop[fermion]{v2}{v3}{0}[$f$];
\semiloop[fermion]{v3}{v2}{180}[$\bar{f}$][below];
\end{tikzpicture}

\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);
\coordinate[above right=of v4,label=right:$f$] (f1);
\coordinate[below right=of v4,label=right:$f$] (f2);
\coordinate[above left =of v1,label=left :$e^+$] (e1);
\coordinate[below left =of v1,label=left :$e^-$] (e2);
\draw[fermion] (e1) -- (v1);
\draw[fermion] (v1) -- (e2);
\draw[photon] (v1) -- (v2) node[midway,above=0.1cm] {$Z$};
\draw[photon] (v3) -- (v4) node[midway,above=0.1cm] {$Z$};
\draw[fermion] (f1) -- (v4);
\draw[fermion] (v4) -- (f2);
% the next two lines behave fine, but don't have any labels
\semiloop[fermion]{v2}{v3}{0};
\semiloop[fermion]{v3}{v2}{180};
\end{tikzpicture}

\end{document}

在此处输入图片描述

看来您需要更新 tex 发行版。添加\listfiles并比较以下内容(您可以在末尾的日志文件中找到它):

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
pgfplots.sty    2013/10/03 v1.9 Data Visualization (1.9)
    tikz.sty    2013/12/13 v3.0.0 (rcs-revision 1.142)
     pgf.sty    2013/12/18 v3.0.0 (rcs-revision 1.14)
  pgfrcs.sty    2013/12/20 v3.0.0 (rcs-revision 1.28)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.0 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
  pgfsys.sty    2013/11/30 v3.0.0 (rcs-revision 1.47)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.0 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.0 (rcs-revision 1.1)
  pgffor.sty    2013/12/13 v3.0.0 (rcs-revision 1.25)
 pgfkeys.sty    
 pgfkeys.code.tex
 pgfmath.sty    
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
  xparse.sty    2013/12/31 v4634 L3 Experimental document command parser
   expl3.sty    2014/01/07 v4646 L3 Experimental code bundle wrapper
 l3names.sty    2014/01/04 v4640 L3 Namespace for primitives
l3bootstrap.sty    2014/01/04 v4640 L3 Experimental bootstrap code
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
l3basics.sty    2014/01/04 v4642 L3 Basic definitions
 l3expan.sty    2014/01/04 v4642 L3 Argument expansion
    l3tl.sty    2013/12/27 v4625 L3 Token lists
   l3seq.sty    2013/12/14 v4623 L3 Sequences and stacks
   l3int.sty    2013/08/02 v4583 L3 Integers
 l3quark.sty    2013/12/14 v4623 L3 Quarks
   l3prg.sty    2014/01/04 v4642 L3 Control structures
 l3clist.sty    2013/07/28 v4581 L3 Comma separated lists
 l3token.sty    2013/08/25 v4587 L3 Experimental token manipulation
  l3prop.sty    2013/12/14 v4623 L3 Property lists
   l3msg.sty    2013/07/28 v4581 L3 Messages
  l3file.sty    2013/10/13 v4596 L3 File and I/O operations
  l3skip.sty    2013/07/28 v4581 L3 Dimensions and skips
  l3keys.sty    2013/12/08 v4614 L3 Experimental key-value interfaces
    l3fp.sty    2014/01/04 v4642 L3 Floating points
   l3box.sty    2013/07/28 v4581 L3 Experimental boxes
l3coffins.sty    2013/12/14 v4624 L3 Coffin code layer
 l3color.sty    2012/08/29 v4156 L3 Experimental color support
l3luatex.sty    2013/07/28 v4581 L3 Experimental LuaTeX-specific functions
l3candidates.sty    2014/01/06 v4643 L3 Experimental additions to l3kernel
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
supp-pdf.mkii
 ***********

相关内容