Debian Codegraph @

texmf-dist/doc/latex/hep-math/hep-math-documentation.tex

raw
1 %%
2 %% This is file `hep-math-documentation.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% hep-math-implementation.dtx (with options: `documentation')
8 %% This is a generated file.
9 %% Copyright (C) 2019-2025 by Jan Hajer
10 %% This file may be distributed and/or modified under the
11 %% conditions of the LaTeX Project Public License, either
12 %% version 1.3c of this license or (at your option) any later
13 %% version. The latest version of this license is in:
14 %% http://www.latex-project.org/lppl.txt
15 %% and version 1.3c or later is part of all distributions of
16 %% LaTeX version 2005/12/01 or later.
17
18 \ProvidesFile{hep-math-documentation.tex}[2025/09/01 v1.4 hep-math documentation]
19 \RequirePackage[l2tabu, orthodox]{nag}
20 \documentclass{ltxdoc}
21
22 \renewcommand*\theCodelineNo{\rmfamily\tstyle\footnotesize\arabic{CodelineNo}}
23 \AtBeginEnvironment{macrocode}{\renewcommand*{\ttdefault}{clmt}}
24 \renewcommand*{\MacroFont}{\codestyle}
25 \AtBeginDocument{\DeleteShortVerb{\|}}
26 \AtBeginDocument{\MakeShortVerb{\"}}
27 \EnableCrossrefs
28 \CodelineIndex
29 \RecordChanges
30
31 \usepackage{hologo}
32
33 \usepackage[parskip,oldstyle,font=10pt]{hep-paper}
34 \bibliography{bibliography}
35
36 \setlength{\fboxsep}{1pt}
37 \newenvironment{columns}[1][.5]{%
38 \par\vspace{-\bigskipamount}%
39 \begin{minipage}[t]{\linewidth}%
40 \begin{minipage}[t]{#1\linewidth}%
41 \def\column{%
42 \end{minipage}%
43 \begin{minipage}[t]{\linewidth-#1\linewidth}%
44 }%
45 }{\end{minipage}\end{minipage}\par}
46
47 \GetFileInfo{hep-math.sty}
48
49 \title{The \software{hep-math} package\thanks{This document corresponds to \software{hep-math}~\fileversion.}}
50 \subtitle{Extended math macros}
51 \author{Jan Hajer \email{[email protected]}}
52 \date{\filedate}
53
54 \begin{document}
55
56 \newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em}
57
58 \maketitle
59
60 \begin{abstract}
61 The \software{hep-math} package provides some additional features beyond the \software{mathtools} and \software{amsmath} packages.
62 \end{abstract}
63
64 To use the package place "\usepackage{hep-math}" in the preamble.
65
66 The \software{mathtools} \cite{mathtools} package is loaded, which in turn loads the \hologo{AmSLaTeX} \software{amsmath} \cite{amsmath} package.
67 Horizontal spacing in inline equations and page breaks in block equations are marginally adjusted.
68 \DescribeMacro{\left}
69 \DescribeMacro{\right}
70 Spacing around "\left" and "\right" is fixed with the \software{mleftright} package \cite{mleftright}.
71
72 \section{Macros}
73
74 \DescribeMacro{\mathdef}
75 The "\mathdef"\marg{name}\oarg{arguments}\marg{code} macro \prefix{re}{defines} macros only within math mode without changing the text mode definition.
76
77 \DescribeMacro{\i}
78 \DescribeMacro{\d}
79 The imaginary unit "\i" and the differential "\d" are defined using this functionality.
80
81 \DescribeMacro{\overline}
82 The "\overline" macro is adjusted to \overline{work also outside} of math mode using the \software{soul} \cite{soul} package.
83
84 \DescribeMacro{\oset}
85 \DescribeMacro{\overleft}
86 \DescribeMacro{\overright}
87 \DescribeMacro{\overleftright}
88 A better looking over left right arrow is defined \ie $\overleftright{\partial}$ using a new "\oset"\marg{over}\marg{math} functionality.
89
90 \DescribeMacro{\diag}
91 \DescribeMacro{\sgn}
92 Diagonal matrix "\diag", signum "\sgn", trace "\tr", "\Tr", and "\rank" operators are defined.
93
94 \DescribeMacro{\Re}
95 \DescribeMacro{\Im}
96 The real and imaginary projectors are redefined to look like ordinary operators.
97
98 \DescribeMacro{\sin}
99 \DescribeMacro{\cos}
100 \DescribeMacro{\tan}
101 "\cos" and "\tan" are adjusted to have the same height as "\sin".
102
103 \DescribeMacro{\accsc}
104 "\arccsc" and other inverse trigonometric functions are defined.
105
106 \subsection{Fractions and units}
107
108 \DescribeMacro{\unit}
109 \DescribeMacro{\inv}
110 The correct spacing for units is provided by the macro "\unit"\oarg{value}\marg{unit} from the \software{units} package \cite{units} which can also be used in text mode.
111 The macro "\inv"\oarg{power}\marg{text} allows to avoid math mode also for inverse units such as \unit[5]{\inv{fb}} typeset via "\unit[5]{\inv{fb}}".
112
113 \DescribeMacro{\nicefrac}
114 \DescribeMacro{\flatfrac}
115 \DescribeMacro{\textfrac}
116 The "\frac"\marg{number}\marg{number} macro is accompanied by "\nicefrac"\linebreak[1]\marg{number}\linebreak[1]\marg{number}, "\textfrac"\marg{number}\marg{number}, and "\flatfrac"\marg{number}\marg{number} leading to $\frac12$, $\nicefrac12$, \textfrac12, and $\flatfrac12$.
117 The "\textfrac" macro is mostly intended if a font with oldstyle numerals is used.
118
119 Some macros of the \software{physics} package \cite{physics} are reimplemented with a more conventional typesetting in mind.
120 Finer details about mathematical typesetting can be found in \cite{gregorio:2020}.
121
122 \subsection{Differentials and derivatives}
123
124 \DescribeMacro{\differential}
125 \DescribeMacro{\newderivative}
126 \DescribeMacro{\newpartialderivative}
127 The three macros "\differential"\marg{symbol}, "\newderivative" "{\name}"\marg{symbol}, and "\newpartialderivative" "{\name}"\marg{symbol} allow to define a differential with correct spacing, a derivative using this differential, and if necessary a partial derivative that can handle three dimensional derivatives.
128
129 \DescribeMacro{\d}
130 \DescribeMacro{\dv}
131 These macros are used for the usual differential and derivative, producing $\d x$ via "\d x" and
132 \begin{center}
133 \begin{tabular}{*4c}
134 "\dv[f]x" & "\dv*[f]x^n" & "\dv[f]x*^n" & "\dv*[f]x*^n" \\
135 $\dv[f]x$ & $\dv*[f]x^n$ & $\dv[f]x*^n$ & $\dv*[f]x*^n$ \\
136 "\dv xf" & "\dv*xf" & "\dv x*f" & "\dv*x*f" \\
137 $\dv xf$ & $\dv*xf$ & $\dv x*f$ & $\dv*x*f$
138 \end{tabular}
139 \end{center}
140 via "\dv*"\oarg{f}\marg{x}"*""^"\marg{n}.
141 Upright differential can be produced via "\renewcommand""{\diffsymbol}" "{\mathrm d}".
142 The differential takes care of the correct spacing as long as it is placed at the end of the integral $\int f(x)\d x$.
143 In order to archive correct spacing when it is placed at the beginning of the integral it is advisable to place the whole expression in a "\mathop{\int\d x} f(x)" such that $\mathop{\int\d x} f(x)$.
144
145 \DescribeMacro{\pd}
146 \DescribeMacro{\pdv}
147 Similarly a partial differential and derivative are defined that can be used according to "\pdv*"\oarg{f}\marg{x}"*""^"\marg{a}\oarg{y}"^"\marg{b}\oarg{z}"^"\marg{c}.
148 \begin{center}
149 \begin{tabular}{*4c}
150 "\pdv[f]x" & "\pdv[f]x[y]" & "\pdv[f]x^3" & "\pdv[f]x^2[y]" \\
151 $\pdv[f]x$ & $\pdv[f]x[y]$ & $\pdv[f]x^3$ & $\pdv[f]x^2[y]$ \\
152 "\pdv[f]x^2[y]^3" & "\pdv[f]x[y]^3" & "\pdv x[y]f"\\
153 $\pdv[f]x^2[y]^3$ & $\pdv[f]x[y]^3$ & $\pdv x[y]f$
154 \end{tabular}
155 \end{center}
156
157 \DescribeMacro{\var}
158 \DescribeMacro{\fdv}
159 Similarly a functional variation and functional derivative are defined.
160
161 \DescribeMacro{\cancel}
162 \DescribeMacro{\slashed}
163 The "\cancel"\marg{characters} macro from the \software{cancel} package \cite{cancel} and the "\slashed" \marg{character} macro from the \software{slashed} package \cite{slashed} allow to $\cancel{\text{cancel}}$ math and use the Dirac slash notation \ie $\slashed \pd$, respectively.
164
165 \subsection{Paired delimiters}
166
167 \DescribeMacro{\abs}
168 \DescribeMacro{\norm}
169 \begin{center}
170 \begin{tabular}{*8r}
171 "\abs x" & "\norm x" & "\norm[2]x" & "\norm*[2]x" \\
172 $\abs x$ & $\norm x$ & $\norm[2]x$ & $\norm*[2]x$
173 \end{tabular}
174 \end{center}
175
176 \DescribeMacro{\eval}
177 \DescribeMacro{\order}
178 \begin{center}
179 \begin{tabular}{*8r}
180 "\order x" & "\eval x_0^\infty" & "\eval* x_0^\infty" \\
181 $\order x$ & $\eval x_0^\infty$ & $\eval* x_0^\infty$
182 \end{tabular}
183 \end{center}
184
185 \DescribeMacro{\newpair}
186 \DescribeMacro{\comm}
187 \DescribeMacro{\acomm}
188 The "\newpair"\marg{name}\marg{left delim} \marg{right delim}"_"\marg{subscript}"^"\marg{superscript} macro is defined and used for the definition of \prefix{anti}{commutators} and Poisson brackets.
189 \begin{center}
190 \begin{tabular}{*8r}
191 "\pb xy" & "\comm xy" & "\acomm xy" \\
192 $\pb xy$ & $\comm xy$ & $\acomm xy$
193 \end{tabular}
194 \end{center}
195 They can easily be redefined using \eg "\newpair\comm\lbrack\rbrack_-".
196
197 \DescribeMacro{\bra}
198 \DescribeMacro{\ket}
199 \DescribeMacro{\braket}
200 \DescribeMacro{\ketbra}
201 \DescribeMacro{\mel}
202 \DescribeMacro{\ev}
203 \DescribeMacro{\vev}
204 Macros for the bra-ket notation are introduced.
205 \begin{center}
206 \begin{tabular}{*4c}
207 "\bra x" & "\ket x" & "\braket xy" & "\ketbra xy" \\
208 $\bra x$ & $\ket x$ & $\braket xy$ & $\ketbra xy$ \\
209 "\mel xyz" & "\ev x" & "\ev[\Omega] x" & "\vev x" \\
210 $\mel xyz$ & $\ev x$ & $\ev[\Omega] x$ & $\vev x$
211 \end{tabular}
212 \end{center}
213
214 \DescribeMacro{\column}
215 \DescribeMacro{\row}
216 Macros for row and column vectors are introduced together with a symbol for transpose vectors.
217 \begin{center}
218 \begin{tabular}{*4c}
219 "\column{x,y,z}" & "\row{x,y,z}^\trans" \\
220 $\column{x,y,z}$ & $\row{x,y,z}^\trans$ \\
221 \end{tabular}
222 \end{center}
223
224 \section{Environments}
225
226 \DescribeMacro{eqnarray}
227 The "eqnarray" environment is depreciated, the "split", "multline", "align", "multlined", "aligned", "alignedat", and "cases" environments of the \software{amsmath} and \software{mathtools} packages should be used instead.
228
229 \DescribeMacro{equation}
230 Use the "equation" environment for short equations.
231 \begin{columns}
232 \begin{verbatim}
233 \begin{equation}
234 left = right \ .
235 \end{equation}
236 \end{verbatim}
237 \column
238 \begin{equation}
239 \framebox[2em]{left\strut} = \framebox[7em]{right\strut} \ .
240 \end{equation}
241 \end{columns}
242
243 \DescribeMacro{multline}
244 Use the "multline" environment for longer equations.
245 \begin{columns}
246 \begin{verbatim}
247 \begin{multline}
248 left = right 1 \\
249 + right 2 \ .
250 \end{multline}
251 \end{verbatim}
252 \column
253 \begin{multline}
254 \framebox[2em]{left\strut} = \framebox[7em]{right 1\strut} \\
255 \framebox[7em]{+ right 2\strut} \ .
256 \end{multline}
257 \end{columns}
258
259 \DescribeMacro{split}
260 Use the "split" sub environment for equations in which multiple equal signs should be aligned.
261 \begin{columns}
262 \begin{verbatim}
263 \begin{equation} \begin{split}
264 left &= right 1 \\
265 &= right 2 \ .
266 \end{split} \end{equation}
267 \end{verbatim}
268 \column
269 \begin{equation}
270 \begin{split}
271 \framebox[2em]{left\strut} &= \framebox[7em]{right 1\strut} \\
272 &= \framebox[7em]{right 2\strut} \ .
273 \end{split}
274 \end{equation}
275 \end{columns}
276
277 \DescribeMacro{align}
278 Use the "align" environment for the vertical alignment and horizontal distribution of multiple equations.
279 \begin{columns}
280 \begin{verbatim}
281 \begin{subequations} \begin{align}
282 left &= right \ , &
283 left &= right \ , \\
284 left &= right \ , &
285 left &= right \ .
286 \end{align} \end{subequations}
287 \end{verbatim}
288 \column
289 \begin{subequations}
290 \begin{align}
291 \framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ , &
292 \framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ , \\
293 \framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ , &
294 \framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ .
295 \end{align}
296 \end{subequations}
297 \end{columns}
298
299 \DescribeMacro{aligned}
300 Use the "aligned" environment within a "equation" environment if the aligned equations should be labeled with a single equation number.
301
302 \DescribeMacro{multlined}
303 Use the "multlined" environment if either "split" or "align" contain very long lines.
304 \begin{columns}
305 \begin{verbatim}
306 \begin{equation} \begin{split}
307 left &= right 1 \\ &=
308 \begin{multlined}[t]
309 right 2 \\ + right 3 \ .
310 \end{multlined}
311 \end{split} \end{equation}
312 \end{verbatim}
313 \column
314 \begin{equation}
315 \begin{split}
316 \framebox[2em]{left\strut} &= \framebox[7em]{right 1\strut} \\ &=
317 \begin{multlined}[t]
318 \framebox[7em]{right 2\strut} \\
319 \framebox[7em]{+ right 3\strut} \ .
320 \end{multlined}
321 \end{split}
322 \end{equation}
323 \end{columns}
324
325 \DescribeMacro{alignat}
326 Use the "alignat" environment together with the "\mathllap" macro for the alignment of multiple equations with vastly different lengths.
327 \begin{columns}
328 \begin{verbatim}
329 \begin{subequations}
330 \begin{alignat}{2}
331 left &= long right && \ , \\
332 le. 2 &= ri. 2 \ , &
333 \mathllap{le. 3 = ri. 3} & \ .
334 \end{alignat}
335 \end{subequations}
336 \end{verbatim}
337 \column
338 \begin{subequations}
339 \begin{alignat}{2}
340 \framebox[2em]{left\strut} &=
341 \framebox[11em]{long right\strut} && \ , \\
342 \framebox[2em]{le.\ 2\strut}
343 &= \framebox[2.5em]{ri.\ 2\strut} \ , &
344 \mathllap{\framebox[2em]{le.\ 3\strut}
345 = \framebox[2.5em]{ri.\ 3\strut}} & \ .
346 \end{alignat}
347 \end{subequations}
348 \end{columns}
349
350 As a rule of thumb if you have to use "\notag", "\nonumber", or perform manual spacing via "\quad" you are probably using the wrong environment.
351
352 \printbibliography
353
354 \end{document}
355
356 \endinput
357 %%
358 %% End of file `hep-math-documentation.tex'.