| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2019-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-math}[2025/09/01 v1.4 Math and physics macros] |
| 22 |
%<documentation>\ProvidesFile{hep-math-documentation.tex}[2025/09/01 v1.4 hep-math documentation] |
| 23 |
% |
| 24 |
%<*documentation> |
| 25 |
\RequirePackage[l2tabu, orthodox]{nag} |
| 26 |
\documentclass{ltxdoc} |
| 27 |
|
| 28 |
\renewcommand*\theCodelineNo{\rmfamily\tstyle\footnotesize\arabic{CodelineNo}} |
| 29 |
\AtBeginEnvironment{macrocode}{\renewcommand*{\ttdefault}{clmt}} |
| 30 |
\renewcommand*{\MacroFont}{\codestyle} |
| 31 |
\AtBeginDocument{\DeleteShortVerb{\|}} |
| 32 |
\AtBeginDocument{\MakeShortVerb{\"}} |
| 33 |
\EnableCrossrefs |
| 34 |
\CodelineIndex |
| 35 |
\RecordChanges |
| 36 |
|
| 37 |
\usepackage{hologo} |
| 38 |
|
| 39 |
\usepackage[parskip,oldstyle,font=10pt]{hep-paper} |
| 40 |
\bibliography{bibliography} |
| 41 |
|
| 42 |
\setlength{\fboxsep}{1pt} |
| 43 |
\newenvironment{columns}[1][.5]{% |
| 44 |
\par\vspace{-\bigskipamount}% |
| 45 |
\begin{minipage}[t]{\linewidth}% |
| 46 |
\begin{minipage}[t]{#1\linewidth}% |
| 47 |
\def\column{% |
| 48 |
\end{minipage}% |
| 49 |
\begin{minipage}[t]{\linewidth-#1\linewidth}% |
| 50 |
}% |
| 51 |
}{\end{minipage}\end{minipage}\par} |
| 52 |
%</documentation> |
| 53 |
|
| 54 |
%<*driver> |
| 55 |
\expandafter\newif\csname ifshort\endcsname |
| 56 |
\shortfalse |
| 57 |
\begin{document} |
| 58 |
\DocInput{hep-math-implementation.dtx} |
| 59 |
\end{document} |
| 60 |
%</driver> |
| 61 |
% |
| 62 |
% \fi |
| 63 |
% |
| 64 |
% \CheckSum{725} |
| 65 |
% |
| 66 |
% \CharacterTable |
| 67 |
% {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 |
| 68 |
% 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 |
| 69 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 70 |
% Exclamation \! Double quote \" Hash (number) \# |
| 71 |
% Dollar \$ Percent \% Ampersand \& |
| 72 |
% Acute accent \' Left paren \( Right paren \) |
| 73 |
% Asterisk \* Plus \+ Comma \, |
| 74 |
% Minus \- Point \. Solidus \/ |
| 75 |
% Colon \: Semicolon \; Less than \< |
| 76 |
% Equals \= Greater than \> Question mark \? |
| 77 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 78 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 79 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 80 |
% Right brace \} Tilde \~} |
| 81 |
% |
| 82 |
% \changes{v1.0}{2021/09/01}{Initial version of the style file.} |
| 83 |
% \changes{v1.1}{2022/11/01}{Bug fixes.} |
| 84 |
% \changes{v1.2}{2023/07/01}{Bug fixes.} |
| 85 |
% \changes{v1.3}{2024/11/01}{Bug fixes.} |
| 86 |
% \changes{v1.4}{2025/09/01}{Bug fixes.} |
| 87 |
% |
| 88 |
% \ifshort |
| 89 |
%<*documentation> |
| 90 |
% \fi |
| 91 |
% |
| 92 |
\GetFileInfo{hep-math.sty} |
| 93 |
|
| 94 |
\title{The \software{hep-math} package\thanks{This document corresponds to \software{hep-math}~\fileversion.}} |
| 95 |
\subtitle{Extended math macros} |
| 96 |
\author{Jan Hajer \email{[email protected]}} |
| 97 |
\date{\filedate} |
| 98 |
|
| 99 |
% \ifshort |
| 100 |
\begin{document} |
| 101 |
% \fi |
| 102 |
|
| 103 |
\newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em} |
| 104 |
|
| 105 |
\maketitle |
| 106 |
|
| 107 |
\begin{abstract} |
| 108 |
The \software{hep-math} package provides some additional features beyond the \software{mathtools} and \software{amsmath} packages. |
| 109 |
\end{abstract} |
| 110 |
|
| 111 |
To use the package place "\usepackage{hep-math}" in the preamble. |
| 112 |
|
| 113 |
The \software{mathtools} \cite{mathtools} package is loaded, which in turn loads the \hologo{AmSLaTeX} \software{amsmath} \cite{amsmath} package. |
| 114 |
Horizontal spacing in inline equations and page breaks in block equations are marginally adjusted. |
| 115 |
\DescribeMacro{\left} |
| 116 |
\DescribeMacro{\right} |
| 117 |
Spacing around "\left" and "\right" is fixed with the \software{mleftright} package \cite{mleftright}. |
| 118 |
|
| 119 |
\section{Macros} |
| 120 |
|
| 121 |
\DescribeMacro{\mathdef} |
| 122 |
The "\mathdef"\marg{name}\oarg{arguments}\marg{code} macro \prefix{re}{defines} macros only within math mode without changing the text mode definition. |
| 123 |
|
| 124 |
\DescribeMacro{\i} |
| 125 |
\DescribeMacro{\d} |
| 126 |
The imaginary unit "\i" and the differential "\d" are defined using this functionality. |
| 127 |
|
| 128 |
\DescribeMacro{\overline} |
| 129 |
The "\overline" macro is adjusted to \overline{work also outside} of math mode using the \software{soul} \cite{soul} package. |
| 130 |
|
| 131 |
\DescribeMacro{\oset} |
| 132 |
\DescribeMacro{\overleft} |
| 133 |
\DescribeMacro{\overright} |
| 134 |
\DescribeMacro{\overleftright} |
| 135 |
A better looking over left right arrow is defined \ie $\overleftright{\partial}$ using a new "\oset"\marg{over}\marg{math} functionality. |
| 136 |
|
| 137 |
\DescribeMacro{\diag} |
| 138 |
\DescribeMacro{\sgn} |
| 139 |
Diagonal matrix "\diag", signum "\sgn", trace "\tr", "\Tr", and "\rank" operators are defined. |
| 140 |
|
| 141 |
\DescribeMacro{\Re} |
| 142 |
\DescribeMacro{\Im} |
| 143 |
The real and imaginary projectors are redefined to look like ordinary operators. |
| 144 |
|
| 145 |
\DescribeMacro{\sin} |
| 146 |
\DescribeMacro{\cos} |
| 147 |
\DescribeMacro{\tan} |
| 148 |
"\cos" and "\tan" are adjusted to have the same height as "\sin". |
| 149 |
|
| 150 |
\DescribeMacro{\accsc} |
| 151 |
"\arccsc" and other inverse trigonometric functions are defined. |
| 152 |
|
| 153 |
\subsection{Fractions and units} |
| 154 |
|
| 155 |
\DescribeMacro{\unit} |
| 156 |
\DescribeMacro{\inv} |
| 157 |
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. |
| 158 |
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}}". |
| 159 |
|
| 160 |
\DescribeMacro{\nicefrac} |
| 161 |
\DescribeMacro{\flatfrac} |
| 162 |
\DescribeMacro{\textfrac} |
| 163 |
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$. |
| 164 |
The "\textfrac" macro is mostly intended if a font with oldstyle numerals is used. |
| 165 |
|
| 166 |
Some macros of the \software{physics} package \cite{physics} are reimplemented with a more conventional typesetting in mind. |
| 167 |
Finer details about mathematical typesetting can be found in \cite{gregorio:2020}. |
| 168 |
|
| 169 |
\subsection{Differentials and derivatives} |
| 170 |
|
| 171 |
\DescribeMacro{\differential} |
| 172 |
\DescribeMacro{\newderivative} |
| 173 |
\DescribeMacro{\newpartialderivative} |
| 174 |
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. |
| 175 |
|
| 176 |
\DescribeMacro{\d} |
| 177 |
\DescribeMacro{\dv} |
| 178 |
These macros are used for the usual differential and derivative, producing $\d x$ via "\d x" and |
| 179 |
\begin{center} |
| 180 |
\begin{tabular}{*4c} |
| 181 |
"\dv[f]x" & "\dv*[f]x^n" & "\dv[f]x*^n" & "\dv*[f]x*^n" \\ |
| 182 |
$\dv[f]x$ & $\dv*[f]x^n$ & $\dv[f]x*^n$ & $\dv*[f]x*^n$ \\ |
| 183 |
"\dv xf" & "\dv*xf" & "\dv x*f" & "\dv*x*f" \\ |
| 184 |
$\dv xf$ & $\dv*xf$ & $\dv x*f$ & $\dv*x*f$ |
| 185 |
\end{tabular} |
| 186 |
\end{center} |
| 187 |
via "\dv*"\oarg{f}\marg{x}"*""^"\marg{n}. |
| 188 |
Upright differential can be produced via "\renewcommand""{\diffsymbol}" "{\mathrm d}". |
| 189 |
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$. |
| 190 |
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)$. |
| 191 |
|
| 192 |
\DescribeMacro{\pd} |
| 193 |
\DescribeMacro{\pdv} |
| 194 |
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}. |
| 195 |
\begin{center} |
| 196 |
\begin{tabular}{*4c} |
| 197 |
"\pdv[f]x" & "\pdv[f]x[y]" & "\pdv[f]x^3" & "\pdv[f]x^2[y]" \\ |
| 198 |
$\pdv[f]x$ & $\pdv[f]x[y]$ & $\pdv[f]x^3$ & $\pdv[f]x^2[y]$ \\ |
| 199 |
"\pdv[f]x^2[y]^3" & "\pdv[f]x[y]^3" & "\pdv x[y]f"\\ |
| 200 |
$\pdv[f]x^2[y]^3$ & $\pdv[f]x[y]^3$ & $\pdv x[y]f$ |
| 201 |
\end{tabular} |
| 202 |
\end{center} |
| 203 |
|
| 204 |
\DescribeMacro{\var} |
| 205 |
\DescribeMacro{\fdv} |
| 206 |
Similarly a functional variation and functional derivative are defined. |
| 207 |
|
| 208 |
\DescribeMacro{\cancel} |
| 209 |
\DescribeMacro{\slashed} |
| 210 |
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. |
| 211 |
|
| 212 |
\subsection{Paired delimiters} |
| 213 |
|
| 214 |
\DescribeMacro{\abs} |
| 215 |
\DescribeMacro{\norm} |
| 216 |
\begin{center} |
| 217 |
\begin{tabular}{*8r} |
| 218 |
"\abs x" & "\norm x" & "\norm[2]x" & "\norm*[2]x" \\ |
| 219 |
$\abs x$ & $\norm x$ & $\norm[2]x$ & $\norm*[2]x$ |
| 220 |
\end{tabular} |
| 221 |
\end{center} |
| 222 |
|
| 223 |
\DescribeMacro{\eval} |
| 224 |
\DescribeMacro{\order} |
| 225 |
\begin{center} |
| 226 |
\begin{tabular}{*8r} |
| 227 |
"\order x" & "\eval x_0^\infty" & "\eval* x_0^\infty" \\ |
| 228 |
$\order x$ & $\eval x_0^\infty$ & $\eval* x_0^\infty$ |
| 229 |
\end{tabular} |
| 230 |
\end{center} |
| 231 |
|
| 232 |
\DescribeMacro{\newpair} |
| 233 |
\DescribeMacro{\comm} |
| 234 |
\DescribeMacro{\acomm} |
| 235 |
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. |
| 236 |
\begin{center} |
| 237 |
\begin{tabular}{*8r} |
| 238 |
"\pb xy" & "\comm xy" & "\acomm xy" \\ |
| 239 |
$\pb xy$ & $\comm xy$ & $\acomm xy$ |
| 240 |
\end{tabular} |
| 241 |
\end{center} |
| 242 |
They can easily be redefined using \eg "\newpair\comm\lbrack\rbrack_-". |
| 243 |
|
| 244 |
\DescribeMacro{\bra} |
| 245 |
\DescribeMacro{\ket} |
| 246 |
\DescribeMacro{\braket} |
| 247 |
\DescribeMacro{\ketbra} |
| 248 |
\DescribeMacro{\mel} |
| 249 |
\DescribeMacro{\ev} |
| 250 |
\DescribeMacro{\vev} |
| 251 |
Macros for the bra-ket notation are introduced. |
| 252 |
\begin{center} |
| 253 |
\begin{tabular}{*4c} |
| 254 |
"\bra x" & "\ket x" & "\braket xy" & "\ketbra xy" \\ |
| 255 |
$\bra x$ & $\ket x$ & $\braket xy$ & $\ketbra xy$ \\ |
| 256 |
"\mel xyz" & "\ev x" & "\ev[\Omega] x" & "\vev x" \\ |
| 257 |
$\mel xyz$ & $\ev x$ & $\ev[\Omega] x$ & $\vev x$ |
| 258 |
\end{tabular} |
| 259 |
\end{center} |
| 260 |
|
| 261 |
\DescribeMacro{\column} |
| 262 |
\DescribeMacro{\row} |
| 263 |
Macros for row and column vectors are introduced together with a symbol for transpose vectors. |
| 264 |
\begin{center} |
| 265 |
\begin{tabular}{*4c} |
| 266 |
"\column{x,y,z}" & "\row{x,y,z}^\trans" \\ |
| 267 |
$\column{x,y,z}$ & $\row{x,y,z}^\trans$ \\ |
| 268 |
\end{tabular} |
| 269 |
\end{center} |
| 270 |
|
| 271 |
\section{Environments} |
| 272 |
|
| 273 |
\DescribeMacro{eqnarray} |
| 274 |
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. |
| 275 |
|
| 276 |
\DescribeMacro{equation} |
| 277 |
Use the "equation" environment for short equations. |
| 278 |
\begin{columns} |
| 279 |
\begin{verbatim} |
| 280 |
\begin{equation} |
| 281 |
left = right \ . |
| 282 |
\end{equation} |
| 283 |
\end{verbatim} |
| 284 |
\column |
| 285 |
\begin{equation} |
| 286 |
\framebox[2em]{left\strut} = \framebox[7em]{right\strut} \ . |
| 287 |
\end{equation} |
| 288 |
\end{columns} |
| 289 |
|
| 290 |
\DescribeMacro{multline} |
| 291 |
Use the "multline" environment for longer equations. |
| 292 |
\begin{columns} |
| 293 |
\begin{verbatim} |
| 294 |
\begin{multline} |
| 295 |
left = right 1 \\ |
| 296 |
+ right 2 \ . |
| 297 |
\end{multline} |
| 298 |
\end{verbatim} |
| 299 |
\column |
| 300 |
\begin{multline} |
| 301 |
\framebox[2em]{left\strut} = \framebox[7em]{right 1\strut} \\ |
| 302 |
\framebox[7em]{+ right 2\strut} \ . |
| 303 |
\end{multline} |
| 304 |
\end{columns} |
| 305 |
|
| 306 |
\DescribeMacro{split} |
| 307 |
Use the "split" sub environment for equations in which multiple equal signs should be aligned. |
| 308 |
\begin{columns} |
| 309 |
\begin{verbatim} |
| 310 |
\begin{equation} \begin{split} |
| 311 |
left &= right 1 \\ |
| 312 |
&= right 2 \ . |
| 313 |
\end{split} \end{equation} |
| 314 |
\end{verbatim} |
| 315 |
\column |
| 316 |
\begin{equation} |
| 317 |
\begin{split} |
| 318 |
\framebox[2em]{left\strut} &= \framebox[7em]{right 1\strut} \\ |
| 319 |
&= \framebox[7em]{right 2\strut} \ . |
| 320 |
\end{split} |
| 321 |
\end{equation} |
| 322 |
\end{columns} |
| 323 |
|
| 324 |
\DescribeMacro{align} |
| 325 |
Use the "align" environment for the vertical alignment and horizontal distribution of multiple equations. |
| 326 |
\begin{columns} |
| 327 |
\begin{verbatim} |
| 328 |
\begin{subequations} \begin{align} |
| 329 |
left &= right \ , & |
| 330 |
left &= right \ , \\ |
| 331 |
left &= right \ , & |
| 332 |
left &= right \ . |
| 333 |
\end{align} \end{subequations} |
| 334 |
\end{verbatim} |
| 335 |
\column |
| 336 |
\begin{subequations} |
| 337 |
\begin{align} |
| 338 |
\framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ , & |
| 339 |
\framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ , \\ |
| 340 |
\framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ , & |
| 341 |
\framebox[2em]{left\strut} &= \framebox[3em]{right\strut} \ . |
| 342 |
\end{align} |
| 343 |
\end{subequations} |
| 344 |
\end{columns} |
| 345 |
|
| 346 |
\DescribeMacro{aligned} |
| 347 |
Use the "aligned" environment within a "equation" environment if the aligned equations should be labeled with a single equation number. |
| 348 |
|
| 349 |
\DescribeMacro{multlined} |
| 350 |
Use the "multlined" environment if either "split" or "align" contain very long lines. |
| 351 |
\begin{columns} |
| 352 |
\begin{verbatim} |
| 353 |
\begin{equation} \begin{split} |
| 354 |
left &= right 1 \\ &= |
| 355 |
\begin{multlined}[t] |
| 356 |
right 2 \\ + right 3 \ . |
| 357 |
\end{multlined} |
| 358 |
\end{split} \end{equation} |
| 359 |
\end{verbatim} |
| 360 |
\column |
| 361 |
\begin{equation} |
| 362 |
\begin{split} |
| 363 |
\framebox[2em]{left\strut} &= \framebox[7em]{right 1\strut} \\ &= |
| 364 |
\begin{multlined}[t] |
| 365 |
\framebox[7em]{right 2\strut} \\ |
| 366 |
\framebox[7em]{+ right 3\strut} \ . |
| 367 |
\end{multlined} |
| 368 |
\end{split} |
| 369 |
\end{equation} |
| 370 |
\end{columns} |
| 371 |
|
| 372 |
\DescribeMacro{alignat} |
| 373 |
Use the "alignat" environment together with the "\mathllap" macro for the alignment of multiple equations with vastly different lengths. |
| 374 |
\begin{columns} |
| 375 |
\begin{verbatim} |
| 376 |
\begin{subequations} |
| 377 |
\begin{alignat}{2} |
| 378 |
left &= long right && \ , \\ |
| 379 |
le. 2 &= ri. 2 \ , & |
| 380 |
\mathllap{le. 3 = ri. 3} & \ . |
| 381 |
\end{alignat} |
| 382 |
\end{subequations} |
| 383 |
\end{verbatim} |
| 384 |
\column |
| 385 |
\begin{subequations} |
| 386 |
\begin{alignat}{2} |
| 387 |
\framebox[2em]{left\strut} &= |
| 388 |
\framebox[11em]{long right\strut} && \ , \\ |
| 389 |
\framebox[2em]{le.\ 2\strut} |
| 390 |
&= \framebox[2.5em]{ri.\ 2\strut} \ , & |
| 391 |
\mathllap{\framebox[2em]{le.\ 3\strut} |
| 392 |
= \framebox[2.5em]{ri.\ 3\strut}} & \ . |
| 393 |
\end{alignat} |
| 394 |
\end{subequations} |
| 395 |
\end{columns} |
| 396 |
|
| 397 |
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. |
| 398 |
|
| 399 |
% \ifshort |
| 400 |
\printbibliography |
| 401 |
|
| 402 |
\end{document} |
| 403 |
% |
| 404 |
%</documentation> |
| 405 |
% \fi |
| 406 |
% |
| 407 |
% \StopEventually{ |
| 408 |
% \printbibliography |
| 409 |
% \PrintChanges |
| 410 |
% } |
| 411 |
% |
| 412 |
% \appendix |
| 413 |
% |
| 414 |
% \section{Implementation} |
| 415 |
% |
| 416 |
%<*package> |
| 417 |
% |
| 418 |
% Load the \software{mathtools} package \cite{mathtools} which loads the \software{amsmath} package \cite{amsmath}. |
| 419 |
% Allow page breaks within equations if necessary. |
| 420 |
% Adjust the thick and med mu skips slightly. |
| 421 |
% \begin{macrocode} |
| 422 |
\RequirePackage{mathtools} |
| 423 |
\mathtoolsset{centercolon} |
| 424 |
\allowdisplaybreaks[1] |
| 425 |
\thickmuskip=5mu plus 3mu minus 1mu |
| 426 |
\medmuskip=4mu plus 2mu minus 3mu |
| 427 |
% \end{macrocode} |
| 428 |
% |
| 429 |
% \begin{macro}{\mathdef} |
| 430 |
% Define the "\mathdef"\marg{name}\oarg{arguments}\marg{macro} macro which \prefix{re}{defines} macros in math mode only. |
| 431 |
% This macro is implemented using the \software{xparse} package \cite{xparse}. |
| 432 |
% \begin{macrocode} |
| 433 |
\RequirePackage{xparse} |
| 434 |
\DeclareDocumentCommand{\mathdef}{mO{0}om}{% |
| 435 |
\expandafter\let\csname hep@text\string#1\endcsname=#1 |
| 436 |
\expandafter\newcommand\expandafter*\csname hep@math\string#1% |
| 437 |
\IfNoValueTF{#3}{\endcsname[#2]}{\endcsname[#2][#3]}{#4} |
| 438 |
\DeclareRobustCommand#1{% |
| 439 |
\ifmmode |
| 440 |
\expandafter\let\expandafter\next\csname% |
| 441 |
hep@math\string#1\endcsname% |
| 442 |
\else |
| 443 |
\expandafter\let\expandafter\next\csname% |
| 444 |
hep@text\string#1\endcsname% |
| 445 |
\fi |
| 446 |
\next |
| 447 |
}% |
| 448 |
} |
| 449 |
% \end{macrocode} |
| 450 |
% \end{macro} |
| 451 |
% |
| 452 |
% \begin{macro}{\i} |
| 453 |
% Provide an upright imaginary unit in math mode. |
| 454 |
% \begin{macrocode} |
| 455 |
\newcommand*{\imaginaryunit}{\text{i}} |
| 456 |
\AtBeginDocument{\mathdef{\i}{\imaginaryunit}} |
| 457 |
% \end{macrocode} |
| 458 |
% \end{macro} |
| 459 |
% |
| 460 |
% \begin{macro}{\overline} |
| 461 |
% Redefine "\overline" to be a text macro using the \software{soul} package \cite{soul}. |
| 462 |
% Extend it as a math macro with the original definition from the \software{amsmath} package \cite{amsmath}. |
| 463 |
% \begin{macrocode} |
| 464 |
\RequirePackage{soul} |
| 465 |
% \def\overline#1{{\renewcommand*{\ULdepth}{-1.9ex}{}\uline{#1}}} |
| 466 |
\newcommand*\textoverline[1]{{\setul{-1.9ex}{}\ul{#1}}} |
| 467 |
\let\overline\textoverline |
| 468 |
\DeclareRobustCommand{\over@line}[1]{\@@overline{#1}} |
| 469 |
\mathdef{\overline}{\over@line} |
| 470 |
\newcommand*\hep@widebar[1]{% |
| 471 |
\mkern2.5mu\overline{\mkern-2.5mu#1\mkern-.5mu}\mkern.5mu% |
| 472 |
} |
| 473 |
\newcommand*\widebar[1]{% |
| 474 |
\settowidth{\dimen0}{\ensuremath{#1}}% |
| 475 |
\ifdim\dimen0>.475em\hep@widebar{#1}\else\bar{#1}\fi% |
| 476 |
} |
| 477 |
% \end{macrocode} |
| 478 |
% \end{macro} |
| 479 |
% |
| 480 |
% \begin{macro}{\oset} |
| 481 |
% Define a new overset macro "\oset"\oarg{offset}\marg{over}\marg{base} |
| 482 |
% \begin{macrocode} |
| 483 |
\newcommand*{\oset}[3][-1pt]{% |
| 484 |
\text{\raisebox{.2ex}{$\mathop{#3}\limits^{% |
| 485 |
\vbox to#1{\kern-2\ex@\hbox{$\scriptscriptstyle#2$}\vss}% |
| 486 |
}$}}% |
| 487 |
} |
| 488 |
% \end{macrocode} |
| 489 |
% \end{macro} |
| 490 |
% \begin{macro}{\overleftright} |
| 491 |
% Define a over left right arrow "\overleftright"\marg{base}. |
| 492 |
% \begin{macrocode} |
| 493 |
\newcommand*{\overleft}[1]{\oset{\leftarrow}{#1}} |
| 494 |
\newcommand*{\overright}[1]{\oset{\rightarrow}{#1}} |
| 495 |
\newcommand*{\overleftright}[1]{\oset{\leftrightarrow}{#1}} |
| 496 |
% \end{macrocode} |
| 497 |
% \end{macro} |
| 498 |
% |
| 499 |
% \begin{macro}{eqnarray} |
| 500 |
% Undefine the "eqnarray" environment if not prevented by package option. |
| 501 |
% \begin{macrocode} |
| 502 |
% \newif\ifhep@eqnarray\hep@eqnarraytrue |
| 503 |
% \ifhep@eqnarray\else |
| 504 |
% \let\eqnarray\@undefined |
| 505 |
% \let\endeqnarray\@undefined |
| 506 |
% \fi |
| 507 |
% \end{macrocode} |
| 508 |
% \end{macro} |
| 509 |
% |
| 510 |
% \subsection{Operators} |
| 511 |
% |
| 512 |
% \begin{macro}{\tr} |
| 513 |
% \begin{macro}{\Tr} |
| 514 |
% \begin{macro}{\rank} |
| 515 |
% \begin{macro}{\erf} |
| 516 |
% \begin{macro}{\Res} |
| 517 |
% \begin{macro}{\sgn} |
| 518 |
% \begin{macro}{\sgn} |
| 519 |
% \begin{macro}{\diag} |
| 520 |
% Provide the "\diag", "\sgn", and some other operators. |
| 521 |
% \begin{macrocode} |
| 522 |
\DeclareMathOperator{\tr}{tr} |
| 523 |
\DeclareMathOperator{\Tr}{Tr} |
| 524 |
\DeclareMathOperator{\rank}{rank} |
| 525 |
\DeclareMathOperator{\erf}{erf} |
| 526 |
\DeclareMathOperator{\Res}{Res} |
| 527 |
\DeclareMathOperator{\sgn}{sgn} |
| 528 |
\DeclareMathOperator{\diag}{diag} |
| 529 |
\let\det\relax\DeclareMathOperator{\det}{det} |
| 530 |
% \end{macrocode} |
| 531 |
% \end{macro} |
| 532 |
% \end{macro} |
| 533 |
% \end{macro} |
| 534 |
% \end{macro} |
| 535 |
% \end{macro} |
| 536 |
% \end{macro} |
| 537 |
% \end{macro} |
| 538 |
% \end{macro} |
| 539 |
|
| 540 |
% \begin{macro}{\Re} |
| 541 |
% \begin{macro}{\Im} |
| 542 |
% Redefine the real and imaginary projectors. |
| 543 |
% \begin{macrocode} |
| 544 |
\let\Re\relax\DeclareMathOperator{\Re}{Re} |
| 545 |
\let\Im\relax\DeclareMathOperator{\Im}{Im} |
| 546 |
% \end{macrocode} |
| 547 |
% \end{macro} |
| 548 |
% \end{macro} |
| 549 |
|
| 550 |
% \begin{macro}{\transpose} |
| 551 |
% \begin{macro}{\trans} |
| 552 |
% Define a transpose symbol. |
| 553 |
% \begin{macrocode} |
| 554 |
\RequirePackage{amssymb} |
| 555 |
\newcommand*{\hep@transpose}[2]{\raisebox{\depth}{$\m@th#1\intercal$}} |
| 556 |
\newcommand*{\transpose}{{\mathpalette\hep@transpose{}}} |
| 557 |
\let\trans\transpose |
| 558 |
% \end{macrocode} |
| 559 |
% \end{macro} |
| 560 |
% \end{macro} |
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
% \subsubsection{Trigonometric functions} |
| 565 |
% |
| 566 |
% \begin{macro}{\cos} |
| 567 |
% \begin{macro}{\tan} |
| 568 |
% Adjust the height of of cos and tan to be equal to sin. |
| 569 |
% \begin{macrocode} |
| 570 |
\let\cos\undefined\DeclareMathOperator{\cos}{cos\vphantom{i}} |
| 571 |
\let\tan\undefined\DeclareMathOperator{\tan}{tan\vphantom{i}} |
| 572 |
% \end{macrocode} |
| 573 |
% \end{macro} |
| 574 |
% \end{macro} |
| 575 |
% \begin{macro}{\arccsc} |
| 576 |
% \begin{macro}{\arcsec} |
| 577 |
% \begin{macro}{\arccot} |
| 578 |
% Define arc operators. |
| 579 |
% \begin{macrocode} |
| 580 |
\DeclareMathOperator{\arccsc}{arccsc} |
| 581 |
\DeclareMathOperator{\arcsec}{arcsec} |
| 582 |
\DeclareMathOperator{\arccot}{arccot} |
| 583 |
% \end{macrocode} |
| 584 |
% \end{macro} |
| 585 |
% \end{macro} |
| 586 |
% \end{macro} |
| 587 |
% \begin{macro}{\asin} |
| 588 |
% \begin{macro}{\acos} |
| 589 |
% \begin{macro}{\atan} |
| 590 |
% \begin{macro}{\acsc} |
| 591 |
% \begin{macro}{\asec} |
| 592 |
% \begin{macro}{\acot} |
| 593 |
% Define shorthand for arc operators. |
| 594 |
% \begin{macrocode} |
| 595 |
\DeclareMathOperator{\asin}{asin} |
| 596 |
\DeclareMathOperator{\acos}{acos} |
| 597 |
\DeclareMathOperator{\atan}{atan} |
| 598 |
\DeclareMathOperator{\acsc}{acsc} |
| 599 |
\DeclareMathOperator{\asec}{asec} |
| 600 |
\DeclareMathOperator{\acot}{acot} |
| 601 |
% \end{macrocode} |
| 602 |
% \end{macro} |
| 603 |
% \end{macro} |
| 604 |
% \end{macro} |
| 605 |
% \end{macro} |
| 606 |
% \end{macro} |
| 607 |
% \end{macro} |
| 608 |
% \begin{macro}{\csch} |
| 609 |
% \begin{macro}{\sech} |
| 610 |
% Define csch and sech operators. |
| 611 |
% \begin{macrocode} |
| 612 |
\DeclareMathOperator{\csch}{csch} |
| 613 |
\DeclareMathOperator{\sech}{sech} |
| 614 |
% \end{macrocode} |
| 615 |
% \end{macro} |
| 616 |
% \end{macro} |
| 617 |
% |
| 618 |
% \subsection{Units and fractions} |
| 619 |
% |
| 620 |
% \begin{macro}{\unit} |
| 621 |
% Load the \software{units} package \cite{units} which provides the "\units" and "\nicefrac" macros. |
| 622 |
% Patch the "\unit" macros to behave like "\mathinner" within an equation |
| 623 |
% \begin{macrocode} |
| 624 |
\RequirePackage{units} |
| 625 |
\let\oldunit\unit |
| 626 |
\renewcommand*{\unit}[2][]{% |
| 627 |
\ifthenelse{\boolean{mmode}}{% |
| 628 |
\mathinner{\oldunit[#1]{#2}}% |
| 629 |
}{% |
| 630 |
\oldunit[#1]{#2}% |
| 631 |
}% |
| 632 |
} |
| 633 |
\let\oldunitfrac\unitfrac |
| 634 |
\renewcommand*{\unitfrac}[3][]{% |
| 635 |
\ifthenelse{\boolean{mmode}}{% |
| 636 |
\mathinner{\oldunitfrac[#1]{#2}{#3}}% |
| 637 |
}{% |
| 638 |
\oldunitfrac[#1]{#2}{#3}% |
| 639 |
}% |
| 640 |
} |
| 641 |
% \end{macrocode} |
| 642 |
% \end{macro} |
| 643 |
% |
| 644 |
% \begin{macro}{\inv} |
| 645 |
% Provide a macro for the inverse, useful in combination with the unit macro in text mode. |
| 646 |
% \begin{macrocode} |
| 647 |
\newcommand*{\inv}[2][1]{#2\ensuremath{^{-#1}}} |
| 648 |
% \end{macrocode} |
| 649 |
% \end{macro} |
| 650 |
% |
| 651 |
% \begin{macro}{\textfrac} |
| 652 |
% Provide the "\textfrac" macro useful in combination with a font using lining numerals. |
| 653 |
% \begin{macrocode} |
| 654 |
\newcommand*{\textfrac}[2]{\ensuremath{\nicefrac{\text{#1}}{\text{#2}}}} |
| 655 |
% \end{macrocode} |
| 656 |
% \end{macro} |
| 657 |
% |
| 658 |
% \begin{macro}{\flatfrac} |
| 659 |
% Provide a flat fraction. |
| 660 |
% \begin{macrocode} |
| 661 |
\DeclarePairedDelimiterX{\hep@flatfrac}[2]{.}{.}{% |
| 662 |
\kern-\nulldelimiterspace#1\delimsize/% |
| 663 |
\hep@left@delim#2\kern-\nulldelimiterspace% |
| 664 |
} |
| 665 |
\NewDocumentCommand{\flatfrac}{somm}{% |
| 666 |
\mathinner{% |
| 667 |
\IfBooleanTF{#1}{% |
| 668 |
\hep@flatfrac*{#3}{#4}% |
| 669 |
}{% |
| 670 |
\IfNoValueTF{#2}{\hep@left@delim#3/\hep@left@delim#4% |
| 671 |
}{% |
| 672 |
\hep@flatfrac[#2]{#3}{#4}% |
| 673 |
}% |
| 674 |
}% |
| 675 |
}% |
| 676 |
} |
| 677 |
% \end{macrocode} |
| 678 |
% \end{macro} |
| 679 |
% |
| 680 |
% \subsubsection{Differentials and derivatives} |
| 681 |
% |
| 682 |
% \begin{macro}{\int} |
| 683 |
% Redefine "\int". |
| 684 |
% \begin{macrocode} |
| 685 |
% \let\hep@int\int |
| 686 |
% \RenewDocumentCommand{\int}{oe{_^}}{% |
| 687 |
% \def\temp{\hep@int_{\IfValueT{#2}{#2}}^{\IfValueT{#3}{#3}}}% |
| 688 |
% \IfValueTF{#1}{\mathop{\temp#1}}{\temp}% |
| 689 |
% } |
| 690 |
% \end{macrocode} |
| 691 |
% \end{macro} |
| 692 |
% |
| 693 |
% \begin{macro}{\differential} |
| 694 |
% Define a generic differential "\differential". |
| 695 |
% \begin{macrocode} |
| 696 |
\newcommand*{\differential}[1]{\mathop{}\!#1} |
| 697 |
% \end{macrocode} |
| 698 |
% \end{macro} |
| 699 |
% |
| 700 |
% \begin{macro}{\newderivative} |
| 701 |
% Define a generic derivative. |
| 702 |
% \begin{macrocode} |
| 703 |
\newcommand*\newderivative[2]{ |
| 704 |
\NewDocumentCommand{#1}{somse{^}}{% |
| 705 |
\IfBooleanTF{##4}{% |
| 706 |
\IfBooleanTF{##1}{\nicefrac}{\frac}% |
| 707 |
}{% |
| 708 |
\IfBooleanTF{##1}{\flatfrac}{\dfrac}% |
| 709 |
}{% |
| 710 |
\differential#2\IfValueT{##5}{^{##5\!}}\IfValueT{##2}{##2}% |
| 711 |
}{% |
| 712 |
\differential#2{{}##3}\IfValueT{##5}{^{##5}}% |
| 713 |
}% |
| 714 |
} |
| 715 |
} |
| 716 |
% \end{macrocode} |
| 717 |
% \end{macro} |
| 718 |
% |
| 719 |
% \begin{macro}{\newpartialderivative} |
| 720 |
% Define a generic partial derivative |
| 721 |
% \begin{macrocode} |
| 722 |
\newcommand*\newpartialderivative[2]{ |
| 723 |
\NewDocumentCommand{#1}{somsE{^}{1}oE{^}{1}oE{^}{1}}{% |
| 724 |
\def\hep@one{\IfValueTF{##6}{##7}{0}} |
| 725 |
\def\hep@two{\IfValueTF{##8}{##9}{0}} |
| 726 |
\def\hep@sum{\the\numexpr##5+\hep@one+\hep@two\relax} |
| 727 |
\IfBooleanTF{##4}{% |
| 728 |
\IfBooleanTF{##1}{\nicefrac}{\frac}% |
| 729 |
}{% |
| 730 |
\IfBooleanTF{##1}{\flatfrac}{\dfrac}% |
| 731 |
}{% |
| 732 |
\differential#2\ifnum\hep@sum=1\relax\else{^{\hep@sum\!}}\fi |
| 733 |
\IfValueT{##2}{##2}% |
| 734 |
}{% |
| 735 |
\differential#2{{}##3}\ifnum##5=1\relax\else{^{##5}}\fi% |
| 736 |
\IfValueT{##6}{#2##6\ifnum##7=1\relax\else{^{##7}}\fi}% |
| 737 |
\IfValueT{##8}{#2##8\ifnum##9=1\relax\else{^{##9}}\fi}% |
| 738 |
}% |
| 739 |
} |
| 740 |
} |
| 741 |
% \end{macrocode} |
| 742 |
% \end{macro} |
| 743 |
% |
| 744 |
% \begin{macro}{\diffsymbol} |
| 745 |
% \begin{macro}{\diff} |
| 746 |
% \begin{macro}{\d} |
| 747 |
% \begin{macro}{\derivative} |
| 748 |
% \begin{macro}{\dv} |
| 749 |
% Define the differential "\d" and the usual derivative. |
| 750 |
% \begin{macrocode} |
| 751 |
\providecommand*{\diffsymbol}{d} |
| 752 |
\newcommand*{\diff}{\differential\diffsymbol} |
| 753 |
\AtBeginDocument{\mathdef{\d}{\diff}} |
| 754 |
\newderivative{\derivative}{\diffsymbol} |
| 755 |
\newcommand*\dv{\derivative} |
| 756 |
% \end{macrocode} |
| 757 |
% \end{macro} |
| 758 |
% \end{macro} |
| 759 |
% \end{macro} |
| 760 |
% \end{macro} |
| 761 |
% \end{macro} |
| 762 |
% |
| 763 |
% \begin{macro}{\partialdifferential} |
| 764 |
% \begin{macro}{\pd} |
| 765 |
% \begin{macro}{\partialderivative} |
| 766 |
% \begin{macro}{\pdv} |
| 767 |
% Define the partial differential and derivative. |
| 768 |
% \begin{macrocode} |
| 769 |
\newcommand*\partialdifferential{\differential\partial} |
| 770 |
\newcommand*\slashedpartialdifferential{\differential{\slashed\partial}} |
| 771 |
\newcommand*\spd{\slashedpartialdifferential} |
| 772 |
\newcommand*\pd{\partialdifferential} |
| 773 |
\newpartialderivative{\partialderivative}{\partial} |
| 774 |
\newcommand*\pdv{\partialderivative} |
| 775 |
% \end{macrocode} |
| 776 |
% \end{macro} |
| 777 |
% \end{macro} |
| 778 |
% \end{macro} |
| 779 |
% \end{macro} |
| 780 |
% |
| 781 |
% \begin{macro}{\gaugediffsymbol} |
| 782 |
% \begin{macro}{\gaugediff} |
| 783 |
% \begin{macro}{\D} |
| 784 |
% Define the gauge covariant differential "\D". |
| 785 |
% \begin{macrocode} |
| 786 |
\providecommand*{\gaugediffsymbol}{D} |
| 787 |
\newcommand*{\gaugediff}{\differential\gaugediffsymbol} |
| 788 |
\newcommand*{\D}{\gaugediff} |
| 789 |
% \end{macrocode} |
| 790 |
% \end{macro} |
| 791 |
% \end{macro} |
| 792 |
% \end{macro} |
| 793 |
% |
| 794 |
% \begin{macro}{\covariantdiff} |
| 795 |
% \begin{macro}{\cd} |
| 796 |
% Define the covariant differential "\cd". |
| 797 |
% \begin{macrocode} |
| 798 |
\newcommand*{\covariantdiff}{\differential\nabla} |
| 799 |
\newcommand*{\cd}{\covariantdiff} |
| 800 |
% \end{macrocode} |
| 801 |
% \end{macro} |
| 802 |
% \end{macro} |
| 803 |
% |
| 804 |
% \begin{macro}{\variation} |
| 805 |
% \begin{macro}{\var} |
| 806 |
% \begin{macro}{\functionalderivative} |
| 807 |
% \begin{macro}{\fdv} |
| 808 |
% Define the functional variation and derivative. |
| 809 |
% \begin{macrocode} |
| 810 |
\newcommand*\variation{\differential\delta} |
| 811 |
\newcommand*\var{\variation} |
| 812 |
\newpartialderivative{\functionalderivative}{\delta} |
| 813 |
\newcommand*\fdv{\functionalderivative} |
| 814 |
% \end{macrocode} |
| 815 |
% \end{macro} |
| 816 |
% \end{macro} |
| 817 |
% \end{macro} |
| 818 |
% \end{macro} |
| 819 |
% |
| 820 |
% \begin{macro}{\cancel} |
| 821 |
% \begin{macro}{\slashed} |
| 822 |
% Load the \software{cancel} \cite{cancel} and \software{slashed} \cite{slashed} packages which provide the "\cancel" and "\slashed" macros. |
| 823 |
% \begin{macrocode} |
| 824 |
\RequirePackage{cancel} |
| 825 |
\RequirePackage{slashed} |
| 826 |
\declareslashed{}{/}{.14}{0}{L} |
| 827 |
\declareslashed{}{/}{.055}{0}{\partial} |
| 828 |
\declareslashed{}{/}{.06}{0}{\gaugediff} |
| 829 |
\declareslashed{}{/}{.055}{0}{\partialdifferential} |
| 830 |
% \end{macrocode} |
| 831 |
% \end{macro} |
| 832 |
% \end{macro} |
| 833 |
% |
| 834 |
% \subsection{Paired delimiters} |
| 835 |
% |
| 836 |
% \begin{macro}{\left} |
| 837 |
% \begin{macro}{\right} |
| 838 |
% Load the \software{mleftright} package \cite{mleftright} and adjust the spacing around "\left" and "\right". |
| 839 |
% \begin{macrocode} |
| 840 |
\RequirePackage{mleftright} |
| 841 |
\mleftright |
| 842 |
% \end{macrocode} |
| 843 |
% \end{macro} |
| 844 |
% \end{macro} |
| 845 |
% |
| 846 |
% \begin{macro}{\noargumentsymbol} |
| 847 |
% \begin{macro}{\optionalargument} |
| 848 |
% Allow for macros to have an empty argument using the \software{etoolbox} package \cite{etoolbox}. |
| 849 |
% \begin{macrocode} |
| 850 |
\RequirePackage{etoolbox} |
| 851 |
\newcommand*{\noargumentsymbol}{\:\cdot\:} |
| 852 |
\newcommand*{\optionalargument}[1]{\ifblank{#1}{\noargumentsymbol}{#1}} |
| 853 |
% \end{macrocode} |
| 854 |
% \end{macro} |
| 855 |
% \end{macro} |
| 856 |
% |
| 857 |
% \begin{macro}{\abs} |
| 858 |
% \begin{macro}{\norm} |
| 859 |
% Absolute value and norm. |
| 860 |
% \begin{macrocode} |
| 861 |
\DeclarePairedDelimiterX\abs[1]\lvert\rvert{\optionalargument{#1}} |
| 862 |
\DeclarePairedDelimiterX\hep@norm[1]\lVert\rVert{\optionalargument{#1}} |
| 863 |
\DeclarePairedDelimiterXPP\hep@pnorm[2]{}\lVert\rVert{_{#1}}{#2} |
| 864 |
\NewDocumentCommand{\norm}{som}{% |
| 865 |
\IfValueTF{#2}{% |
| 866 |
\IfBooleanTF{#1}{\hep@pnorm*}{\hep@pnorm}{#2}% |
| 867 |
}{% |
| 868 |
\IfBooleanTF{#1}{\hep@norm*}{\hep@norm}% |
| 869 |
}{\optionalargument{#3}}% |
| 870 |
} |
| 871 |
% \end{macrocode} |
| 872 |
% \end{macro} |
| 873 |
% \end{macro} |
| 874 |
|
| 875 |
% \begin{macro}{\floor} |
| 876 |
% \begin{macro}{\ceil} |
| 877 |
% Floor and ceiling paired delimiters. |
| 878 |
% \begin{macrocode} |
| 879 |
\DeclarePairedDelimiter\ceil{\lceil}{\rceil} |
| 880 |
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor} |
| 881 |
% \end{macrocode} |
| 882 |
% \end{macro} |
| 883 |
% \end{macro} |
| 884 |
|
| 885 |
% \begin{macro}{\ordersymbol} |
| 886 |
% \begin{macro}{\order} |
| 887 |
% Order symbol and macro. |
| 888 |
% \begin{macrocode} |
| 889 |
\providecommand*{\ordersymbol}{\mathcal{O}} |
| 890 |
\DeclarePairedDelimiterXPP\order[1]{\ordersymbol}(){}{#1} |
| 891 |
% \end{macrocode} |
| 892 |
% \end{macro} |
| 893 |
% \end{macro} |
| 894 |
|
| 895 |
% \begin{macro}{\evaluated} |
| 896 |
% \begin{macro}{\eval} |
| 897 |
% Vertical evaluation bar |
| 898 |
% \begin{macrocode} |
| 899 |
\DeclarePairedDelimiter{\hep@evaluated}{.}{\rvert} |
| 900 |
\NewDocumentCommand{\evaluated}{som}{% |
| 901 |
\IfBooleanTF{#1}{% |
| 902 |
\hep@evaluated*{#3}% |
| 903 |
}{% |
| 904 |
\IfNoValueTF{#2}{#3\rvert}{\hep@evaluated[#2]{#3}}% |
| 905 |
}% |
| 906 |
} |
| 907 |
\newcommand*\eval{\evaluated} |
| 908 |
% \end{macrocode} |
| 909 |
% \end{macro} |
| 910 |
% \end{macro} |
| 911 |
|
| 912 |
% \begin{macro}{\row} |
| 913 |
% \begin{macro}{\column} |
| 914 |
% Shortcuts for rows and columns |
| 915 |
% \begin{macrocode} |
| 916 |
\newcommand*{\rowseperator}{,\,} |
| 917 |
\ExplSyntaxOn |
| 918 |
\newcommand*{\hep@row}[1]{ |
| 919 |
\seq_set_split:Nnn\hep@seq{,}{#1} |
| 920 |
\begin{matrix}\seq_use:Nn\hep@seq{\rowseperator}\end{matrix} |
| 921 |
} |
| 922 |
\newcommand*{\hep@column}[1]{% |
| 923 |
\seq_set_split:Nnn\hep@seq{,}{#1}% |
| 924 |
\begin{matrix}\seq_use:Nn\hep@seq{\\}\end{matrix}% |
| 925 |
} |
| 926 |
\ExplSyntaxOff |
| 927 |
\DeclarePairedDelimiterX{\hep@row@}[1]{(}{)}{\hep@row{#1}} |
| 928 |
\NewDocumentCommand{\hep@column@}{me{^}e{_}}{% |
| 929 |
\left(\hep@column{#1}\right)% |
| 930 |
\IfValueT{#2}{^{\!\!\!#2}}\IfValueT{#3}{_{\!\!\!#3}}% |
| 931 |
} |
| 932 |
\providecommand*{\column}{} |
| 933 |
\providecommand*{\row}{} |
| 934 |
\mathdef{\column}{\hep@column@} |
| 935 |
\providecommand*{\row}{} |
| 936 |
\mathdef{\row}{\hep@row@} |
| 937 |
% \end{macrocode} |
| 938 |
% \end{macro} |
| 939 |
% \end{macro} |
| 940 |
|
| 941 |
% \subsubsection{Set and Probability} |
| 942 |
% |
| 943 |
% \begin{macro}{\midbar} |
| 944 |
% Define a generic midbar. |
| 945 |
% \begin{macrocode} |
| 946 |
\newcommand*\hep@left@delim{\mathopen{}} |
| 947 |
\providecommand*{\midbar}[1][]{% |
| 948 |
\nonscript\:#1\vert\allowbreak\nonscript\:\hep@left@delim% |
| 949 |
} |
| 950 |
% \end{macrocode} |
| 951 |
% \end{macro} |
| 952 |
|
| 953 |
% Check if "nfssect-cfr" is loaeded and patch the global "\set" macro into the "cfr" namespace |
| 954 |
% \begin{macrocode} |
| 955 |
\RequirePackage{xpatch} |
| 956 |
\@ifundefined{exfs@merge@families}{}{% |
| 957 |
\xpatchcmd{\exfs@merge@families}{\set}{\cfr@set}{}{}% |
| 958 |
\xpatchcmd{\exfs@merge@families}{\set}{\cfr@set}{}{}% |
| 959 |
\xpatchcmd{\exfs@merge@families}{\set}{\cfr@set}{}{}% |
| 960 |
}% |
| 961 |
% \end{macrocode} |
| 962 |
% \begin{macro}{\suchthat} |
| 963 |
% \begin{macro}{\set} |
| 964 |
% Define a "\set" macro that allows a midbar via "\suchthat". |
| 965 |
% \begin{macrocode} |
| 966 |
\providecommand*\suchthat{\midbar} |
| 967 |
\DeclarePairedDelimiterX\set[1]\{\}{% |
| 968 |
\renewcommand*\suchthat{\midbar[\delimsize]}#1% |
| 969 |
} |
| 970 |
% \end{macrocode} |
| 971 |
% \end{macro} |
| 972 |
% \end{macro} |
| 973 |
|
| 974 |
% \begin{macro}{\probabilitysymbol} |
| 975 |
% \begin{macro}{\given} |
| 976 |
% \begin{macro}{\Pr} |
| 977 |
% Redefine the "\Pr" macro to a macro that takes a "\given" macro and generates a midbar. |
| 978 |
% \begin{macrocode} |
| 979 |
\providecommand*{\probabilitysymbol}{\operatorname{Pr}} |
| 980 |
\providecommand*\given{\midbar} |
| 981 |
\DeclarePairedDelimiterXPP\hep@Pr[1]{% |
| 982 |
\probabilitysymbol}(){}{% |
| 983 |
\renewcommand*\given{\midbar[\delimsize]}#1% |
| 984 |
} |
| 985 |
\let\Pr\relax |
| 986 |
\NewDocumentCommand{\Pr}{so}{% |
| 987 |
\IfValueTF{#2}{% |
| 988 |
\IfBooleanTF{#1}{\hep@Pr*}{\hep@Pr}{#2}% |
| 989 |
}{% |
| 990 |
\probabilitysymbol% |
| 991 |
}% |
| 992 |
} |
| 993 |
% \end{macrocode} |
| 994 |
% \end{macro} |
| 995 |
% \end{macro} |
| 996 |
% \end{macro} |
| 997 |
|
| 998 |
% \subsubsection{Commutators} |
| 999 |
% |
| 1000 |
% \begin{macro}{\newpair} |
| 1001 |
% Define the "\newpair" macro that generates pairs surrounded by brackets. |
| 1002 |
% \begin{macrocode} |
| 1003 |
\NewDocumentCommand{\newpair}{mmme{_}e{^}}{% |
| 1004 |
\IfNoValueTF{#4}{% |
| 1005 |
\IfNoValueTF{#5}{% |
| 1006 |
\DeclarePairedDelimiterX{#1}[2]{#2}{#3}% |
| 1007 |
}{% |
| 1008 |
\DeclarePairedDelimiterXPP{#1}[2]{}{#2}{#3}{^{#5}}% |
| 1009 |
}% |
| 1010 |
}{% |
| 1011 |
\DeclarePairedDelimiterXPP{#1}[2]{}{#2}{#3}{_{#4}}% |
| 1012 |
}{% |
| 1013 |
\optionalargument{##1},\optionalargument{##2}% |
| 1014 |
}% |
| 1015 |
} |
| 1016 |
% \end{macrocode} |
| 1017 |
%\end{macro} |
| 1018 |
% |
| 1019 |
% \begin{macro}{\innerproduct} |
| 1020 |
% \begin{macro}{\poissonbracket} |
| 1021 |
% \begin{macro}{\pb} |
| 1022 |
% \begin{macro}{\commutator} |
| 1023 |
% \begin{macro}{\comm} |
| 1024 |
% \begin{macro}{\anticommutator} |
| 1025 |
% \begin{macro}{\acomm} |
| 1026 |
% Poissonbracket, commutator and anti-commutator. |
| 1027 |
% \begin{macrocode} |
| 1028 |
\newpair\innerproduct\langle\rangle |
| 1029 |
\newpair\poissonbracket\lbrace\rbrace |
| 1030 |
\newpair\commutator\lbrack\rbrack |
| 1031 |
\newcommand*\pb{\poissonbracket} |
| 1032 |
\newcommand*\comm{\commutator} |
| 1033 |
\newcommand*\acomm{\poissonbracket} |
| 1034 |
% \end{macrocode} |
| 1035 |
% \end{macro} |
| 1036 |
% \end{macro} |
| 1037 |
% \end{macro} |
| 1038 |
% \end{macro} |
| 1039 |
% \end{macro} |
| 1040 |
% \end{macro} |
| 1041 |
% \end{macro} |
| 1042 |
% |
| 1043 |
% \subsubsection{Bra-ket notation} |
| 1044 |
% |
| 1045 |
% \begin{macro}{\braketspace} |
| 1046 |
% Define the space within braket notation. |
| 1047 |
% \begin{macrocode} |
| 1048 |
% \providecommand*\braketspace{\mskip1mu} |
| 1049 |
\providecommand*\braketouterspace{\mskip1mu} |
| 1050 |
\providecommand*\braketinnerspace{\mskip3mu} |
| 1051 |
\newcommand*\hep@midvert{% |
| 1052 |
\braketinnerspace\delimsize\vert\braketinnerspace\hep@left@delim% |
| 1053 |
} |
| 1054 |
% \end{macrocode} |
| 1055 |
% \end{macro} |
| 1056 |
% |
| 1057 |
% \begin{macro}{\braket} |
| 1058 |
% Define the braket macro. |
| 1059 |
% \begin{macrocode} |
| 1060 |
\DeclarePairedDelimiterX\braket[2]{\langle}{\rangle}{% |
| 1061 |
\braketouterspace#1\hep@midvert#2\braketouterspace% |
| 1062 |
} |
| 1063 |
% \end{macrocode} |
| 1064 |
% \end{macro} |
| 1065 |
|
| 1066 |
% \begin{macro}{\bra} |
| 1067 |
% Define the bra macro. |
| 1068 |
% \begin{macrocode} |
| 1069 |
\DeclarePairedDelimiterXPP\hep@bra[1]{% |
| 1070 |
}{\langle}{\rvert}{\braketinnerspace% |
| 1071 |
}{\braketouterspace#1\braketinnerspace% |
| 1072 |
} |
| 1073 |
\NewDocumentCommand{\bra}{smt\ket sgt\ketbra sgg}{% |
| 1074 |
\IfBooleanTF{#6}{% |
| 1075 |
\IfBooleanTF{#1}{\braket*{#2}{#8}}{\braket{#2}{#8}}% |
| 1076 |
\IfBooleanTF{#7}{\bra*{#9}}{\bra{#9}}% |
| 1077 |
}{ |
| 1078 |
\IfBooleanTF{#3}{% |
| 1079 |
\IfBooleanTF{#1}{\braket*}{% |
| 1080 |
\IfBooleanTF{#4}{\braket*}{\braket}}{#2}{#5% |
| 1081 |
}% |
| 1082 |
}{% |
| 1083 |
\IfBooleanTF{#1}{\hep@bra*}{\hep@bra}{#2}% |
| 1084 |
}% |
| 1085 |
}% |
| 1086 |
} |
| 1087 |
% \end{macrocode} |
| 1088 |
% \end{macro} |
| 1089 |
|
| 1090 |
% \begin{macro}{\ket} |
| 1091 |
% Define the ket macro. |
| 1092 |
% \begin{macrocode} |
| 1093 |
\DeclarePairedDelimiterXPP\ket[1]{% |
| 1094 |
\braketinnerspace}{\lvert}{\rangle}{% |
| 1095 |
}{% |
| 1096 |
\braketinnerspace\hep@left@delim#1\braketouterspace% |
| 1097 |
} |
| 1098 |
% \end{macrocode} |
| 1099 |
% \end{macro} |
| 1100 |
|
| 1101 |
% \begin{macro}{\ketbra} |
| 1102 |
% Define the ketbra macro. |
| 1103 |
% \begin{macrocode} |
| 1104 |
\NewDocumentCommand{\ketbra}{smm}{% |
| 1105 |
\IfBooleanTF{#1}{% |
| 1106 |
\ket*{#2}\bra*{#3}% |
| 1107 |
}{% |
| 1108 |
\ket{#2}\bra{#3}% |
| 1109 |
}% |
| 1110 |
} |
| 1111 |
% \end{macrocode} |
| 1112 |
% \end{macro} |
| 1113 |
|
| 1114 |
% \begin{macro}{\matrixelement} |
| 1115 |
% \begin{macro}{\mel} |
| 1116 |
% Define the matrixelement macro. |
| 1117 |
% \begin{macrocode} |
| 1118 |
\DeclarePairedDelimiterX\matrixelement[3]{% |
| 1119 |
\langle}{\rangle |
| 1120 |
}{% |
| 1121 |
\braketouterspace#1\hep@midvert#2\hep@midvert#3\braketouterspace% |
| 1122 |
} |
| 1123 |
\newcommand*\matrixel{\matrixelement} |
| 1124 |
\newcommand*\mel{\matrixelement} |
| 1125 |
% \end{macrocode} |
| 1126 |
% \end{macro} |
| 1127 |
% \end{macro} |
| 1128 |
|
| 1129 |
% \begin{macro}{\expectationvalue} |
| 1130 |
% \begin{macro}{\ev} |
| 1131 |
% \begin{macro}{\vev} |
| 1132 |
% Define the expectationvalue and vev macros. |
| 1133 |
% \begin{macrocode} |
| 1134 |
\DeclarePairedDelimiterX\hep@expvalue[1]{\langle}{\rangle}{% |
| 1135 |
\braketouterspace#1\braketouterspace% |
| 1136 |
} |
| 1137 |
\NewDocumentCommand{\expectationvalue}{som}{% |
| 1138 |
\IfNoValueTF{#2}{% |
| 1139 |
\IfBooleanTF{#1}{\hep@expvalue*}{\hep@expvalue}{#3}% |
| 1140 |
}{% |
| 1141 |
\IfBooleanTF{#1}{\matrixelement*}{\matrixelement}{#2}{#3}{#2}% |
| 1142 |
}% |
| 1143 |
} |
| 1144 |
\newcommand*\ev{\expectationvalue} |
| 1145 |
\newcommand*\vev[1]{\expectationvalue[0]{#1}} |
| 1146 |
% \end{macrocode} |
| 1147 |
% \end{macro} |
| 1148 |
% \end{macro} |
| 1149 |
% \end{macro} |
| 1150 |
% |
| 1151 |
%</package> |
| 1152 |
% |
| 1153 |
% \section{Test} |
| 1154 |
% |
| 1155 |
%<*test> |
| 1156 |
% |
| 1157 |
% \begin{macrocode} |
| 1158 |
\documentclass{article} |
| 1159 |
|
| 1160 |
\usepackage{hep-math} |
| 1161 |
|
| 1162 |
\begin{document} |
| 1163 |
|
| 1164 |
\begin{gather} |
| 1165 |
\bra{x}\ket{y} |
| 1166 |
\braket*{x}{y}\\ |
| 1167 |
\dv[f]{x}^3 |
| 1168 |
\pdv[f]{x}[y]^2[z]^3 |
| 1169 |
\fdv[f]{x}^3[y]\\ |
| 1170 |
\set{x \suchthat x \in X} |
| 1171 |
\end{gather} |
| 1172 |
|
| 1173 |
\end{document} |
| 1174 |
|
| 1175 |
% \end{macrocode} |
| 1176 |
%</test> |
| 1177 |
% |
| 1178 |
% \section{Readme} |
| 1179 |
% |
| 1180 |
%<*readme> |
| 1181 |
% |
| 1182 |
% \begin{macrocode} |
| 1183 |
# The `hep-math` package |
| 1184 |
|
| 1185 |
Extended math macros |
| 1186 |
|
| 1187 |
## Introduction |
| 1188 |
|
| 1189 |
The `hep-math` package provides some additional features beyond the |
| 1190 |
`mathtools` and `amsmath` packages. |
| 1191 |
|
| 1192 |
To use the package place `\usepackage{hep-math}` in the preamble. |
| 1193 |
|
| 1194 |
## Author |
| 1195 |
|
| 1196 |
Jan Hajer |
| 1197 |
|
| 1198 |
## License |
| 1199 |
|
| 1200 |
This file may be distributed and/or modified under the conditions of the |
| 1201 |
`LaTeX` Project Public License, either version 1.3c of this license or |
| 1202 |
(at your option) any later version. The latest version of this license is |
| 1203 |
in `http://www.latex-project.org/lppl.txt` and version 1.3c or later is |
| 1204 |
part of all distributions of LaTeX version 2005/12/01 or later. |
| 1205 |
% \end{macrocode} |
| 1206 |
% |
| 1207 |
%</readme> |
| 1208 |
% |
| 1209 |
% \Finale |
| 1210 |
|
| 1211 |
\endinput |
| 1212 |
|
| 1213 |
% \PrintIndex |
| 1214 |
% makeindex -s gglo.ist -o hep-math-implementation.gls hep-math-implementation.glo |
| 1215 |
% makeindex -s gglo.ist -o hep-math-implementation.ind hep-math-implementation.idx |