-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
bmc-maths.sty
107 lines (98 loc) · 3.59 KB
/
bmc-maths.sty
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
%══════════════════════════════════════════%
% %
% BMC %
% A Bespoke, Multipurpose Class %
% -- Maths Functionality -- %
% -~=~- %
% Authored by tecosaur %
% %
%══════════════════════════════════════════%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bmc-maths}[2019/06/09 Maths functionality used in the BMC class]
\newif\ifbmc@nomathsfont
\newif\ifbmc@plainmathsdd
\bmc@nomathsfontfalse
\bmc@plainmathsddfalse
\DeclareOption{nofont}{\bmc@nomathsfonttrue}
\DeclareOption{plaindd}{\bmc@plainmathsddtrue}
\ProcessOptions\relax
% various math packages
\RequirePackage{amsmath,amssymb}
\ifbmc@nomathsfont\else
\RequirePackage[varbb]{newpxmath}
\fi
\RequirePackage{xfrac}
\RequirePackage[makeroom]{cancel}
\RequirePackage{mathtools}
% deliminators
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\round}{\lfloor}{\rceil}
% number sets
\newcommand{\RR}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{R}}{\mathbb{R}^{#1}}}}
\newcommand{\NN}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{N}}{\mathbb{N}^{#1}}}}
\newcommand{\ZZ}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{Z}}{\mathbb{Z}^{#1}}}}
\newcommand{\QQ}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{Q}}{\mathbb{Q}^{#1}}}}
\newcommand{\CC}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{C}}{\mathbb{C}^{#1}}}}
\newcommand{\PP}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{P}}{\mathbb{P}^{#1}}}}
\newcommand{\HH}[1][]{\ensuremath{\ifstrempty{#1}{\mathbb{H}}{\mathbb{H}^{#1}}}}
% expected value
\newcommand{\EE}{\ensuremath{\mathbb{E}}}
% commonly used macros
% - differentials
\ifbmc@plainmathsdd
\newcommand{\dd}[1][]{\ensuremath{\,\mathsl{d}^{#1}}}
\else
\newsavebox\diffdbox
\newcommand{\slantedromand}{{\mathpalette\makesl{d}}}
\newcommand{\makesl}[2]{%
\begingroup
\sbox{\diffdbox}{$\mathsurround=0pt#1\mathrm{#2}$}%
\pdfsave
\pdfsetmatrix{1 0 0.2 1}%
\rlap{\usebox{\diffdbox}}%
\pdfrestore
\hskip\wd\diffdbox
\endgroup
}
\newcommand{\dd}[1][]{\ensuremath{\mathop{}\!\ifstrempty{#1}{%
\slantedromand\@ifnextchar^{\hspace{0.2ex}}{\hspace{0.1ex}}}%
{\slantedromand\hspace{0.2ex}^{#1}}}}
\fi
\ProvideDocumentCommand\dv{o m g}{%
\ensuremath{%
\IfValueTF{#3}{%
\IfNoValueTF{#1}{%
\frac{\dd #2}{\dd #3}%
}{%
\frac{\dd^{#1} #2}{\dd #3^{#1}}%
}%
}{%
\IfNoValueTF{#1}{%
\frac{\dd}{\dd #2}%
}{%
\frac{\dd^{#1}}{\dd #2^{#1}}%
}%
}%
}%
}
\providecommand*{\pdv}[3][]{\frac{\partial^{#1}#2}{\partial#3^{#1}}}
% - others
\DeclareMathOperator{\Lap}{\mathcal{L}}
\DeclareMathOperator{\Var}{Var} % varience
\DeclareMathOperator{\Cov}{Cov} % covarience
\DeclareMathOperator{\E}{E} % expected
% Since the amsthm package isn't loaded
\newcommand*{\qed}{\hfill\ensuremath{\blacksquare}}
\newcommand*{\qedhere}{\hfill\ensuremath{\square}}
% I prefer the slanted \leq
\let\oldleq\leq % save them in case they're every wanted
\let\oldgeq\geq
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
% redefine matrix env to allow for alignment, use r as default
\renewcommand*\env@matrix[1][r]{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols #1}}