-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.tex
94 lines (76 loc) · 3.09 KB
/
commands.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
% Obscure delimiters
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\DeclarePairedDelimiter{\ip}{\langle}{\rangle}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
% Better left and right: https://tex.stackexchange.com/a/2610/217707
\newcommand{\lft}{\mathopen{}\mathclose\bgroup\left}
\newcommand{\rgt}{\aftergroup\egroup\right}
% Common sets
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
% Expected value and variance
\newcommand{\E}{\mathbb{E}}
\newcommand{\Var}{\mathrm{Var}}
% Input and output space
\newcommand{\X}{\mathcal{X}}
\newcommand{\Y}{\mathcal{Y}}
% Vector, matrix, and tensor
\renewcommand{\vec}[1]{\bm{#1}}
\newcommand{\mat}[1]{\bm{#1}}
\newcommand{\tens}[1]{\bm{\mathsf{#1}}}
% Big-O notation
\newcommand{\bigo}[1]{\mathcal{O}\lft(#1\rgt)}
% Common functions
\newcommand{\transpose}[1]{#1^\top}
\newcommand{\inv}[1]{#1^{-1}}
\renewcommand{\det}[1]{\mathrm{det}\lft(#1\rgt)}
\newcommand{\tr}[1]{\mathrm{tr}\lft(#1\rgt)}
\newcommand{\diag}[1]{\mathrm{diag}\lft(#1\rgt)}
% Distributions
\newcommand{\sample}{\sim}
\newcommand{\sampleiid}{\overset{\mathrm{iid}}{\sim}}
\NewDocumentCommand{\Gauss}{O{0}O{1}o}{\mathcal{N}\lft(#1,#2 \IfValueT{#3}{\mid #3}\rgt)}
\newcommand{\MultiGauss}{\Gauss[\vec{0}][\mat{I}]}
\NewDocumentCommand{\Unif}{m}{\mathrm{Unif}\parentheses*{#1}}
% Math comment in smaller font size
\newcommand{\mathcomment}[1]{\mathrm{\footnotesize #1}}
% Gradient and Hessian operator
\newcommand{\grad}[2]{\vec{\nabla}_{\! #2} #1}
\newcommand{\hess}[2]{\vec{\nabla}^2_{\! #2} #1}
\newcommand{\jacob}[2]{\vec{J}_{#2} #1}
% List of symbols
\newlist{abbrv}{itemize}{1}
\setlist[abbrv,1]{label=,labelwidth=1in,align=parleft,itemsep=0.1\baselineskip,leftmargin=!}
% Add a period to the end of an abbreviation unless there's one already, then \xspace
\makeatletter
\DeclareRobustCommand\onedot{\futurelet\@let@token\@onedot}
\def\@onedot{\ifx\@let@token.\else.\null\fi\xspace}
\def\eg{\emph{e.g}\onedot} \def\Eg{\emph{E.g}\onedot}
\def\ie{\emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot}
\def\cf{\emph{c.f}\onedot} \def\Cf{\emph{C.f}\onedot}
\def\etc{\emph{etc}\onedot} \def\vs{\emph{vs}\onedot}
\def\wrt{w.r.t\onedot} \def\dof{d.o.f\onedot}
\makeatother
% Argument optima
\DeclareMathOperator*{\argmax}{argmax} % no space, limits underneath in displays
\DeclareMathOperator*{\argmin}{argmin} % no space, limits underneath in displays
% Margin tags \usepackage{marginfix}
\let\marginnotetemp\marginnote
\let\marginnote\relax
\usepackage{marginnote}
\let\marginnotepkg\marginnote
\NewDocumentCommand{\margintag}{O{0\baselineskip}m}{
\checkoddpage
\ifoddpage
{\marginnotepkg{\footnotesize #2}[#1]}
\else
{\reversemarginpar\marginnotepkg{\footnotesize #2}[#1]}
\fi}
% \NewDocumentCommand{\margintagt}{O{0\baselineskip}m}{\marginpar{\vspace{#1}\footnotesize #2}}
% \NewDocumentCommand{\safefootnote}{om}{\footnotemark\margintag[#1]{\textsuperscript{\tiny\arabic{footnote}}
% \normalfont\justifying #2}}
\renewcommand\marginnote\marginnotetemp