-
Notifications
You must be signed in to change notification settings - Fork 0
/
latex-macros.sty
237 lines (214 loc) · 7.51 KB
/
latex-macros.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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
\ProvidesPackage{latex-macros}
% Require packages
\RequirePackage{amsmath,amssymb,amsthm}
\RequirePackage{bm,bbm}
\RequirePackage{hyperref}
% mathbb letters
\newcommand{\Abb}{\mathbb{A}}
\newcommand{\Cbb}{\mathbb{C}}
\newcommand{\Dbb}{\mathbb{D}}
\newcommand{\Ebb}{\mathbb{E}}
\newcommand{\Fbb}{\mathbb{F}}
\newcommand{\Gbb}{\mathbb{G}}
\newcommand{\Hbb}{\mathbb{H}}
\newcommand{\Ibb}{\mathbb{I}}
\newcommand{\Jbb}{\mathbb{J}}
\newcommand{\Kbb}{\mathbb{K}}
\newcommand{\Lbb}{\mathbb{L}}
\newcommand{\Mbb}{\mathbb{M}}
\newcommand{\Nbb}{\mathbb{N}}
\newcommand{\Obb}{\mathbb{O}}
\newcommand{\Pbb}{\mathbb{P}}
\newcommand{\Qbb}{\mathbb{Q}}
\newcommand{\Rbb}{\mathbb{R}}
\newcommand{\Sbb}{\mathbb{S}}
\newcommand{\Tbb}{\mathbb{T}}
\newcommand{\Ubb}{\mathbb{U}}
\newcommand{\Vbb}{\mathbb{V}}
\newcommand{\Wbb}{\mathbb{W}}
\newcommand{\Xbb}{\mathbb{X}}
\newcommand{\Ybb}{\mathbb{Y}}
\newcommand{\Zbb}{\mathbb{Z}}
% mathcal letters
\newcommand{\cA}{\mathcal{A}}
\newcommand{\cB}{\mathcal{B}}
\newcommand{\cC}{\mathcal{C}}
\newcommand{\cD}{\mathcal{D}}
\newcommand{\cE}{\mathcal{E}}
\newcommand{\cF}{\mathcal{F}}
\newcommand{\cG}{\mathcal{G}}
\newcommand{\cH}{\mathcal{H}}
\newcommand{\cI}{\mathcal{I}}
\newcommand{\cJ}{\mathcal{J}}
\newcommand{\cK}{\mathcal{K}}
\newcommand{\cL}{\mathcal{L}}
\newcommand{\cM}{\mathcal{M}}
\newcommand{\cN}{\mathcal{N}}
\newcommand{\cO}{\mathcal{O}}
\newcommand{\cP}{\mathcal{P}}
\newcommand{\cQ}{\mathcal{Q}}
\newcommand{\cR}{\mathcal{R}}
\newcommand{\cS}{\mathcal{S}}
\newcommand{\cT}{\mathcal{T}}
\newcommand{\cU}{\mathcal{U}}
\newcommand{\cV}{\mathcal{V}}
\newcommand{\cW}{\mathcal{W}}
\newcommand{\cX}{\mathcal{X}}
\newcommand{\cY}{\mathcal{Y}}
\newcommand{\cZ}{\mathcal{Z}}
% Dynamically generates \{x}hat macros, where {x} is any letter in a-z,A-Z.
% E.g: write \xhat to generate \widehat{x}.
\def\mdefhat#1{\expandafter\def\csname #1hat\endcsname{\widehat{#1}}}
\def\mdefallhat#1{\ifx#1\mdefallhat\else\mdefhat#1\expandafter\mdefallhat\fi}
\mdefallhat abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\mdefallhat
% Dynamically generates \{x}bar macros, where {x} is any letter in a-z
% E.g: write \xbar to generate \bar{x}.
\def\mdefbar#1{\expandafter\def\csname #1bar\endcsname{\bar{#1}}}
\def\mdefallbar#1{\ifx#1\mdefallbar\else\mdefbar#1\expandafter\mdefallbar\fi}
\mdefallbar abcdefghijklmnopqrstuvwxyz\mdefallbar
% Dynamically generates \{x}tld macros, where {x} is any letter in a-z, A-Z
% E.g: write \xtld to generate \widetilde{x}.
\def\mdeftd#1{\expandafter\def\csname #1tld\endcsname{\widetilde{#1}}}
\def\mdefalltd#1{\ifx#1\mdefalltd\else\mdeftd#1\expandafter\mdefalltd\fi}
\mdefalltd abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\mdefalltd
%% var letters
% lower
\newcommand{\veps}{\varepsilon}
\newcommand{\vkap}{\varkappa}
\newcommand{\vphi}{\varphi}
\newcommand{\vpi}{\varpi}
\newcommand{\vrho}{\varrho}
\newcommand{\vthe}{\vartheta}
% upper
\newcommand{\vGam}{\varGamma}
\newcommand{\vDel}{\varDelta}
\newcommand{\vLam}{\varLambda}
\newcommand{\vPsi}{\varPsi}
\newcommand{\vPi}{\varPi}
\newcommand{\vPhi}{\varPhi}
\newcommand{\vSig}{\varSigma}
%% set ops
% delimited
\DeclareMathOperator*{\setI}{\bigcap}
\DeclareMathOperator*{\setU}{\bigcup}
% non-delimited
\newcommand{\setD}{\setminus}
\newcommand{\setDsym}{\bigtriangleup}
% argmin/argmax/arginf/argsup as operators
% with up/down limits
\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\arginf}{arginf}
\DeclareMathOperator*{\argsup}{argsup}
% various shorthand macros
\newcommand{\dist}{\mathrm{dist}}
\newcommand{\proj}{\mathrm{proj}}
\newcommand{\grad}{\nabla}
\newcommand{\conv}{\circledast}
\newcommand{\convhull}{\mathrm{conv}}
\newcommand{\iid}{\overset{\mathrm{i.i.d.}}{\sim}}
% note: span is a latex primitive
\newcommand{\vspan}{\mathrm{span}}
\newcommand{\rank}{\mathrm{rank}}
\newcommand{\tr}{\mathrm{Tr}}
\newcommand{\sign}{\mathrm{sign}}
\newcommand{\range}{\mathrm{range}}
\newcommand{\tdef}{\triangleq}
% middle bar, for use in delimited expressions like sets
\newcommand{\mmid}{\ \middle| \ }
% Positive semidefinite, positive definite cones
\newcommand{\psd}[1]{\Sbb^{#1}_+}
\newcommand{\pd}[1]{\Sbb^{#1}_{++}}
% up/down arrows for limits
\newcommand{\dto}{\downarrow}
\newcommand{\uto}{\uparrow}
\newcommand{\T}{\mathsf{T}}
% unit ball
\newcommand{\ball}{\mathbb{B}}
% multiset
\newcommand{\multo}{\rightrightarrows}
% KL divergence
\newcommand{\dkl}[2]{D_{\mathrm{KL}}\left({#1} \ |\ {#2}\right)}
% convergence symbols
\newcommand{\asto}{\overset{\mathrm{a.s.}}{\longrightarrow}}
\newcommand{\probto}{\overset{\Pbb}{\longrightarrow}}
\newcommand{\lpto}[1]{\overset{L^{#1}}{\longrightarrow}}
\newcommand{\weakto}{\overset{\mathrm{weak}}{\longrightarrow}}
\newcommand{\normto}{\overset{\mathrm{norm}}{\longrightarrow}}
% convex analysis
\newcommand{\diag}{\mathrm{diag}}
\newcommand{\gph}{\mathrm{gph}}
\newcommand{\epi}{\mathrm{epi}}
\newcommand{\dom}{\mathrm{dom}}
\newcommand{\intr}[1]{\mathrm{int}\left( #1 \right)}
\newcommand{\clos}[1]{\mathrm{cl}\left( #1 \right)}
\newcommand{\relint}[1]{{#1}^{\circ}}
% shorthands for parentheses / brackets
\newcommand{\pars}[1]{\left( #1 \right)}
\newcommand{\brks}[1]{\left[ #1 \right]}
% macros for delimited expressions
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\expfun}[1]{\exp\left\{ {#1} \right\}}
\newcommand{\ip}[1] {\left\langle #1 \right\rangle }
\newcommand{\norm}[1] {\left \| #1 \right \|}
\newcommand{\opnorm}[1] {\norm{ #1 }_{\mathrm{op}}}
\newcommand{\frobnorm}[1]{\norm{ #1 }_{\mathrm{F}}}
\newcommand{\infnorm}[1]{\norm{ #1 }_{\infty}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\trace}[1]{\tr \left( #1 \right)}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil}
% proximal operator
\newcommand{\prox}[2]{\mathrm{prox}_{#1}\left( #2 \right)}
% indicator function
\newcommand{\1}{\mathbbm{1}}
% Explicitly sized inner products
\newcommand{\bigip}[1]{\bigl\langle #1 \bigr\rangle}
\newcommand{\biggip}[1]{\biggl\langle #1 \biggr\rangle}
\newcommand{\Bigip}[1]{\Bigl\langle #1 \Bigr\rangle}
\newcommand{\Biggip}[1]{\Biggl\langle #1 \Biggr\rangle}
% Explicitly sized norms
\newcommand{\bignorm}[1]{\bigl\| #1 \bigr\|}
\newcommand{\biggnorm}[1]{\biggl\| #1 \biggr\|}
\newcommand{\Bignorm}[1]{\Bigl\| #1 \Bigr\|}
\newcommand{\Biggnorm}[1]{\Biggl\| #1 \Biggr\|}
% Explicitly sized operator norms
\newcommand{\bigopnorm}[1]{\bigl\| #1 \bigr\|_{\mathrm{op}}}
\newcommand{\biggopnorm}[1]{\biggl\| #1 \biggr\|_{\mathrm{op}}}
\newcommand{\Bigopnorm}[1]{\Bigl\| #1 \Bigr\|_{\mathrm{op}}}
\newcommand{\Biggopnorm}[1]{\Biggl\| #1 \Biggr\|_{\mathrm{op}}}
% Explicitly sized Frobenius norms
\newcommand{\bigfrobnorm}[1]{\bigl\| #1 \bigr\|_{\mathrm{F}}}
\newcommand{\biggfrobnorm}[1]{\biggl\| #1 \biggr\|_{\mathrm{F}}}
\newcommand{\Bigfrobnorm}[1]{\Bigl\| #1 \Bigr\|_{\mathrm{F}}}
\newcommand{\Biggfrobnorm}[1]{\Biggl\| #1 \Biggr\|_{\mathrm{F}}}
% differential in integrals
\newcommand{\dd}[1]{\mathrm{d}{#1}}
% expectation, probability and variance, with optional subscripts
\newcommand{\expec}[2][]{
\ifx\\#1\\
\Ebb \left[ #2 \right]
\else
\Ebb_{#1} \left[ #2 \right]
\fi
}
\newcommand{\prob}[2][]{
\ifx\\#1\\
\Pbb \left( #2 \right)
\else
\Pbb_{#1} \left( #2 \right)
\fi
}
\newcommand{\var}[2][]{
\ifx\\#1\\
\mathrm{Var}_{#1}\left( #2 \right)
\else
\mathrm{Var}\left( #2 \right)
\fi
}
% partial fractions
\newcommand{\pfrac}[2]{\frac{\partial #1}{\partial #2}}
% matrices
\newcommand{\pmx}[1]{\begin{pmatrix} #1 \end{pmatrix}}
\newcommand{\bmx}[1]{\begin{bmatrix} #1 \end{bmatrix}}
\newcommand{\Bmx}[1]{\begin{Bmatrix} #1 \end{Bmatrix}}