-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMtyLaTeXCmds.tex
205 lines (190 loc) · 9.94 KB
/
MtyLaTeXCmds.tex
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
\usepackage{ifluatex}
\usepackage{listings, jvlisting}
\usepackage{mathtools}
\usepackage{xstring}
% Latex
% The last definition of the command is applied across all pages.
% see [Using later defined macro values](https://tex.stackexchange.com/questions/248076/using-later-defined-macro-values)
\makeatletter
% Reserve command name. The command must be pre-defined in advance of first use.
% If you split the document into multiple files, you must put \rsvDef command in EACH of the file which refers the later-defined command.
\newcommand*{\rsvDef}[1]{%
\providecommand{#1}{%
\begingroup%
\def\tempString{The command `\string#1' is not fully defined in .aux file yet. Compile one more time.}%
\textcolor{red}{\tempString}%
\@latex@warning{\tempString}%
\endgroup%
}%
}
% Overriding command definition.
\newcommand*{\laterDef}[2]{\protected@write\@auxout{}{\gdef\string#1{#2}}}
\newcommand*{\laterEdef}[2]{%
\begingroup%
\edef\tempString{#2}%
\protected@write\@auxout{}{\gdef\string#1{\tempString}}%
\endgroup%
}
\makeatother
% Obtain current head number.
\newcommand*{\getTitleNum}{% "%" comments out the line-break
\ifthenelse{\arabic{chapter}=0}{\thepart}{%
\ifthenelse{\arabic{section}=0}{\thechapter}{%
\ifthenelse{\arabic{subsection}=0}{\thesection}{%
\ifthenelse{\arabic{subsubsection}=0}{\thesubsection}{%
\ifthenelse{\arabic{subsubsubsection}=0}{\thesubsubsection}{\thesubsubsubsection}%
}%
}%
}%
}%
}
% Escape underscore.
% ---------- (deprecated at 2024-01-18) ----------
% \makeatletter
% \newcommand*{\@escapeUnderscore}[1]{#1\endgroup}
% \newcommand*{\escapeUnderscore}{\begingroup\@makeother\_\@escapeUnderscore}
% \makeatother
% --------------------
% ---------- (added at 2024-01-18) ----------
\newcommand{\escapeUnderscore}[1]{\StrSubstitute{#1}{_}{\_\allowbreak}} % \allowbreak prevents overfull at table cell.
% --------------------
% new color for \textcolor command
\definecolor{darkpastelgreen}{rgb}{0.01, 0.75, 0.24}
% natural science
% general purpose
\newcommand*{\ctext}[1]{\raise0.2ex\hbox{\textcircled{\scriptsize{#1}}}}
% mathematics
% general purpose
\DeclarePairedDelimiterX{\parens}[1]{\lparen}{\rparen}{#1}
\DeclarePairedDelimiterX{\braces}[1]{\lbrace}{\rbrace}{#1}
\DeclarePairedDelimiterX{\bracks}[1]{\lbrack}{\rbrack}{#1}
\DeclarePairedDelimiterX{\verts}[1]{|}{|}{#1}
\DeclarePairedDelimiterX{\Verts}[1]{\|}{\|}{#1}
\newcommand*{\as}{{\quad\textrm{as}\quad}}
\newcommand*{\st}{{\textrm{ s.t. }}}
\DeclarePairedDelimiterX{\setComprehension}[2]{\lbrace}{\rbrace}{#1\,\delimsize\vert\,#2}
\newcommand*{\naturalNumbers}{\mathbb{N}}
\newcommand*{\integers}{\mathbb{Z}}
\newcommand*{\rationalNumbers}{\mathbb{Q}}
\newcommand*{\realNumbers}{\mathbb{R}}
\newcommand*{\complexNumbers}{\mathbb{C}}
\newcommand*{\field}{\mathbb{F}}
\newcommand*{\func}[2]{{#1}\parens*{#2}}
\newcommand*{\argmax}{\operatorname*{arg~max}}
\newcommand*{\argmin}{\operatorname*{arg~min}}
% set theory
\newcommand*{\range}[2]{\braces*{#1,\dotsc,#2}}
\providecommand{\complement}{}\renewcommand{\complement}{\mathrm{c}}
\newcommand*{\ind}[2]{\mathbbm{1}_{#1}\parens*{#2}}
\newcommand*{\indII}[1]{\mathbbm{1}\braces*{#1}}
% number theory
\newcommand*{\abs}[1]{\verts*{#1}}
\newcommand*{\combi}[2]{{_{#1}\mathrm{C}_{#2}}}
\newcommand*{\perm}[2]{{_{#1}\mathrm{P}_{#2}}}
\newcommand*{\GaloisField}[1]{\mathrm{GF}\parens*{#1}}
% real analysis
\newcommand*{\NapierE}{\mathrm{e}}
\newcommand*{\sgn}{\operatorname{sgn}}
\newcommand*{\rect}{\operatorname{rect}}
\newcommand*{\cl}[1]{\operatorname{cl}#1}
\newcommand*{\Img}[1]{\operatorname{Img}\parens*{#1}}
\newcommand*{\dom}[1]{\operatorname{dom}\parens*{#1}}
\newcommand*{\LittleO}[2]{\underset{#1}{o}\parens*{#2}}
\newcommand*{\norm}[1]{\Verts*{#1}}
\newcommand*{\floor}[1]{\left\lfloor#1\right\rfloor}
\newcommand*{\ceil}[1]{\left\lceil#1\right\rceil}
\newcommand*{\sinc}{\operatorname{sinc}}
\newcommand*{\nsinc}{\operatorname{nsinc}}
\newcommand*{\GammaFunc}[1]{\Gamma\parens*{#1}}
\newcommand*{\erf}{\operatorname{erf}}
% inverse trigonometric function
\newcommand*{\asin}{\operatorname{Sin}^{-1}}
\newcommand*{\acos}{\operatorname{Cos}^{-1}}
\newcommand*{\atan}{\operatorname{Tan}^{-1}}
\newcommand*{\atanEx}[2]{\atan{\parens*{#1,#2}}}
% convolution
\newcommand*{\cycConv}[2]{{#1}\underset{\text{cyc}}{*}{#2}}
% derivative
\newcommand*{\deriv}[3]{\frac{\operatorname{d}^{#3}#1}{\operatorname{d}{#2}^{#3}}}
\newcommand*{\derivLong}[3]{\frac{\operatorname{d}^{#3}}{\operatorname{d}{#2}^{#3}}#1}
\newcommand*{\partDeriv}[3]{\frac{\operatorname{\partial}^{#3}#1}{\operatorname{\partial}{#2}^{#3}}}
\newcommand*{\partDerivLong}[3]{\frac{\operatorname{\partial}^{#3}}{\operatorname{\partial}{#2}^{#3}}#1}
\newcommand*{\partDerivIIHetero}[3]{\frac{\operatorname{\partial}^2#1}{\partial#2\operatorname{\partial}#3}}
\newcommand*{\partDerivIIHeteroLong}[3]{{\frac{\operatorname{\partial}^2}{\partial#2\operatorname{\partial}#3}#1}}
% integral
\newcommand*{\pv}{{\textrm{ p.v. }}}
\newcommand*{\integrate}[5]{\int_{#1}^{#2}{#3}{\mathrm{d}^{#4}}#5}
\newcommand*{\LebInteg}[4]{\int_{#1} {#2} {#3}\parens*{\mathrm{d}#4}}
% complex analysis
\newcommand*{\conj}[1]{\overline{#1}}
\providecommand{\Re}{}\renewcommand{\Re}[1]{{\operatorname{Re}{\parens*{#1}}}}
\providecommand{\Im}{}\renewcommand{\Im}[1]{{\operatorname{Im}{\parens*{#1}}}}
\newcommand*{\Arg}{\operatorname{Arg}}
\newcommand*{\Log}{\operatorname{Log}}
% Laplace transform
\newcommand*{\LPLC}[1]{\operatorname{\mathcal{L}}\parens*{#1}}
\newcommand*{\ILPLC}[1]{\operatorname{\mathcal{L}}^{-1}\parens*{#1}}
% discrete fourier transform
\newcommand*{\DFT}[1]{\mathrm{DFT}\parens*{#1}}
\newcommand*{\IDFT}[1]{\mathrm{IDFT}\parens*{#1}}
% Z-transform
\newcommand*{\ZTrans}[1]{\operatorname{\mathcal{Z}}\parens*{#1}}
\newcommand*{\IZTrans}[1]{\operatorname{\mathcal{Z}}^{-1}\parens*{#1}}
% linear algebra
\newcommand*{\bm}[1]{{\boldsymbol{#1}}}
\newcommand*{\matEntry}[3]{#1\bracks*{#2}\bracks*{#3}}
\newcommand*{\matPart}[5]{\matEntry{#1}{#2:#3}{#4:#5}}
\newcommand*{\diag}[1]{\operatorname{diag}\parens*{#1}}
\newcommand*{\transpose}[1]{{#1}^\top}
\newcommand*{\HerConj}[1]{{#1}^*}
\newcommand*{\tr}[1]{\operatorname{tr}{\parens*{#1}}}
\newcommand*{\inprod}[2]{\left\langle#1,#2\right\rangle}
\newcommand*{\HadamardProd}{\odot}
\newcommand*{\HadamardDiv}{\oslash}
\newcommand*{\Span}[1]{\operatorname{span}\bracks*{#1}}
\newcommand*{\Ker}[1]{\operatorname{Ker}\parens*{#1}}
\newcommand*{\rank}[1]{\operatorname{rank}\parens*{#1}}
% vector
% unit vector
\newcommand*{\vix}{\bm{i}_x}
\newcommand*{\viy}{\bm{i}_y}
\newcommand*{\viz}{\bm{i}_z}
% probability theory
\newcommand*{\PDF}[2]{\operatorname{PDF}\bracks*{#1,\;#2}}
\newcommand*{\Ber}[1]{\operatorname{Ber}\parens*{#1}}
\newcommand*{\Beta}[2]{\operatorname{Beta}\parens*{#1,#2}}
\newcommand*{\ExpDist}[1]{\operatorname{ExpDist}\parens*{#1}}
\newcommand*{\ErlangDist}[2]{\operatorname{ErlangDist}\parens*{#1,#2}}
\newcommand*{\PoissonDist}[1]{\operatorname{PoissonDist}\parens*{#1}}
\newcommand*{\GammaDist}[2]{\operatorname{Gamma}\parens*{#1,#2}}
\newcommand*{\cind}[2]{\ind{#1\left| #2\right.}} % conditional indicator function
\providecommand{\Pr}{}\renewcommand{\Pr}[1]{\operatorname{Pr}\parens*{#1}}
\DeclarePairedDelimiterX{\cPrParens}[2]{(}{)}{#1\,\delimsize\vert\,#2}
\newcommand*{\cPr}[2]{\operatorname{Pr}\cPrParens{#1}{#2}}
\newcommand*{\E}[2]{\operatorname{E}_{#1}\bracks*{#2}}
\newcommand*{\cE}[3]{\E{#1}{\left.#2\right|#3}}
\newcommand*{\Var}[2]{\operatorname{Var}_{#1}\bracks*{#2}}
\newcommand*{\Cov}[2]{\operatorname{Cov}\bracks*{#1,#2}}
\newcommand*{\CovMat}[1]{\operatorname{Cov}\bracks*{#1}}
% graph theory
\newcommand*{\neighborhood}{\mathcal{N}}
% computer science
% fixed-point arithmetic
\newcommand*{\IntPartBW}[1]{\underbracket[0.140ex]{#1}_\text{i}} % 0.140ex is half of the default thickness. See: [How to make underbracket thinner](https://tex.stackexchange.com/questions/559078/how-to-make-underbracket-thinner)
\newcommand*{\DecPartBW}[1]{\underbracket[0.140ex]{#1}_\text{d}}
\newcommand*{\TotalBW}[1]{\underbracket[0.140ex]{#1}}
\newcommand*{\Rat}[1]{\operatorname{Rat}\parens*{#1}} % Maps a fixed-point number to a corresponding rational number.
% programming
\newcommand*{\plpl}{\mathrel{++}}
\newcommand*{\pleq}{\mathrel{+}=}
\newcommand*{\asteq}{\mathrel{*}=}
\ifluatex
\newcommand*{\inlineCode}[1]{\lstinline[basicstyle=\ttfamily]|#1|}
\else
\newcommand*{\inlineCode}[1]{\lstinline[inputencoding=utf8, basicstyle=\ttfamily]|#1|}
\fi
% physics
% unit of measurement
\providecommand{\second}{\text{s}}
\providecommand{\hertz}{\text{Hz}}
\providecommand{\decibel}{\text{dB}}