-
Notifications
You must be signed in to change notification settings - Fork 20
/
tikzfeynman.keys.code.tex
811 lines (800 loc) · 29.7 KB
/
tikzfeynman.keys.code.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TikZ-Feynman
% Feynman Diagrams with TikZ
% Copyright (C) 2015 Joshua Ellis
%
%
% This work may be distributed and/or modified under the terms of the GNU General
% Public License as published by the Free Software Foundation, either version 3
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE. See the LaTeX Project Public License for more
% details.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Shapes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Crossed Circle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfdeclareshape{crossed circle}
{
\inheritsavedanchors[from=circle]
\inheritanchorborder[from=circle]
\inheritanchor[from=circle]{north}
\inheritanchor[from=circle]{north west}
\inheritanchor[from=circle]{north east}
\inheritanchor[from=circle]{center}
\inheritanchor[from=circle]{west}
\inheritanchor[from=circle]{east}
\inheritanchor[from=circle]{mid}
\inheritanchor[from=circle]{mid west}
\inheritanchor[from=circle]{mid east}
\inheritanchor[from=circle]{base}
\inheritanchor[from=circle]{base west}
\inheritanchor[from=circle]{base east}
\inheritanchor[from=circle]{south}
\inheritanchor[from=circle]{south west}
\inheritanchor[from=circle]{south east}
\inheritbackgroundpath[from=circle]
\foregroundpath{
% Compute south west
\centerpoint
\pgf@xc=\radius
\advance\pgf@x by-0.707107\pgf@xc
\advance\pgf@y by-0.707107\pgf@xc
\pgf@xa=\pgf@x \pgf@ya=\pgf@y % Store coordinates
% Compute north east point
\centerpoint
\pgf@xc=\radius
\advance\pgf@x by0.707107\pgf@xc
\advance\pgf@y by0.707107\pgf@xc
\pgf@xb=\pgf@x \pgf@yb=\pgf@y % Store coordinates
\pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}}
\pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}
\pgfsetarrowsstart{}
\pgfsetarrowsend{}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Decorations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Complete Sines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Complete sines replaces the path with a whole number of sine waves.
%% Thanks to http://tex.stackexchange.com/a/134516/26980
\pgfdeclaredecoration{complete sines}{initial}
{
%% Begin by computing the overall path length and find how many sine waves we
%% can fit in. Nothing happens beyond the computation.
\state{initial}[
width=+0pt,
next state=move,
persistent precomputation={
\def\tikzfeynman@cs@angle@step{30}
\def\tikzfeynman@cs@current@angle{0}
\pgfmathsetlengthmacro{\tikzfeynman@cs@points@per@step}{
\pgfdecoratedinputsegmentlength
/ int(\pgfdecoratedinputsegmentlength
/ \pgfdecorationsegmentlength)
/ 360
* \tikzfeynman@cs@angle@step}
},
]{}
%% Move to the origin to the path
\state{move}[
width=+\tikzfeynman@cs@points@per@step,
next state=draw
]{
\pgfpathmoveto{\pgfpointorigin}
}
%% Draw the sine wave itself. This computes the value every 20 degrees and draws straight edges.
\state{draw}[
width=+\tikzfeynman@cs@points@per@step,
switch if less than=1.25*\tikzfeynman@cs@points@per@step to final, % <- bit of a hack
persistent postcomputation={
\pgfmathparse{mod(\tikzfeynman@cs@current@angle+\tikzfeynman@cs@angle@step, 360)}
\let\tikzfeynman@cs@current@angle=\pgfmathresult%
},
]{
\pgfmathparse{sin(\tikzfeynman@cs@current@angle) * \pgfmetadecorationsegmentamplitude / 2}
\tikz@decoratepathfalse
\pgfpathlineto{\pgfqpoint{0pt}{\pgfmathresult pt}}%
}
\state{final}{
\ifdim\pgfdecoratedremainingdistance>0pt\relax
\pgfpathlineto{\pgfpointdecoratedpathlast}
\fi
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Keys
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzfeynmanset{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Hooks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
execute at begin feynman/.code={},
execute at end feynman/.code={},
every feynman/.style={/tikzfeynman/every feynman@@/.append style={#1}},
every feynman@@/.style={
/tikzfeynman/.cd,
/tikzfeynman/medium,
},
execute at begin feynman@@/.code={} %% Internal version
execute at end feynman@@/.code={}, %% Internal version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Diagrams
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
every diagram/.style={/tikzfeynman/every diagram@@/.append style={#1}},
every diagram@@/.style={
/tikzfeynman/.cd,
.search also={/tikz/graphs, /tikz},
nodes={
/tikzfeynman/.cd,
/tikzfeynman/.search also={/tikz/graphs, /tikz},
/tikzfeynman/every vertex@@,
/tikzfeynman/every vertex},
edges={
/tikzfeynman/.cd,
/tikzfeynman/.search also={/tikz/graphs, /tikz},
/tikzfeynman/every edge@@,
/tikzfeynman/every edge},
/tikzfeynman/medium,
},
every inline/.style={/tikzfeynman/inline@@/.append style={#1}},
every inline@@/.style={
/tikzfeynman/small,
},
inline/.style={
/tikz/baseline={#1},
/tikzfeynman/every inline@@,
},
every small/.style={/tikzfeynman/small@@/.append style={#1}},
every small@@/.style={
/tikz/node distance=1cm,
/graph drawing/node distance=1.25cm,
/graph drawing/level distance=1cm,
/graph drawing/sibling distance=1.5cm,
/tikzfeynman/every dot@@/.append style={/tikz/minimum size=1mm},
/tikzfeynman/every crossed dot@@/.append style={/tikz/minimum size=2mm},
/tikzfeynman/every blob@@/.append style={/tikz/minimum size=0.5cm},
/tikzfeynman/arrow size=1.2pt,
/tikzfeynman/insertion/size=2.5pt,
},
small/.style={/tikzfeynman/every small@@},
every medium/.style={/tikzfeynman/medium@@/.append style={#1}},
every medium@@/.style={
/tikz/node distance=1.5cm,
/graph drawing/node distance=1.9cm,
/graph drawing/level distance=1.5cm,
/graph drawing/sibling distance=2.25cm,
},
medium/.style={/tikzfeynman/every medium@@},
every large/.style={/tikzfeynman/large@@/.append style={#1}},
every large@@/.style={
/tikz/node distance=2cm,
/graph drawing/node distance=2.5cm,
/graph drawing/level distance=2cm,
/graph drawing/sibling distance=3cm,
/tikz/graphs/edges={thick},
/tikzfeynman/every dot@@/.append style={/tikz/minimum size=2mm},
/tikzfeynman/every crossed dot@@/.append style={/tikz/minimum size=4mm},
/tikzfeynman/every blob@@/.append style={/tikz/minimum size=1cm},
/tikzfeynman/arrow size=1.6pt,
/tikzfeynman/insertion/size=4pt,
},
large/.style={/tikzfeynman/every large@@},
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Vertices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
every vertex@@/.style={
/tikz/shape=coordinate,
},
every vertex/.style={/tikzfeynman/every vertex@@/.append style={#1}},
vertex/.style={
/tikzfeynman/every vertex@@,
},
every dot@@/.style={
/tikz/shape=circle,
/tikz/graphs/as={},
/tikz/draw,
/tikz/fill,
/tikz/inner sep=0pt,
/tikz/outer sep=0pt,
/tikz/minimum size=1.5mm,
},
every dot/.style={/tikzfeynman/every dot@@/.append style={#1}},
dot/.style={
/tikzfeynman/every dot@@,
},
every square dot@@/.style={
/tikz/shape=rectangle,
},
every square dot/.style={/tikzfeynman/every square dot@@/.append style={#1}},
square dot/.style={
/tikzfeynman/every dot@@,
/tikzfeynman/every square dot@@,
},
every empty dot@@/.style={
/tikz/fill=none,
},
every empty dot/.style={/tikzfeynman/every empty dot@@/.append style={#1}},
empty dot/.style={
/tikzfeynman/every dot@@,
/tikzfeynman/every empty dot@@,
},
every crossed dot@@/.style={
/tikz/fill=none,
/tikz/shape=crossed circle,
/tikz/minimum size=3mm,
},
every crossed dot/.style={/tikzfeynman/every crossed dot@@/.append style={#1}},
crossed dot/.style={
/tikzfeynman/every dot@@,
/tikzfeynman/every crossed dot@@,
},
every blob@@/.style={
/tikz/shape=circle,
/tikz/graphs/as={},
/tikz/draw,
/tikz/fill=none,
/tikz/outer sep=0.5\pgflinewidth,
/tikz/inner sep=0pt,
/tikz/minimum size=0.75cm,
/tikz/pattern=north west lines,
},
every blob/.style={/tikzfeynman/every blob@@/.append style={#1}},
blob/.style={
/tikzfeynman/every blob@@,
},
every particle@@/.style={
/tikz/shape=rectangle,
/tikz/draw=none,
/tikz/fill=none,
/tikz/inner sep=0.3333em,
/tikz/outer sep=0.5\pgflinewidth,
},
every particle/.style={/tikzfeynman/every particle@@/.append style={#1}},
particle/.style args={#1}{
/tikzfeynman/every particle@@,
/tikz/graphs/as={#1},
},
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Edge styles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Arrow Style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
arrow size/.store in=\tikzfeynman@arrow@size,
arrow size=1.5pt,
with arrow/.style={
/tikz/decoration={
markings,
mark=at position #1 with {
\node[
transform shape,
xshift=-0.5mm,
fill,
inner sep=\tikzfeynman@arrow@size,
draw=none,
isosceles triangle
] { };
},
},
/tikz/postaction={
/tikz/decorate=true,
},
},
with reversed arrow/.style={
/tikz/decoration={
markings,
mark=at position #1 with {
\node[
transform shape,
xshift=-0.5mm,
rotate=180,
fill,
inner sep=\tikzfeynman@arrow@size,
draw=none,
isosceles triangle
] { };
},
},
/tikz/postaction={
/tikz/decorate=true,
},
},
%% Base Edge Styles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
every edge@@/.style={},
every edge/.style={/tikzfeynman/every edge@@/.append style={#1}},
%% Specific Styles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
every plain@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw
},
},
every plain/.style={/tikzfeynman/every plain@@/.append style={#1}},
plain/.style={
/tikzfeynman/every plain@@,
},
every boson@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikz/decoration={
complete sines,
amplitude=1mm,
segment length=2mm,
},
/tikz/decorate=true,
},
},
every boson/.style={/tikzfeynman/every boson@@/.append style={#1}},
boson/.style={
/tikzfeynman/every boson@@,
},
every charged boson@@/.style={
/tikzfeynman/with arrow=0.5,
},
every charged boson/.style={/tikzfeynman/every charged boson@@/.append style={#1}},
charged boson/.style={
/tikzfeynman/boson,
/tikzfeynman/every charged boson@@,
},
every anti charged boson@@/.style={
/tikzfeynman/with reversed arrow=0.5,
},
every anti charged boson/.style={/tikzfeynman/every anti charged boson@@/.append style={#1}},
anti charged boson/.style={
/tikzfeynman/boson,
/tikzfeynman/every anti charged boson@@,
},
every photon@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikz/decoration={
complete sines,
amplitude=1mm,
segment length=2mm,
},
/tikz/decorate=true,
},
},
every photon/.style={/tikzfeynman/every photon@@/.append style={#1}},
photon/.style={
/tikzfeynman/every photon@@,
},
every scalar@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikz/dashed,
},
},
every scalar/.style={/tikzfeynman/every scalar@@/.append style={#1}},
scalar/.style={
/tikzfeynman/every scalar@@,
},
every charged scalar@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikzfeynman/with arrow=0.5,
},
},
every charged scalar/.style={/tikzfeynman/every charged scalar@@/.append style={#1}},
charged scalar/.style={
/tikzfeynman/scalar,
/tikzfeynman/every charged scalar@@,
},
every anti charged scalar@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikzfeynman/with reversed arrow=0.5,
},
},
every anti charged scalar/.style={/tikzfeynman/every anti charged scalar@@/.append style={#1}},
anti charged scalar/.style={
/tikzfeynman/scalar,
/tikzfeynman/every anti charged scalar@@,
},
every ghost@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikz/dotted,
/tikz/thick,
},
},
every ghost/.style={/tikzfeynman/every ghost@@/.append style={#1}},
ghost/.style={
/tikzfeynman/every ghost@@,
},
every fermion@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikzfeynman/with arrow=0.5,
},
},
every fermion/.style={/tikzfeynman/every fermion@@/.append style={#1}},
fermion/.style={
/tikzfeynman/every fermion@@,
},
every anti fermion@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikzfeynman/with reversed arrow=0.5,
},
},
every anti fermion/.style={/tikzfeynman/every anti fermion@@/.append style={#1}},
anti fermion/.style={
/tikzfeynman/every anti fermion@@,
},
every majorana@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikzfeynman/with arrow=0.33,
/tikzfeynman/with reversed arrow=0.73,
},
},
every majorana/.style={/tikzfeynman/every majorana@@/.append style={#1}},
majorana/.style={
/tikzfeynman/every majorana@@,
},
every anti majorana@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikzfeynman/with reversed arrow=0.33,
/tikzfeynman/with arrow=0.73,
},
},
every anti majorana/.style={/tikzfeynman/every anti majorana@@/.append style={#1}},
anti majorana/.style={
/tikzfeynman/every anti majorana@@,
},
every gluon@@/.style={
/tikz/draw=none,
/tikz/decoration={name=none},
/tikz/postaction={
/tikz/draw,
/tikz/decoration={
coil,
aspect=0.75,
mirror,
segment length=1.5mm
},
/tikz/decorate=true,
},
},
every gluon/.style={/tikzfeynman/every gluon@@/.append style={#1}},
gluon/.style={
/tikzfeynman/every gluon@@,
},
%% Insertions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
insertion/.search also={/tikzfeynman,/tikz},
%% Parameters
insertion/size/.store in=\tikzfeynman@insertion@size,
insertion/size=3pt,
insertion/style/.store in=\tikzfeynman@insertion@style,
insertion/style={},
%% Styles
insertion@@/.style args={[#1]#2}{
/tikz/decoration={
markings,
mark=at position #2 with {
\tikzfeynmanset{insertion/.cd,#1}
\draw [\tikzfeynman@insertion@style] (-\tikzfeynman@insertion@size, -\tikzfeynman@insertion@size) -- (\tikzfeynman@insertion@size, \tikzfeynman@insertion@size);
\draw [\tikzfeynman@insertion@style] (-\tikzfeynman@insertion@size, \tikzfeynman@insertion@size) -- (\tikzfeynman@insertion@size, -\tikzfeynman@insertion@size);
},
},
/tikz/postaction={
/tikz/decorate=true,
},
},
insertion@@/.default={[]0.5},
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Momentum arrows
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
momentum/.search also={/tikzfeynman,/tikz},
%% Parameters
momentum/label distance/.store in=\tikzfeynman@momentum@label@distance,
momentum/label distance=0pt,
momentum/arrow distance/.store in=\tikzfeynman@momentum@arrow@distance,
momentum/arrow distance=3mm,
momentum/arrow shorten/.store in=\tikzfeynman@momentum@arrow@shorten,
momentum/arrow shorten=0.15,
momentum/label style/.store in=\tikzfeynman@momentum@label@style,
momentum/label style={},
momentum/arrow style/.store in=\tikzfeynman@momentum@arrow@style,
momentum/arrow style={},
%% Styles
momentum@@/.style args={[#1]#2}{
/tikz/preaction={
/tikz/decoration={
show path construction,
moveto code={},
lineto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@1)$)
node [pos=0.5, auto,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
curveto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentfirst)
.. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
.. (\tikzinputsegmentlast)
{ \foreach \i in {1, ..., 50} {
coordinate [pos=\tikzfeynman@momentum@arrow@shorten + (1-2 * \tikzfeynman@momentum@arrow@shorten)*\i/50] (tf@m@\i) } };
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@2)$)
foreach \i [count=\j from 3] in {2, ..., 24} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@\j)$)
}
-- ($(tf@m@25)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@26)$)
node [pos=0.5, auto,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@arrow@style] {#2}
foreach \i [count=\j from 27] in {26, ..., 49} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@\j)$)
}
-- ($(tf@m@50)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@49)$);
},
closepath code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@1)$)
node [pos=0.5, auto,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
},
/tikz/decorate=true,
},
},
momentum'@@/.style args={[#1]#2}{
/tikz/preaction={
/tikz/decoration={
show path construction,
moveto code={},
lineto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@1)$)
node [pos=0.5, auto, swap,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
curveto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentfirst)
.. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
.. (\tikzinputsegmentlast)
{ \foreach \i in {1, ..., 50} {
coordinate [pos=\tikzfeynman@momentum@arrow@shorten + (1-2 * \tikzfeynman@momentum@arrow@shorten)*\i/50] (tf@m@\i) } };
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@2)$)
foreach \i [count=\j from 3] in {2, ..., 24} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@\j)$)
}
-- ($(tf@m@25)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@26)$)
node [pos=0.5, auto, swap,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@arrow@style] {#2}
foreach \i [count=\j from 27] in {26, ..., 49} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@\j)$)
}
-- ($(tf@m@50)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@49)$);
},
closepath code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@1)$)
node [pos=0.5, auto, swap,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
},
/tikz/decorate=true,
},
},
reversed momentum@@/.style args={[#1]#2}{
/tikz/preaction={
/tikz/decoration={
show path construction,
moveto code={},
lineto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentlast) -- (\tikzinputsegmentfirst)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@1)$)
node [pos=0.5, auto, swap,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
curveto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentlast)
.. controls (\tikzinputsegmentsupportb) and (\tikzinputsegmentsupporta)
.. (\tikzinputsegmentfirst)
{ \foreach \i in {1, ..., 50} {
coordinate [pos=\tikzfeynman@momentum@arrow@shorten + (1-2 * \tikzfeynman@momentum@arrow@shorten)*\i/50] (tf@m@\i) } };
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@2)$)
foreach \i [count=\j from 3] in {2, ..., 24} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@\j)$)
}
-- ($(tf@m@25)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@26)$)
node [pos=0.5, auto, swap,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@arrow@style] {#2}
foreach \i [count=\j from 27] in {26, ..., 49} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@\j)$)
}
-- ($(tf@m@50)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@49)$);
},
closepath code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentlast) -- (\tikzinputsegmentfirst)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@1)$)
node [pos=0.5, auto, swap,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
},
/tikz/decorate=true,
},
},
reversed momentum'@@/.style args={[#1]#2}{
/tikz/preaction={
/tikz/decoration={
show path construction,
moveto code={},
lineto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentlast) -- (\tikzinputsegmentfirst)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@1)$)
node [pos=0.5,
auto,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
curveto code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentlast)
.. controls (\tikzinputsegmentsupportb) and (\tikzinputsegmentsupporta)
.. (\tikzinputsegmentfirst)
{ \foreach \i in {1, ..., 50} {
coordinate [pos=\tikzfeynman@momentum@arrow@shorten + (1-2 * \tikzfeynman@momentum@arrow@shorten)*\i/50] (tf@m@\i) } };
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@2)$)
foreach \i [count=\j from 3] in {2, ..., 24} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@\j)$)
}
-- ($(tf@m@25)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@26)$)
node [pos=0.5,
auto,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@arrow@style] {#2}
foreach \i [count=\j from 27] in {26, ..., 49} {
-- ($(tf@m@\i)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@\j)$)
}
-- ($(tf@m@50)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@49)$);
},
closepath code={
\tikzfeynmanset{momentum/.cd,#1}
\path (\tikzinputsegmentlast) -- (\tikzinputsegmentfirst)
coordinate [pos=\tikzfeynman@momentum@arrow@shorten] (tf@m@1)
coordinate [pos=1 - \tikzfeynman@momentum@arrow@shorten] (tf@m@2);
\draw [-Stealth, \tikzfeynman@momentum@arrow@style]
($(tf@m@1)!\tikzfeynman@momentum@arrow@distance!90:(tf@m@2)$)
-- ($(tf@m@2)!\tikzfeynman@momentum@arrow@distance!-90:(tf@m@1)$)
node [pos=0.5, auto,
outer sep=\tikzfeynman@momentum@label@distance,
\tikzfeynman@momentum@label@style] {#2};
},
},
/tikz/decorate=true,
},
},
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Modifiers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
half left/.style={
/tikz/bend left=90,
/tikz/looseness=1.5,
},
half right/.style={
/tikz/bend right=90,
/tikz/looseness=1.5,
},
quarter left/.style={
/tikz/bend left=45,
},
quarter right/.style={
/tikz/bend right=45,
},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Graceful Failure of LuaTeX keys
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\tikzfeynman@luatex@required@path{
\PackageWarning{tikz-feynman}{The key you tried to use '\pgfkeyscurrentpath/\pgfkeyscurrentname' requires LuaTeX. It will be ignored.}
}
\def\tikzfeynman@luatex@required@key{
\PackageWarning{tikz-feynman}{The key you tried to use '\pgfkeyscurrentpath' requires LuaTeX. It will be ignored.}
}
\ifluatex\else
\pgfkeys{
/graph drawing/.unknown/.code=\tikzfeynman@luatex@required@path,
/tikz/graphs/.unknown/.code=\tikzfeynman@luatex@required@path,
/tikz/horizontal/.code=\tikzfeynman@luatex@required@key,
/tikz/horizontal'/.code=\tikzfeynman@luatex@required@key,
/tikz/vertical/.code=\tikzfeynman@luatex@required@key,
/tikz/vertical'/.code=\tikzfeynman@luatex@required@key,
/tikz/tree layout/.code=\tikzfeynman@luatex@required@key,
/tikz/spring layout/.code=\tikzfeynman@luatex@required@key,
/tikz/layered layout/.code=\tikzfeynman@luatex@required@key,
/tikz/spring electrical layout/.code=\tikzfeynman@luatex@required@key,
/tikz/electric charge/.code=\tikzfeynman@luatex@required@key,
}
% \tikzfeynmanset{
% horizontal/.code={The key 'horizontal' requires LuaTeX. It will be ignored.},
% }
\fi
\endinput