Debian Codegraph @

texmf-dist/tex/latex/tikz-feynhand/tikzlibraryfeynhand.code.tex

raw
1
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % TikZ-FeynHand, Version 1.1.0 of 2019/08/19
5 % Feynhand Diagrams with TikZ (LaTex manual version)
6 % Copyright (C) 2019 Max Dohse
7 % Copyright (C) 2016 Joshua Ellis
8 %
9 % This LaTeX file and the whole package are free:
10 % you can redistribute it and/or modify it under the
11 % terms of the GNU General Public License as published by the Free Software Foundation,
12 % either version 3 of the License, or (at your option) any later version.
13 %
14 % This file is a modification of the file tikzlibraryfeynman.code.tex
15 % of the package tikz-feynman (version 1.1.0 of 2016/02/05)
16 % which is available online at https://ctan.org/pkg/tikz-feynman
17 % for a list of changes, see the file CHANGES.TXT
18 %
19 % available at https://ctan.org/pkg/tikz-feynhand
20 % The Current Maintainer of this work is Max Dohse.
21 %
22 % This program is distributed in the hope that it will be useful, but WITHOUT
23 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24 % FOR A PARTICULAR PURPOSE.
25 %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 %
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 %% Pre-requisites
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 \usetikzlibrary{
32 arrows.meta,
33 calc,
34 decorations,
35 decorations.markings,
36 decorations.pathmorphing,
37 decorations.pathreplacing,
38 external,
39 patterns,
40 positioning,
41 shapes.geometric,
42 }
43
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %% Function definitions
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47
48 %% Miscellaneous functions
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 \def\tikzfeynhand@empty{}
51
52 %% Key Manager
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 %% Setup the tikz-feynhand key family
55 \pgfkeys{
56 /tikzfeynhand/.is family,
57 /tikzfeynhand/.search also={/tikz},
58 }
59
60 %% |\tikzfeynhandset| allows keys that belong with tikz-feynhand to be easily set.
61 \def\tikzfeynhandset{\pgfqkeys{/tikzfeynhand}}
62
63 %% Version check
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %% Check which version is expected and which is installed
66 \def\tikzfeynhand@compat@parse#1.#2.#3\pgfeov{
67 \edef\tikzfeynhand@compat@major{#1}
68 \edef\tikzfeynhand@compat@minor{#2}
69 \edef\tikzfeynhand@compat@patch{#3}
70 \edef\tikzfeynhand@compat{#1.#2.#3}
71 }
72 \let\tikzfeynhand@compat=\tikzfeynhand@empty
73 \pgfkeyslet{/tikzfeynhand/compat/.@cmd}{\tikzfeynhand@compat@parse}
74 \ProcessPgfPackageOptions{/tikzfeynhand}
75
76 \AtBeginDocument{
77 \ifx\tikzfeynhand@version\tikzfeynhand@compat\else
78 \ifx\tikzfeynhand@compat\tikzfeynhand@empty
79 \PackageWarning{tikz-feynhand}{Consider loading TikZ-Feynhand with \string\usepackage[compat=\tikzfeynhand@version]{tikz-feynhand} so that you can be warned if TikZ-Feynhand changes.}
80 \else
81 \ifx\tikzfeynhand@compat@major\tikzfeynhand@version@major
82 \ifx\tikzfeynhand@compat@minor\tikzfeynhand@version@minor
83 \ifx\tikzfeynhand@compat@patch\tikzfeynhand@version@patch\else
84 \PackageInfo{tikz-feynhand}{The preamble requested version \tikzfeynhand@compat, but the system version is \tikzfeynhand@version. This should cause no issue.}
85 \fi
86 \else
87 \PackageWarning{tikz-feynhand}{The preamble requested version \tikzfeynhand@compat, but the system version is \tikzfeynhand@version. This may change some diagrams.}
88 \fi
89 \else
90 \PackageError{tikz-feynhand}{The preamble requested version \tikzfeynhand@compat, but the system version is \tikzfeynhand@version. They are most likely incompatible. Please download the appropriate version from jpellis.me/projects/tikz-feynhand.}
91 \fi
92 \fi
93 \fi
94 }
95
96 %% Feynhand Environment
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98
99 %% Provide `\begin{feynhand} ... \end{feynhand}` within TikZ pictures.
100 \tikzaddtikzonlycommandshortcutlet\feynhand\tikzfeynhand@environment@feynhand
101 \tikzaddtikzonlycommandshortcutlet\endfeynhand\endtikzfeynhand@environment@feynhand
102
103 %% \begin{feynhand}...\end{feynhand}
104 \def\tikzfeynhand@environment@feynhand{%
105 \pgfutil@ifnextchar[{\tikzfeynhand@environment@feynhand@opt}
106 {\tikzfeynhand@environment@feynhand@opt[]}}
107
108 \def\tikzfeynhand@environment@feynhand@opt[#1]{%
109 \begingroup
110 %% Local overrides
111 \let\tikz@@scan@fig=\tikzfeynhand@scan@fig
112 %% Local commands
113 \let\vertex=\tikzfeynhand@commands@vertex
114 \let\propagator=\tikzfeynhand@commands@propagator
115 \let\propag=\propagator
116 %% Opening hooks
117 \scope
118 \tikzfeynhand@tikz@search@tikzfeynhand
119 \pgfkeys{/tikzfeynhand/every feynhand@@,#1}
120 \pgfkeysvalueof{/tikzfeynhand/execute at begin feynhand@@}%
121 \pgfkeysvalueof{/tikzfeynhand/execute at begin feynhand}%
122 }
123
124 \def\endtikzfeynhand@environment@feynhand{%
125 %% Closing hooks
126 \pgfkeysvalueof{/tikzfeynhand/execute at end feynhand}%
127 \pgfkeysvalueof{/tikzfeynhand/execute at end feynhand@@}%
128 \endscope
129 \endgroup
130 }
131
132 %%% Allow empty nodes
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 \newif\iftikzfeynhandallowemptynode
135 \newif\iftikzfeynhandvertex
136 \def\tikzfeynhand@scan@fig{%
137 \pgfutil@ifnextchar a{\tikz@fig@scan@at}
138 {\pgfutil@ifnextchar({\tikz@fig@scan@name}
139 {\pgfutil@ifnextchar[{\tikz@fig@scan@options}%
140 {\pgfutil@ifnextchar\bgroup{\tikz@fig@main}%
141 {\iftikzfeynhandvertex%
142 \tikzset{/tikzfeynhand/every vertex@@}%
143 \iftikzfeynhandallowemptynode%
144 \else%
145 \tikzset{/tikzfeynhand/particle}%
146 \fi%
147 \fi%
148 \tikz@fig@main{}
149 }
150 }
151 }
152 }
153 }
154
155 %% Include /tikzfeynhand in the search path
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 \def\tikzfeynhand@tikz@search@tikzfeynhand{%
158 \pgfkeys{/tikz/.unknown/.code=%
159 \let\tikz@key\pgfkeyscurrentname%
160 %% Is it a tikzfeynhand key?
161 \pgfkeys{/tikzfeynhand/\tikz@key/.try={##1}}%
162 \ifpgfkeyssuccess%
163 \else%
164 %% Is it a pgf key?
165 \pgfkeys{/pgf/\tikz@key/.try={##1}}%
166 \ifpgfkeyssuccess%
167 \else%
168 \expandafter\pgfutil@in@\expandafter!\expandafter{\tikz@key}%
169 \ifpgfutil@in@%
170 %% this is a color!
171 \expandafter\tikz@addoption\expandafter{\expandafter\tikz@compat@color@set\expandafter{\tikz@key}}%
172 \edef\tikz@textcolor{\tikz@key}%
173 \else%
174 \pgfutil@doifcolorelse{\tikz@key}
175 {%
176 \expandafter\tikz@addoption\expandafter{\expandafter\tikz@compat@color@set\expandafter{\tikz@key}}%
177 \edef\tikz@textcolor{\tikz@key}%
178 }%
179 {%
180 %% Ok, second chance: This might be an arrow specification:
181 \expandafter\pgfutil@in@\expandafter-\expandafter{\tikz@key}%
182 \ifpgfutil@in@%
183 %% Ah, an arrow spec!
184 \expandafter\tikz@processarrows\expandafter{\tikz@key}%
185 \else%
186 %% Ok, third chance: A shape!
187 \expandafter\ifx\csname pgf@sh@s@\tikz@key\endcsname\relax%
188 \pgfkeys{/errors/unknown key/.expand
189 once=\expandafter{\expandafter/\expandafter t\expandafter
190 i\expandafter k\expandafter z\expandafter/\tikz@key}{##1}}%
191 \else%
192 \edef\tikz@shape{\tikz@key}%
193 \fi%
194 \fi%
195 }%
196 \fi%
197 \fi%
198 \fi%
199 }
200 }
201
202
203 %% Vertex
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 %% SEE ALSO \vertex above!
206 %% Adapted from |\coordinate| code
207 \def\tikzfeynhand@commands@vertex{%
208 \path \pgfextra{\tikzfeynhandallowemptynodetrue}
209 \pgfextra{\tikzfeynhandvertextrue}
210 node}
211
212 %% Propagators
213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 \newcommand{\tikzfeynhand@commands@propagator}[1][]{\draw [#1]}
215
216 %% Optional argument in style key
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218 \def\tikzfeynhand@key@opt#1[#2]#3\pgfeov{%
219 \tikzfeynhandset{#1={[#2]#3}}}
220
221 %% Insertion
222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 \def\tikzfeynhand@insertion{%
224 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{insertion@@}}
225 {\tikzfeynhand@key@opt{insertion@@}[]}}
226 \pgfkeyslet{/tikzfeynhand/insertion/.@cmd}{\tikzfeynhand@insertion}
227
228 %% Slash
229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230 \def\tikzfeynhand@slash{%
231 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{slash@@}}
232 {\tikzfeynhand@key@opt{slash@@}[]}}
233 \pgfkeyslet{/tikzfeynhand/slash/.@cmd}{\tikzfeynhand@slash}
234
235 %% Backslash
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 \def\tikzfeynhand@backslash{%
238 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{backslash@@}}
239 {\tikzfeynhand@key@opt{backslash@@}[]}}
240 \pgfkeyslet{/tikzfeynhand/backslash/.@cmd}{\tikzfeynhand@backslash}
241
242 %% Momentum
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 \def\tikzfeynhand@momentum@std{%
245 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{momentum@@}}
246 {\tikzfeynhand@key@opt{momentum@@}[]}}
247 \pgfkeyslet{/tikzfeynhand/momentum/.@cmd}{\tikzfeynhand@momentum@std}
248
249 \def\tikzfeynhand@momentum@stdp{%
250 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{momentum'@@}}
251 {\tikzfeynhand@key@opt{momentum'@@}[]}}
252 \pgfkeyslet{/tikzfeynhand/momentum'/.@cmd}{\tikzfeynhand@momentum@stdp}
253
254 \def\tikzfeynhand@momentum@stdr{%
255 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{reversed momentum@@}}
256 {\tikzfeynhand@key@opt{reversed momentum@@}[]}}
257 \pgfkeyslet{/tikzfeynhand/reversed momentum/.@cmd}{\tikzfeynhand@momentum@stdr}
258
259 \def\tikzfeynhand@momentum@stdrp{%
260 \pgfutil@ifnextchar[{\tikzfeynhand@key@opt{reversed momentum'@@}}
261 {\tikzfeynhand@key@opt{reversed momentum'@@}[]}}
262 \pgfkeyslet{/tikzfeynhand/reversed momentum'/.@cmd}{\tikzfeynhand@momentum@stdrp}
263
264 % short versions of momentum styles
265 \pgfkeyslet{/tikzfeynhand/rmomentum/.@cmd}{\tikzfeynhand@momentum@stdr}
266 \pgfkeyslet{/tikzfeynhand/rmomentum'/.@cmd}{\tikzfeynhand@momentum@stdrp}
267
268 \pgfkeyslet{/tikzfeynhand/mom/.@cmd}{\tikzfeynhand@momentum@std}
269 \pgfkeyslet{/tikzfeynhand/mom'/.@cmd}{\tikzfeynhand@momentum@stdp}
270
271 \pgfkeyslet{/tikzfeynhand/revmom/.@cmd}{\tikzfeynhand@momentum@stdr}
272 \pgfkeyslet{/tikzfeynhand/revmom'/.@cmd}{\tikzfeynhand@momentum@stdrp}
273
274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
275 %% Styles
276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277
278 \input tikzfeynhand.keys.code.tex
279
280 \endinput