Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yiming-wange
GitHub Repository: yiming-wange/cs224n-2023-solution
Path: blob/main/a3/a3_latex/std_macros.tex
995 views
1
% version 1.2 05/21/08
2
\newcommand\sa{\ensuremath{\mathcal{a}}}
3
\newcommand\sd{\ensuremath{\mathcal{d}}}
4
\newcommand\se{\ensuremath{\mathcal{e}}}
5
\newcommand\sg{\ensuremath{\mathcal{g}}}
6
\newcommand\sh{\ensuremath{\mathcal{h}}}
7
\newcommand\si{\ensuremath{\mathcal{i}}}
8
\newcommand\sj{\ensuremath{\mathcal{j}}}
9
\newcommand\sk{\ensuremath{\mathcal{k}}}
10
\newcommand\sm{\ensuremath{\mathcal{m}}}
11
\newcommand\sn{\ensuremath{\mathcal{n}}}
12
\newcommand\so{\ensuremath{\mathcal{o}}}
13
\newcommand\sq{\ensuremath{\mathcal{q}}}
14
\newcommand\sr{\ensuremath{\mathcal{r}}}
15
\newcommand\st{\ensuremath{\mathcal{t}}}
16
\newcommand\su{\ensuremath{\mathcal{u}}}
17
\newcommand\sv{\ensuremath{\mathcal{v}}}
18
\newcommand\sw{\ensuremath{\mathcal{w}}}
19
\newcommand\sx{\ensuremath{\mathcal{x}}}
20
\newcommand\sy{\ensuremath{\mathcal{y}}}
21
\newcommand\sz{\ensuremath{\mathcal{z}}}
22
\newcommand\sA{\ensuremath{\mathcal{A}}}
23
\newcommand\sB{\ensuremath{\mathcal{B}}}
24
\newcommand\sC{\ensuremath{\mathcal{C}}}
25
\newcommand\sD{\ensuremath{\mathcal{D}}}
26
\newcommand\sE{\ensuremath{\mathcal{E}}}
27
\newcommand\sF{\ensuremath{\mathcal{F}}}
28
\newcommand\sG{\ensuremath{\mathcal{G}}}
29
\newcommand\sH{\ensuremath{\mathcal{H}}}
30
\newcommand\sI{\ensuremath{\mathcal{I}}}
31
\newcommand\sJ{\ensuremath{\mathcal{J}}}
32
\newcommand\sK{\ensuremath{\mathcal{K}}}
33
\newcommand\sL{\ensuremath{\mathcal{L}}}
34
\newcommand\sM{\ensuremath{\mathcal{M}}}
35
\newcommand\sN{\ensuremath{\mathcal{N}}}
36
\newcommand\sO{\ensuremath{\mathcal{O}}}
37
\newcommand\sP{\ensuremath{\mathcal{P}}}
38
\newcommand\sQ{\ensuremath{\mathcal{Q}}}
39
\newcommand\sR{\ensuremath{\mathcal{R}}}
40
\newcommand\sS{\ensuremath{\mathcal{S}}}
41
\newcommand\sT{\ensuremath{\mathcal{T}}}
42
\newcommand\sU{\ensuremath{\mathcal{U}}}
43
\newcommand\sV{\ensuremath{\mathcal{V}}}
44
\newcommand\sW{\ensuremath{\mathcal{W}}}
45
\newcommand\sX{\ensuremath{\mathcal{X}}}
46
\newcommand\sY{\ensuremath{\mathcal{Y}}}
47
\newcommand\sZ{\ensuremath{\mathcal{Z}}}
48
\newcommand\ba{\ensuremath{\mathbf{a}}}
49
\newcommand\bb{\ensuremath{\mathbf{b}}}
50
\newcommand\bc{\ensuremath{\mathbf{c}}}
51
\newcommand\bd{\ensuremath{\mathbf{d}}}
52
\newcommand\be{\ensuremath{\mathbf{e}}}
53
\newcommand\bef{\ensuremath{\mathbf{f}}}
54
\newcommand\bg{\ensuremath{\mathbf{g}}}
55
\newcommand\bh{\ensuremath{\mathbf{h}}}
56
\newcommand\bi{\ensuremath{\mathbf{i}}}
57
\newcommand\bj{\ensuremath{\mathbf{j}}}
58
\newcommand\bk{\ensuremath{\mathbf{k}}}
59
\newcommand\bl{\ensuremath{\mathbf{l}}}
60
\newcommand\bm{\ensuremath{\mathbf{m}}}
61
\newcommand\bn{\ensuremath{\mathbf{n}}}
62
\newcommand\bo{\ensuremath{\mathbf{o}}}
63
\newcommand\bp{\ensuremath{\mathbf{p}}}
64
\newcommand\bq{\ensuremath{\mathbf{q}}}
65
\newcommand\br{\ensuremath{\mathbf{r}}}
66
\newcommand\bs{\ensuremath{\mathbf{s}}}
67
\newcommand\bt{\ensuremath{\mathbf{t}}}
68
\newcommand\bu{\ensuremath{\mathbf{u}}}
69
\newcommand\bv{\ensuremath{\mathbf{v}}}
70
\newcommand\bw{\ensuremath{\mathbf{w}}}
71
\newcommand\bx{\ensuremath{\mathbf{x}}}
72
\newcommand\by{\ensuremath{\mathbf{y}}}
73
\newcommand\bz{\ensuremath{\mathbf{z}}}
74
\newcommand\bA{\ensuremath{\mathbf{A}}}
75
\newcommand\bB{\ensuremath{\mathbf{B}}}
76
\newcommand\bC{\ensuremath{\mathbf{C}}}
77
\newcommand\bD{\ensuremath{\mathbf{D}}}
78
\newcommand\bE{\ensuremath{\mathbf{E}}}
79
\newcommand\bF{\ensuremath{\mathbf{F}}}
80
\newcommand\bG{\ensuremath{\mathbf{G}}}
81
\newcommand\bH{\ensuremath{\mathbf{H}}}
82
\newcommand\bI{\ensuremath{\mathbf{I}}}
83
\newcommand\bJ{\ensuremath{\mathbf{J}}}
84
\newcommand\bK{\ensuremath{\mathbf{K}}}
85
\newcommand\bL{\ensuremath{\mathbf{L}}}
86
\newcommand\bM{\ensuremath{\mathbf{M}}}
87
\newcommand\bN{\ensuremath{\mathbf{N}}}
88
\newcommand\bO{\ensuremath{\mathbf{O}}}
89
\newcommand\bP{\ensuremath{\mathbf{P}}}
90
\newcommand\bQ{\ensuremath{\mathbf{Q}}}
91
\newcommand\bR{\ensuremath{\mathbf{R}}}
92
\newcommand\bS{\ensuremath{\mathbf{S}}}
93
\newcommand\bT{\ensuremath{\mathbf{T}}}
94
\newcommand\bU{\ensuremath{\mathbf{U}}}
95
\newcommand\bV{\ensuremath{\mathbf{V}}}
96
\newcommand\bW{\ensuremath{\mathbf{W}}}
97
\newcommand\bX{\ensuremath{\mathbf{X}}}
98
\newcommand\bY{\ensuremath{\mathbf{Y}}}
99
\newcommand\bZ{\ensuremath{\mathbf{Z}}}
100
\newcommand\Ba{\ensuremath{\mathbb{a}}}
101
\newcommand\Bb{\ensuremath{\mathbb{b}}}
102
\newcommand\Bc{\ensuremath{\mathbb{c}}}
103
\newcommand\Bd{\ensuremath{\mathbb{d}}}
104
\newcommand\Be{\ensuremath{\mathbb{e}}}
105
\newcommand\Bf{\ensuremath{\mathbb{f}}}
106
\newcommand\Bg{\ensuremath{\mathbb{g}}}
107
\newcommand\Bh{\ensuremath{\mathbb{h}}}
108
\newcommand\Bi{\ensuremath{\mathbb{i}}}
109
\newcommand\Bj{\ensuremath{\mathbb{j}}}
110
\newcommand\Bk{\ensuremath{\mathbb{k}}}
111
\newcommand\Bl{\ensuremath{\mathbb{l}}}
112
\newcommand\Bm{\ensuremath{\mathbb{m}}}
113
\newcommand\Bn{\ensuremath{\mathbb{n}}}
114
\newcommand\Bo{\ensuremath{\mathbb{o}}}
115
\newcommand\Bp{\ensuremath{\mathbb{p}}}
116
\newcommand\Bq{\ensuremath{\mathbb{q}}}
117
\newcommand\Br{\ensuremath{\mathbb{r}}}
118
\newcommand\Bs{\ensuremath{\mathbb{s}}}
119
\newcommand\Bt{\ensuremath{\mathbb{t}}}
120
\newcommand\Bu{\ensuremath{\mathbb{u}}}
121
\newcommand\Bv{\ensuremath{\mathbb{v}}}
122
\newcommand\Bw{\ensuremath{\mathbb{w}}}
123
\newcommand\Bx{\ensuremath{\mathbb{x}}}
124
\newcommand\By{\ensuremath{\mathbb{y}}}
125
\newcommand\Bz{\ensuremath{\mathbb{z}}}
126
\newcommand\BA{\ensuremath{\mathbb{A}}}
127
\newcommand\BB{\ensuremath{\mathbb{B}}}
128
\newcommand\BC{\ensuremath{\mathbb{C}}}
129
\newcommand\BD{\ensuremath{\mathbb{D}}}
130
\newcommand\BE{\ensuremath{\mathbb{E}}}
131
\newcommand\BF{\ensuremath{\mathbb{F}}}
132
\newcommand\BG{\ensuremath{\mathbb{G}}}
133
\newcommand\BH{\ensuremath{\mathbb{H}}}
134
\newcommand\BI{\ensuremath{\mathbb{I}}}
135
\newcommand\BJ{\ensuremath{\mathbb{J}}}
136
\newcommand\BK{\ensuremath{\mathbb{K}}}
137
\newcommand\BL{\ensuremath{\mathbb{L}}}
138
\newcommand\BM{\ensuremath{\mathbb{M}}}
139
\newcommand\BN{\ensuremath{\mathbb{N}}}
140
\newcommand\BO{\ensuremath{\mathbb{O}}}
141
\newcommand\BP{\ensuremath{\mathbb{P}}}
142
\newcommand\BQ{\ensuremath{\mathbb{Q}}}
143
\newcommand\BR{\ensuremath{\mathbb{R}}}
144
\newcommand\BS{\ensuremath{\mathbb{S}}}
145
\newcommand\BT{\ensuremath{\mathbb{T}}}
146
\newcommand\BU{\ensuremath{\mathbb{U}}}
147
\newcommand\BV{\ensuremath{\mathbb{V}}}
148
\newcommand\BW{\ensuremath{\mathbb{W}}}
149
\newcommand\BX{\ensuremath{\mathbb{X}}}
150
\newcommand\BY{\ensuremath{\mathbb{Y}}}
151
\newcommand\BZ{\ensuremath{\mathbb{Z}}}
152
\newcommand\balpha{\ensuremath{\mbox{\boldmath$\alpha$}}}
153
\newcommand\bbeta{\ensuremath{\mbox{\boldmath$\beta$}}}
154
\newcommand\btheta{\ensuremath{\mbox{\boldmath$\theta$}}}
155
\newcommand\bphi{\ensuremath{\mbox{\boldmath$\phi$}}}
156
\newcommand\bpi{\ensuremath{\mbox{\boldmath$\pi$}}}
157
\newcommand\bpsi{\ensuremath{\mbox{\boldmath$\psi$}}}
158
\newcommand\bmu{\ensuremath{\mbox{\boldmath$\mu$}}}
159
% Basic
160
\newcommand\T{\text}
161
\newcommand\sign{\text{sign}}
162
\newcommand\tr{\text{tr}}
163
\newcommand\fig[1]{\begin{center} \includegraphics{#1} \end{center}}
164
\newcommand\Fig[4]{\begin{figure}[tb] \begin{center} \includegraphics[scale=#2]{#1} \end{center} \caption{\label{fig:#3} #4} \end{figure}}
165
\newcommand\FigTop[4]{\begin{figure}[t] \begin{center} \includegraphics[scale=#2]{#1} \end{center} \caption{\label{fig:#3} #4} \end{figure}}
166
\newcommand\FigStar[4]{\begin{figure*}[tb] \begin{center} \includegraphics[scale=#2]{#1} \end{center} \caption{\label{fig:#3} #4} \end{figure*}}
167
\newcommand\aside[1]{\quad\text{[#1]}}
168
\newcommand\homework[3]{\title{#1} \author{#2} \date{#3} \maketitle}
169
% Math
170
\newcommand\argmin{\mathop{\text{argmin}}}
171
\newcommand\argmax{\mathop{\text{argmax}}}
172
\newcommand\p[1]{\ensuremath{\left( #1 \right)}} % Parenthesis ()
173
\newcommand\pb[1]{\ensuremath{\left[ #1 \right]}} % []
174
\newcommand\pc[1]{\ensuremath{\left\{ #1 \right\}}} % {}
175
\newcommand\eval[2]{\ensuremath{\left. #1 \right|_{#2}}} % Evaluation
176
\newcommand\inv[1]{\ensuremath{\frac{1}{#1}}}
177
%\newcommand\half{\ensuremath{\frac{1}{2}}}
178
\newcommand\R{\ensuremath{\mathbb{R}}} % Real numbers
179
\newcommand\inner[2]{\ensuremath{\left< #1, #2 \right>}} % Inner product
180
\newcommand\mat[2]{\ensuremath{\left(\begin{array}{#1}#2\end{array}\right)}} % Matrix
181
\newcommand\eqn[1]{\begin{eqnarray} #1 \end{eqnarray}} % Equation (array)
182
\newcommand\eqnl[2]{\begin{eqnarray} \label{eqn:#1} #2 \end{eqnarray}} % Equation (array) with label
183
\newcommand\eqdef{\ensuremath{\stackrel{\rm def}{=}}} % Equal by definition
184
%\newcommand{\1}{\mathbb{I}} % Indicator (don't use \mathbbm{1} because bbm is not TrueType though)
185
\newcommand{\1}{\ensuremath{\mathbbm{1}}}
186
\newcommand{\bone}{\mathbf{1}} % for vector one
187
\newcommand{\bzero}{\mathbf{0}} % for vector zero
188
\newcommand\refeqn[1]{(\ref{eqn:#1})}
189
\newcommand\refeqns[2]{(\ref{eqn:#1}) and (\ref{eqn:#2})}
190
\newcommand\refchp[1]{Chapter~\ref{chp:#1}}
191
\newcommand\refsec[1]{Section~\ref{sec:#1}}
192
\newcommand\refsecs[2]{Sections~\ref{sec:#1} and~\ref{sec:#2}}
193
\newcommand\reffig[1]{Figure~\ref{fig:#1}}
194
\newcommand\reffigs[2]{Figures~\ref{fig:#1} and~\ref{fig:#2}}
195
\newcommand\reffigss[3]{Figures~\ref{fig:#1},~\ref{fig:#2}, and~\ref{fig:#3}}
196
\newcommand\reffigsss[4]{Figures~\ref{fig:#1},~\ref{fig:#2},~\ref{fig:#3}, and~\ref{fig:#4}}
197
\newcommand\reftab[1]{Table~\ref{tab:#1}}
198
\newcommand\refapp[1]{Appendix~\ref{sec:#1}}
199
\newcommand\refthm[1]{Theorem~\ref{thm:#1}}
200
\newcommand\refthms[2]{Theorems~\ref{thm:#1} and~\ref{thm:#2}}
201
\newcommand\reflem[1]{Lemma~\ref{lem:#1}}
202
\newcommand\reflems[2]{Lemmas~\ref{lem:#1} and~\ref{lem:#2}}
203
\newcommand\refprop[1]{Proposition~\ref{prop:#1}}
204
\newcommand\refdef[1]{Definition~\ref{def:#1}}
205
\newcommand\refcor[1]{Corollary~\ref{cor:#1}}
206
\newcommand\refalg[1]{Algorithm~\ref{alg:#1}}
207
\newcommand\Chapter[2]{\chapter{#2}\label{chp:#1}}
208
\newcommand\Section[2]{\section{#2}\label{sec:#1}}
209
\newcommand\Subsection[2]{\subsection{#2}\label{sec:#1}}
210
\newcommand\Subsubsection[2]{\subsubsection{#2}\label{sec:#1}}
211
\newtheorem{definition}{Definition}
212
\newtheorem{assumption}{Assumption}
213
\newtheorem{proposition}{Proposition}
214
\newtheorem{theorem}{Theorem}
215
\newtheorem{lemma}{Lemma}
216
\newtheorem{corollary}{Corollary}
217
% Probability
218
\newcommand\cv{\ensuremath{\to}} % Convergence
219
\newcommand\cvL{\ensuremath{\xrightarrow{\mathcal{L}}}} % Convergence in law
220
\newcommand\cvd{\ensuremath{\xrightarrow{d}}} % Convergence in distribution
221
\newcommand\cvP{\ensuremath{\xrightarrow{P}}} % Convergence in probability
222
\newcommand\cvas{\ensuremath{\xrightarrow{a.s.}}} % Convergence almost surely
223
\newcommand\eqdistrib{\ensuremath{\stackrel{d}{=}}} % Equal in distribution
224
\newcommand\E{\ensuremath{\mathbb{E}}} % Expectation
225
\newcommand\Ex[2]{\ensuremath{\mathbb{E}_{#1}\left[#2\right]}} % Expectation
226
\newcommand\var{\ensuremath{\text{var}}} % Variance
227
\newcommand\cov{\ensuremath{\text{cov}}} % Covariance
228
\newcommand\diag{\ensuremath{\text{diag}}} % Diagnonal matrix
229
\newcommand\cE[2]{\ensuremath{\E \left( #1 \mid #2 \right)}} % Conditional expectation
230
\newcommand\KL[2]{\ensuremath{\T{KL}\left( #1 \,||\, #2 \right)}} % KL-divergence
231
\newcommand\D[2]{\ensuremath{\bD\left( #1 \,||\, #2 \right)}} % KL-divergence
232
233
% Utilities
234
\newcommand\lte{\leq}
235
\newcommand\gte{\geq}
236
\newcommand\lone[1]{\ensuremath{\|#1\|_1}}
237
\newcommand\ltwo[1]{\ensuremath{\|#1\|_2^2}}
238
\renewcommand{\vec}[1]{\mathbf{#1}}
239
240
% Debug
241
\usepackage{color}
242
\newcommand{\hl}[2]{\colorbox{#2}{#1}}
243
\newcommand{\hly}[1]{\hl{yellow}{#1}}
244
\def\todo#1{\hl{{\bf TODO:} #1}{yellow}}
245
\def\needcite{\hl{{$^{\tt\small[citation\ needed]}$}}{blue}}
246
\def\needfig{\hl{Figure X}{green}}
247
\def\note#1{\hl{{\bf NOTE:} #1}{yellow}}
248
\def\dome{\hl{{\bf TODO:} write me!}{yellow}}
249