Debian Codegraph @

texmf-dist/source/latex/hep-graphic/hep-graphic-implementation.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2023 by Jan Hajer
4 % -----------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3c
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % \fi
17 %
18 % \iffalse
19 %
20 %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
21 %<package>\ProvidesPackage{hep-graphic}[2025/09/01 v1.4 Graphics in High Energy Physics]
22 %<plot>\ProvidesPackage{hep-plot}[2025/09/01 v1.4 Plots in High Energy Physics]
23 %<feynman>\ProvidesPackage{hep-feynman}[2025/09/01 v1.4 Feynman diagrams in High Energy Physics]
24 %<documentation>\ProvidesFile{hep-graphic-documentation.tex}[2025/09/01 v1.4 HEP-graphic documentation]
25 %
26 %<*documentation>
27 %
28 \RequirePackage[l2tabu, orthodox]{nag}
29 \documentclass{ltxdoc}
30
31 \renewcommand*\theCodelineNo{\rmfamily\tstyle\footnotesize\arabic{CodelineNo}}
32 \AtBeginEnvironment{macrocode}{\renewcommand*{\ttdefault}{clmt}}
33 \renewcommand*{\MacroFont}{\codestyle}
34 \AtBeginDocument{\DeleteShortVerb{\|}}
35 \AtBeginDocument{\MakeShortVerb{\"}}
36 \EnableCrossrefs
37 \CodelineIndex
38 \RecordChanges
39
40 \usepackage{hologo}
41
42 \usepackage[parskip,oldstyle,font=10pt]{hep-paper}
43 \bibliography{bibliography}
44 %</documentation>
45
46 %<*driver>
47 \expandafter\newif\csname ifshort\endcsname
48 \shortfalse
49 \begin{document}
50 \DocInput{hep-graphic-implementation.dtx}
51 \end{document}
52 %</driver>
53 %
54 % \fi
55 %
56 % \CheckSum{130}
57 %
58 % \CharacterTable
59 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
60 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
61 % Digits \0\1\2\3\4\5\6\7\8\9
62 % Exclamation \! Double quote \" Hash (number) \#
63 % Dollar \$ Percent \% Ampersand \&
64 % Acute accent \' Left paren \( Right paren \)
65 % Asterisk \* Plus \+ Comma \,
66 % Minus \- Point \. Solidus \/
67 % Colon \: Semicolon \; Less than \<
68 % Equals \= Greater than \> Question mark \?
69 % Commercial at \@ Left bracket \[ Backslash \\
70 % Right bracket \] Circumflex \^ Underscore \_
71 % Grave accent \` Left brace \{ Vertical bar \|
72 % Right brace \} Tilde \~}
73 %
74 % \changes{v1.1}{2022/11/01}{Bug fixes.}
75 % \changes{v1.2}{2023/07/01}{Bug fixes.}
76 % \changes{v1.3}{2024/11/01}{Bug fixes.}
77 % \changes{v1.4}{2025/09/01}{Bug fixes.}
78 %
79 % \ifshort
80 %<*documentation>
81 % \fi
82 %
83 \GetFileInfo{hep-graphic.sty}
84
85 % \title{The \software{hep-graphic} package\thanks{This document corresponds to \software{hep-graphic}~\fileversion.}}
86 \title{The \software{hep-graphic} package\thanks{This document corresponds to \software{hep-graphic}~v1.0.}}
87 \subtitle{Plot macros}
88 \author{Jan Hajer \email{[email protected]}}
89 % \date{\filedate}
90 \date{2023/07/01}
91
92 % \ifshort
93 \begin{document}
94 % \fi
95
96 \newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em}
97
98 \maketitle
99
100 \begin{abstract}
101 The \software{hep-graphic} is a convenience wrapper for the \software{pgf/tikz}, \software{pgfplots}, and \software{standalone} packages.
102 \end{abstract}
103
104 \section{Graphic}
105
106 After loading the "hep-graphic" package the \software{pgf/tikz} \cite{pgf} and \software{standalone} \cite{standalone} packages are loaded and externalisation is activated.
107 The "plot" and "feynman" options load the neccessary packages for plotting and feynman diagrams.
108 The macro "\includetikz"\oarg{width}\marg{name} loads "tikz" pictures.
109
110 \subsection{Plot}
111
112 The \software{hep-plot} package loads the \software{pgfplots} package \cite{pgfplots} and applies some optimisation.
113
114 \subsection{Feynman}
115
116 The \software{hep-feynman} package loads the \software{tikz-feynman} package \cite{tikz-feynman} and applies some optimisation.
117
118 % \ifshort
119 \printbibliography
120
121 \end{document}
122 %
123 %</documentation>
124 % \fi
125 %
126 % \StopEventually{
127 % \printbibliography
128 % \PrintChanges
129 % }
130 %
131 % \appendix
132 %
133 % \section{Implementation}
134 %
135 % \subsection{Graphic}
136 %
137 %<*package>
138 %
139 % Define a hepgraphic namespace for the options using the \software{kvoptions} package \cite{kvoptions}.
140 % \begin{macrocode}
141 \RequirePackage{kvoptions}
142 \SetupKeyvalOptions{
143 family=hepgraphic,
144 prefix=hepgraphic@
145 }
146 % \end{macrocode}
147 %
148 % \begin{macro}{plot}
149 % Define the "extern" option to activate externalisation into the declared folder.
150 % \begin{macrocode}
151 \DeclareStringOption{extern}[.]
152 % \end{macrocode}
153 % \end{macro}
154 %
155 % \begin{macro}{plot}
156 % Define the "plot" switch for loading plot code.
157 % \begin{macrocode}
158 \DeclareBoolOption[false]{plot}
159 % \end{macrocode}
160 % \end{macro}
161 %
162 % \begin{macro}{feynman}
163 % Define the "feynman" switch for loading feynman code.
164 % \begin{macrocode}
165 \DeclareBoolOption[false]{feynman}
166 % \end{macrocode}
167 % \end{macro}
168 %
169 % \begin{macrocode}
170 \ProcessKeyvalOptions*
171 % \end{macrocode}
172 %
173 % Load the \software{hep-plot} and \software{hep-feynman} packages when required.
174 % \begin{macrocode}
175 \ifhepgraphic@plot\RequirePackage{hep-plot}\fi
176 \ifhepgraphic@feynman\RequirePackage{hep-feynman}\fi
177 % \end{macrocode}
178 %
179 % Load the \software{tikz} package with the \software{external} library \cite{pgf}.
180 % \begin{macrocode}
181 \RequirePackage{tikz}
182 \ifx\hepgraphic@extern\@empty\else
183 \usetikzlibrary{external}
184 \tikzexternalize[
185 % optimize=false,
186 only named=true,
187 ]
188 \tikzsetexternalprefix{\hepgraphic@extern/}
189 \fi
190 % \end{macrocode}
191 %
192 % \begin{macro}{\graphicpath}
193 % Load the \software{standalone} package \cite{standalone} and define the "\graphicpath" pointing to the folder with "pgf" files.
194 % \begin{macrocode}
195 \RequirePackage{tikzscale}
196 \def\hep@graphic@path{.}
197 \newcommand*{\graphicpath}[1]{\def\hep@graphic@path{#1}}
198 % \end{macrocode}
199 % \end{macro}
200 % \begin{macro}{\includetikz}
201 % Define a macro to include "tikz" figures using the \software{xparse} package \cite{xparse}.
202 % \begin{macrocode}
203 \RequirePackage{xparse}
204 \NewDocumentCommand{\includepgf}{sO{}m}{%
205 \tikzsetnextfilename{#3}%
206 \IfBooleanTF{#1}{%
207 \includegraphics{\hep@graphic@path/#3}%
208 }{%
209 \pgfplotsset{#2}
210 \includegraphics[#2]{\hep@graphic@path/#3}%
211 }%
212 }
213 \newcommand*{\includefeynman}[1]{%
214 \vcenter{\hbox{\includegraphics{\hep@graphic@path/#1}}}%
215 }
216 % \end{macrocode}
217 % \end{macro}
218 %
219 %</package>
220 %
221 % \subsection{Plots}
222 %
223 %<*plot>
224 %
225 % Load the \software{pgf/tikz} package \cite{pgf}.
226 % \begin{macrocode}
227 \RequirePackage{tikz}
228 % \end{macrocode}
229 %
230 % \begin{macro}{dashdotdotdotted}
231 % \begin{macro}{dashdotdotdotdotted}
232 % Add new line styles.
233 % \begin{macrocode}
234 \tikzset{
235 dashdotdotdotted/.style={dash pattern=on 3pt off 2pt
236 on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt
237 on \the\pgflinewidth off 2pt
238 },
239 dashdotdotdotdotted/.style={dash pattern=on 3pt off 2pt
240 on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt
241 on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt
242 },
243 dotdotdashed/.style={dash pattern=on 3pt off 2pt
244 on 3pt off 2pt on \the\pgflinewidth off 2pt
245 },
246 dotdotdotdashed/.style={dash pattern=on 3pt off 2pt
247 on 3pt off 2pt on 3pt off 2pt on \the\pgflinewidth off 2pt
248 },
249 }%
250 % \end{macrocode}
251 % \end{macro}
252 % \end{macro}
253 % Change thousand separator
254 % \begin{macrocode}
255 \pgfkeys{/pgf/number format/.cd,1000 sep={\,}}%
256 % \end{macrocode}
257 %
258 % Load the \software{pgfplots} package \cite{pgfplots} and set global options.
259 % \begin{macrocode}
260 \RequirePackage{pgfplots}
261 \pgfplotsset{
262 compat=newest,
263 width=\linewidth,
264 height=\linewidth,
265 enlargelimits=false,
266 }
267 % \end{macrocode}
268 %
269 % Fix glitch.
270 % \begin{macrocode}
271 \pgfplotsset{
272 every y tick scale label/.append style={
273 inner sep=1pt,
274 xshift=-1pt,
275 yshift=-1pt,
276 },
277 }
278 % \end{macrocode}
279 %
280 % Set default font size
281 % \begin{macrocode}
282 \pgfplotsset{
283 legend style={font=\footnotesize},
284 tick label style={font=\footnotesize},
285 label style={font=\small},
286 title style={font=\small},
287 max space between ticks=30,
288 }
289 % \end{macrocode}
290 % \begin{macro}{three panels}
291 % Set font size three panel versions
292 % \begin{macrocode}
293 \pgfplotsset{
294 three panels/.style={
295 legend style={font=\scriptsize},
296 tick label style={font=\scriptsize},
297 label style={font=\footnotesize},
298 title style={font=\footnotesize},
299 max space between ticks=25,
300 /tikz/mark size=1.5pt,
301 major tick length=1mm,
302 minor tick length=0.66mm,
303 every axis title shift=0pt,
304 },
305 }
306 % \end{macrocode}
307 % \end{macro}
308 %
309 % \begin{macro}{colors}
310 % \begin{macro}{line styles}
311 % \begin{macro}{marks}
312 % \begin{macro}{horizontal marks}
313 % \begin{macro}{vertical marks}
314 % Create cycle lists
315 % \begin{macrocode}
316 \colorlet{darkgreen}{green!50!black}
317 \pgfplotscreateplotcyclelist{colors}{
318 blue, red, darkgreen, violet, orange, yellow!75!orange,
319 brown, black
320 }
321 \pgfplotscreateplotcyclelist{line styles}{
322 solid, dashed, densely dotted, dashdotted,
323 dashdotdotted, dotdotdashed, dashdotdotdotted, dotdotdotdashed, dashdotdotdotdotted
324 }
325 \pgfplotscreateplotcyclelist{marks}{
326 mark=-, mark=|, mark=Mercedes star flipped, mark=Mercedes star, mark=+,
327 mark=x, mark=star, mark=asterisk, mark=10-pointed star
328 }
329 \pgfplotscreateplotcyclelist{vertical marks}{
330 mark=|, mark=Mercedes star flipped, mark=Mercedes star, mark=x, mark=star,
331 mark=asterisk, mark=10-pointed star
332 }
333 \pgfplotscreateplotcyclelist{horizontal marks}{
334 mark=-, mark=Mercedes star flipped, mark=Mercedes star, mark=x, mark=star,
335 mark=asterisk, mark=10-pointed star
336 }
337 \pgfplotscreateplotcyclelist{star marks}{
338 mark=Mercedes star flipped, mark=Mercedes star, mark=x, mark=star,
339 mark=asterisk, mark=10-pointed star
340 }
341 \pgfplotsset{
342 cycle multiindex* list={colors\nextlist line styles},
343 }
344 % \end{macrocode}
345 % \end{macro}
346 % \end{macro}
347 % \end{macro}
348 % \end{macro}
349 % \end{macro}
350 %
351 % \begin{macro}{\cyclelistshift}
352 % Define the "\cyclelistshift" macro skiping one step in a cyclelist.
353 % Must be used in combination with "\setcounter{cyclelistshift}{0}".
354 % \begin{macrocode}
355 \newcounter{cyclelistshift}
356 \newcommand*\cyclelistshift{
357 \globaldefs=1\relax
358 % \stepcounter{cyclelistshift}
359 \addtocounter{cyclelistshift}{1}
360 \pgfplotsset{cycle list shift=\value{cyclelistshift}}
361 \globaldefs=0\relax
362 }
363 % \end{macrocode}
364 % \end{macro}
365 %
366 % \begin{macro}{rainbow}
367 % Define the "rainbow" colormap.
368 % \begin{macrocode}
369 \pgfplotsset{
370 colormap={rainbow}{
371 color(0)=(violet); color(1)=(blue); color(2)=(darkgreen);
372 color(3)=(yellow); color(4)=(orange); color(5)=(red)
373 },
374 }
375 % \end{macrocode}
376 % \end{macro}
377 %
378 % \begin{macro}{legend}
379 % Set the legend style.
380 % \begin{macrocode}
381 \pgfplotsset{
382 legend cell align=left,
383 legend style={
384 at={(1,1)},
385 anchor=north east,
386 inner sep=1pt,
387 outer sep=6pt,
388 draw=none,
389 fill opacity=.9,
390 draw opacity=1,
391 text opacity=1,
392 cells={align=left},
393 /tikz/every even column/.append style={column sep=.5em},
394 % fill=none,
395 },
396 }
397 % \end{macrocode}
398 % \end{macro}
399 %
400 % \begin{macro}{contour legend}
401 % Define basic contour legend
402 % \begin{macrocode}
403 \pgfplotsset{
404 contour legend/.style={
405 % contour prepared={labels=false},
406 colorbar sampled line,
407 colorbar style={
408 mark size=7pt,
409 mark options={semithick},
410 tickwidth=0pt,
411 subtickwidth=0pt,
412 },
413 },
414 }
415 % \end{macrocode}
416 % \end{macro}
417 %
418 % \begin{macro}{contour legend x}
419 % Define horizontal contour legend.
420 % \begin{macrocode}
421 % \usepgfplotslibrary{colormaps}
422 \pgfplotsset{
423 contour legend x/.style={
424 colorbar horizontal,
425 colormap name=rainbow,
426 % colormap/rainbow,
427 contour legend,
428 colorbar style={
429 at={(0.5,1.025)},
430 anchor=south,
431 mark=|,
432 axis x line*=top,
433 axis y line=none,
434 xticklabel pos=upper,
435 title style={
436 at={(-0.05,1)},
437 anchor=east,
438 },
439 xlabel style={
440 at={(-0.06,1)},
441 anchor=south east,
442 },
443 },
444 },
445 }
446 % \end{macrocode}
447 % \end{macro}
448 %
449 %
450 % \begin{macro}{contour legend y}
451 % Define vertical contour legend.
452 % \begin{macrocode}
453 \pgfplotsset{
454 contour legend y/.style={
455 contour legend,
456 colorbar style={
457 at={(1.025,0.5)},
458 anchor=west,
459 mark=-,
460 axis x line=none,
461 title style={
462 at={(1,-0.1)},
463 anchor=north west,
464 },
465 },
466 },
467 }
468 % \end{macrocode}
469 % \end{macro}
470 %
471 % \begin{macro}{contour plot x}
472 % \begin{macro}{contour plot y}
473 % Define vertical contour legend.
474 % \begin{macrocode}
475 \pgfplotsset{
476 contour plot x/.style={
477 contour legend x,
478 contour prepared={labels=false},
479 },
480 contour plot y/.style={
481 contour legend y,
482 contour prepared={labels=false},
483 },
484 }
485 % \end{macrocode}
486 % \end{macro}
487 % \end{macro}
488 %
489 % \begin{macro}{error legend}
490 % Define error legend.
491 % \begin{macrocode}
492 \pgfplotsset{
493 error legend/.style n args={3}{
494 legend image code/.code={
495 \draw[draw=none,fill=#1,#3](0mm,-1mm)rectangle(6mm,1mm);
496 \draw[draw=#1,#2] (0mm,0mm)--(6mm,0mm);
497 }
498 },
499 }
500 % \end{macrocode}
501 % \end{macro}
502 %
503 % \begin{macro}{\addlegendtitle}
504 % Define a legend title macro.
505 % \begin{macrocode}
506 \newcommand*{\addlegendtitle}[2][]{
507 \addlegendimage{empty legend}
508 \addlegendentry[#1]{\hspace{-7mm}#2}
509 }%
510 % \end{macrocode}
511 % \end{macro}
512 %
513 %</plot>
514 %
515 % \subsection{Feynman graphs}
516 %
517 %<*feynman>
518 %
519 % Load \software{tikz-feynman} package \cite{tikz-feynman} to enable the drawing of Feynman diagrams.
520 % Deactivate warning
521 % \begin{macrocode}
522 \RequirePackage{tikz-feynman}
523 \tikzfeynmanset{
524 compat=1.1.0,
525 warn luatex=false,
526 }
527 \makeatletter\def\tikzfeynman@luatex@required@path{}\makeatother
528 % \end{macrocode}
529 %
530 % Redfine the arrow style
531 % \begin{macrocode}
532 \tikzfeynmanset{
533 with arrow/.style={%
534 decoration={markings,mark=at position#1with\arrow{>}},
535 postaction=decorate
536 },
537 with reversed arrow/.style={%
538 decoration={markings,mark=at position#1with\arrow{<}},
539 postaction=decorate
540 },
541 momentum/arrow style={->},
542 }
543 % \end{macrocode}
544 %
545 %</feynman>
546 %
547 % \section{Tests}
548 %
549 %<*test>
550 %
551 % \begin{macrocode}
552 \documentclass{article}
553
554 \usepackage{hep-graphic}
555
556 \begin{document}
557
558 \end{document}
559 % \end{macrocode}
560 %
561 %</test>
562 %
563 % \section{Readme}
564 %
565 %<*readme>
566 %
567 % \begin{macrocode}
568 # The `hep-graphic` package
569
570 A `LaTeX` package for publications in High Energy Physics.
571
572 ## Introduction
573
574 ...
575
576 ## Author
577
578 Jan Hajer
579
580 ## License
581
582 This file may be distributed and/or modified under the conditions of the
583 `LaTeX` Project Public License, either version 1.3c of this license or
584 (at your option) any later version. The latest version of this license is
585 in `http://www.latex-project.org/lppl.txt` and version 1.3c or later is
586 part of all distributions of LaTeX version 2005/12/01 or later.
587 % \end{macrocode}
588 %
589 %</readme>
590 %
591 % \Finale
592
593 \endinput
594
595 % \PrintIndex
596 % makeindex -s gglo.ist -o hep-graphic-implementation.gls hep-graphic-implementation.glo
597 % makeindex -s gglo.ist -o hep-graphic-implementation.ind hep-graphic-implementation.idx