summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hepunits/hepunits.sty
blob: 6cb68abfa725bed75daa13e9371818a6de3c62ed (plain)
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
%% hepunits
%%   High energy physics (HEP) extensions to the SIunits package
%% Author: Andy Buckley <andy@insectnation.org>
%%
%% This material is subject to the LaTeX Project Public License.
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
%% or the details of that license.
%%
%% Please let me know if you use hepunits and what you think of it.
%% I'll try to implement any suggested options that seem sensible!

\def\fileversion{2.0.0}
\def\filedate{2020/04/10}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hepunits}[\filedate\space High-energy physics units by Andy Buckley (v\fileversion)]


%% Option handling
\def\@yes{yes}
\def\@HEPopt@noprefixcmds{}
\def\@HEPopt@sicmds{}
\def\@HEPopt@freestanding{}
\DeclareOption{sicmds}{\def\@HEPopt@sicmds{yes}}
\DeclareOption{noprefixcmds}{\def\@HEPopt@noprefixcmds{yes}}
\DeclareOption{freestanding}{\def\@HEPopt@freestanding{yes}}
\ProcessOptions
\ifx\@HEPopt@noprefixcmds\@yes\def\@HEPopt@sicmds\@empty\fi


%% Get the dependency packages
\RequirePackage{amsmath}
\RequirePackage{ifthen}
\RequirePackage{siunitx}

%% Pass default config to siunitx
\sisetup{detect-all, detect-display-math, mode=text}
\ifx\@HEPopt@freestanding\@yes
\sisetup{free-standing-units=true}
\fi


%% -------------------------------------------------
%% Units defined below here
%% -------------------------------------------------

\DeclareSIUnit{\Hz}{\hertz}

\ifx\@HEPopt@sicmds\@yes
%% Lengths
\DeclareSIUnit{\fermi}{\femto\metre}
\DeclareSIUnit{\nm}{\nano\metre}
\DeclareSIUnit{\micron}{\micro\metre}
\DeclareSIUnit{\um}{\micro\metre}
\DeclareSIUnit{\mm}{\milli\metre}
\DeclareSIUnit{\cm}{\centi\metre}

%% Angles
\DeclareSIUnit{\mrad}{\milli\radian}

%% Times
\DeclareSIUnit{\as}{\atto\second}
\DeclareSIUnit{\fs}{\femto\second}
\DeclareSIUnit{\ps}{\pico\second}
\DeclareSIUnit{\ns}{\nano\second}

%% Rates
\DeclareSIUnit{\mHz}{\milli\hertz}
\DeclareSIUnit{\kHz}{\kilo\hertz}
\DeclareSIUnit{\MHz}{\mega\hertz}
\DeclareSIUnit{\GHz}{\giga\hertz}
\DeclareSIUnit{\THz}{\tera\hertz}
\fi


%% Fields
\DeclareSIUnit{\gauss}{G}

%% Luminosity
\DeclareSIUnit{\invcmsq}{\centi\metre\tothe{-2}}
\DeclareSIUnit{\invcmsqpersecond}{\invcmsq\second\tothe{-1}}
\DeclareSIUnit{\invcmsqpersec}{\invcmsqpersecond}

%% (Inverse) cross-sections
\DeclareSIUnit{\invbarn}{\barn\tothe{-1}}
\ifx\@HEPopt@noprefixcmds\@empty
\DeclareSIUnit{\millibarn}{\milli\barn}
\DeclareSIUnit{\microbarn}{\micro\barn}
\DeclareSIUnit{\nanobarn}{\nano\barn}
\DeclareSIUnit{\picobarn}{\pico\barn}
\DeclareSIUnit{\femtobarn}{\femto\barn}
\DeclareSIUnit{\attobarn}{\atto\barn}
\DeclareSIUnit{\zeptobarn}{\zepto\barn}
\DeclareSIUnit{\yoctobarn}{\yocto\barn}
\DeclareSIUnit{\invnanobarn}{\nano\invbarn}
\DeclareSIUnit{\invpicobarn}{\pico\invbarn}
\DeclareSIUnit{\invfemtobarn}{\femto\invbarn}
\DeclareSIUnit{\invattobarn}{\atto\invbarn}
\DeclareSIUnit{\invzeptobarn}{\zepto\invbarn}
\DeclareSIUnit{\invyoctobarn}{\yocto\invbarn}
\DeclareSIUnit{\invnb}{\invnanobarn}
\DeclareSIUnit{\invpb}{\invpicobarn}
\DeclareSIUnit{\invfb}{\invfemtobarn}
\DeclareSIUnit{\invab}{\invattobarn}
\DeclareSIUnit{\invzb}{\invzeptobarn}
\DeclareSIUnit{\invyb}{\invyoctobarn}
\fi

%% HEP energy, momentum and mass units
% \DeclareSIUnit{\electronvolt}{\text{e\kern-1.2\scriptspace V}}
\DeclareSIUnit{\electronvolt}{\text{e\kern-0.15ex V}}
\DeclareSIUnit{\eV}{\electronvolt}
\newcommand{\@eVoverc}[1][]{\ensuremath{
    \eV
    \ifthenelse{\equal{\f@series}{\bfdefault}}{/}{\mkern-\medmuskip/\mkern-\thinmuskip}
    \text{\ensuremath{c#1}}
  }}
\DeclareSIUnit{\electronvoltc}{\@eVoverc}
\DeclareSIUnit{\electronvoltcsq}{\@eVoverc[^2]}
\DeclareSIUnit{\eVc}{\@eVoverc}
\DeclareSIUnit{\eVcsq}{\@eVoverc[^2]}
\ifx\@HEPopt@noprefixcmds\@empty
\DeclareSIUnit{\meV}{\milli\eV}
\DeclareSIUnit{\keV}{\kilo\eV}
\DeclareSIUnit{\MeV}{\mega\eV}
\DeclareSIUnit{\GeV}{\giga\eV}
\DeclareSIUnit{\TeV}{\tera\eV}
\DeclareSIUnit{\meVc}{\milli\eVc}
\DeclareSIUnit{\keVc}{\kilo\eVc}
\DeclareSIUnit{\MeVc}{\mega\eVc}
\DeclareSIUnit{\GeVc}{\giga\eVc}
\DeclareSIUnit{\TeVc}{\tera\eVc}
\DeclareSIUnit{\meVcsq}{\milli\eVcsq}
\DeclareSIUnit{\keVcsq}{\kilo\eVcsq}
\DeclareSIUnit{\MeVcsq}{\mega\eVcsq}
\DeclareSIUnit{\GeVcsq}{\giga\eVcsq}
\DeclareSIUnit{\TeVcsq}{\tera\eVcsq}
\fi