-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmathcommon.sty
More file actions
439 lines (354 loc) · 13.7 KB
/
Copy pathmathcommon.sty
File metadata and controls
439 lines (354 loc) · 13.7 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
%%%
%
% mathcommon.sty
%
% My personal list of commonly used LaTeX math packages and macros.
%
% To use the macros defined in this file, add the following line to
% the preamble of a LaTeX document:
%
% \uspackage{mathcommon}
%
% Authors: Sandro Stucki <sandro.stucki@gmail.com>
% Ricardo Honorato-Zimmer <rikardo.horo@gmail.com>
%
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathcommon}%
[2013/05/11 LaTeX package defining common math macros]
%%% Packages %%%
% AMS Math typesetting
\RequirePackage{amsmath} % AMS math basics
\RequirePackage{amsfonts} % Math fonts
\RequirePackage{amssymb} % Math symbols
\RequirePackage{mathtools} % Extensible arrows etc.
% Some styles may come with their own definitions proof/theorem
% environments that are not compatible with the amsthm package.
\@ifundefined{proof}{ %
\RequirePackage{amsthm} % Package for theorem environments
}
% Double stroke font (e.g. \mathds{1} for the indicator function)
\RequirePackage{dsfont}
% More math symbols (e.g. double-brackets: \llbracket, \rrbracket,
% triangle arrows: \leftarrowtriangle, \rightarrowtriangle, etc.)
\RequirePackage{stmaryrd}
% Using TikZ for diagrams
\RequirePackage{tikz}
\usetikzlibrary{arrows,fit,matrix,positioning,calc}
%%% Theorem environments %%%
% Only attempt to define new theorem environments if the amsthm
% package was loaded. The use of the \@ifundefined macro below guards
% the theorem environment definitions to avoid overriding previous
% definitions (that are compatible with amsthm), e.g. when using
% special styles or packages such as beamer.
\ifcsname newtheoremstyle\endcsname%
%
% Theorem environments with slanted text.
% \newtheoremstyle{thmslanttext}%
% {\topsep}% space above the theorem (default)
% {\topsep}% space below the theorem (default)
% {\slshape}% body font (slanted)
% {}% indentation (none)
% {\bfseries\sffamily}% head font (bold, sans serif)
% {}% punctuation between head and body (none)
% {1em}% space after theorem head (1em)
% {}% head specification (default format)
% \theoremstyle{thmslanttext}%
\theoremstyle{plain}% (use default AMS "plain" style)
\newcounter{null}
\@ifundefined{theorem}{\newtheorem{theorem}{Theorem}[null]}{}
\@ifundefined{proposition}{\newtheorem{proposition}{Proposition}[null]}{}
\@ifundefined{definition}{\newtheorem{definition}{Definition}[null]}{}
\@ifundefined{remark}{\newtheorem{remark}{Remark}[null]}{}
% Uncomment to have section numbers in theorems.
% \@ifundefined{theorem}{\newtheorem{theorem}{Theorem}[section]}{}
% \@ifundefined{proposition}{\newtheorem{proposition}{Proposition}[section]}{}
% \@ifundefined{definition}{\newtheorem{definition}{Definition}[section]}{}
% \@ifundefined{remark}{\newtheorem{remark}{Remark}[section]}{}
%
% Theorem environments that share a counter with 'theorem'
\@ifundefined{corollary}{\newtheorem{corollary}[theorem]{Corollary}}{}
\@ifundefined{lemma}{\newtheorem{lemma}[theorem]{Lemma}}{}
\@ifundefined{conjecture}{\newtheorem{conjecture}[theorem]{Conjecture}}{}
% Theorem environment that doesn't use a counter
\@ifundefined{note}{\newtheorem*{note}{Note}}{}
% Simple hack to have simple numbering of theorems
% Comment this if using section numbers in theorems
\renewcommand{\thetheorem}{\arabic{theorem}}
\renewcommand{\theproposition}{\arabic{proposition}}
\renewcommand{\thedefinition}{\arabic{definition}}
\renewcommand{\theremark}{\arabic{remark}}
%
% Theorem environments with regular text.
% \newtheoremstyle{thmnormaltext}%
% {\topsep}% space above the theorem (default)
% {\topsep}% space below the theorem (default)
% {}% body font (regular)
% {}% indentation (none)
% {\bfseries\sffamily}% head font (bold, sans serif)
% {}% punctuation between head and body (none)
% {1em}% space after theorem head (1em)
% {}% head specification (default format)
% \theoremstyle{thmnormaltext}%
\theoremstyle{definition}% (use predefined AMS "definition" style)
\@ifundefined{fact}{\newtheorem{fact}{Fact}[section]}{}
\@ifundefined{hypothesis}{\newtheorem{hypothesis}[theorem]{Hypothesis}}{}
\@ifundefined{example}{\newtheorem{example}{Example}[section]}{}
\@ifundefined{exercise}{\newtheorem{exercise}{Exercise}[section]}{}
\@ifundefined{problem}{\newtheorem{problem}{Problem}[section]}{}
\@ifundefined{notation}{\newtheorem*{notation}{Notation}}{}
%
\fi% End of \ifcsnamenewtheorem\endcsname
%%% Probability theory %%%
% Simple bold versions
\DeclareMathOperator*{\pr}{\mathbf{P}} % Probability
\renewcommand*{\exp}{\operatorname*{\mathbf{E}}} % Expectation
\DeclareMathOperator*{\var}{\mathbf{V}} % Variance
\DeclareMathOperator*{\ind}{\mathbf{1}} % Indicator function
% "Blackboard bold"/double stroke versions
\DeclareMathOperator*{\PP}{\mathbb{P}} % Probability
\DeclareMathOperator*{\EE}{\mathbb{E}} % Expectation
\DeclareMathOperator*{\VV}{\mathbb{V}} % Variance
\DeclareMathOperator*{\IInd}{\mathds{1}} % Indicator function
% "Verbose" bold versions
\renewcommand*{\Pr}{\operatorname*{\mathbf{Pr}}} % Probability
\DeclareMathOperator*{\Var}{\mathbf{Var}} % Variance
\DeclareMathOperator*{\Cov}{\mathbf{Cov}} % Covariance
% Average
\newcommand{\avg}[1]{\langle #1 \rangle}
%%% Sets %%%
% Common sets
\renewcommand{\emptyset}{\varnothing} % Empty set
\newcommand{\NN}{\mathbb{N}} % Natural numbers
\newcommand{\ZZ}{\mathbb{Z}} % Integers
\newcommand{\QQ}{\mathbb{Q}} % Rational numbers
\newcommand{\RR}{\mathbb{R}} % Real numbers
% Absolute value/cardinality
\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}
% Orientations in 3D euclidean space
\DeclareMathOperator{\SO}{SO(3)}
% Computability theory sets
\newcommand{\KK}{\mathbb{K}} % Undecidable problems
\newcommand{\zero}{\varnothing} % lowest Turing degree (0)
% Complexity classes
\newcommand{\Poly}{\mathbf{P}} % P
\newcommand{\NP}{\mathbf{NP}} % NP
\newcommand{\PSPACE}{\mathbf{PSPACE}} % PSPACE
\newcommand{\AP}{\mathbf{AP}} % AP
\newcommand{\PPoly}{\mathbf{P/Poly}} % P/Poly
% Standalone "such that" colon
\newcommand{\st}{\; | \;}%{:}
% Simple set notation.
\newcommand{\set}[1]{\left\{ #1 \right\}}
% Command for generating "set of <x> s.t. <p(x)>" definitions. The
% parameters are
%
% #1: the variable name(s) (to appear before the "s.t." colon), and
%
% #2: the predicate deciding set membership for particular instances
% of the variables (to appear after the colon).
%
% The output is of the form "{ #1 : #2 }" with the curly braces
% adjusted to the expression.
\newcommand{\setof}[2]{\set{#1 \st #2}}
% Indexed set
\newcommand{\iset}[1]{\set{#1}_{i \in I}}
% Tuples and sequences
\newcommand{\tuple}[1]{\langle #1 \rangle}
\newcommand{\seq}[1]{#1}
% Set operators
\newcommand{\duni}{+} % Disjoint union.
\newcommand{\dsum}{\sum} % Disjoint union ("sum").
\DeclareMathOperator{\inl}{inl} % Left injection of disjoint union.
\DeclareMathOperator{\inr}{inr} % Right injection of disjoint union.
% \renewcommand{\setminus}{-} % Relative complement/difference.
\DeclareMathOperator*{\union}{\cup} % Union
\DeclareMathOperator*{\bigunion}{\bigcup} % Union
\DeclareMathOperator*{\intersection}{\cap} % Intersection
% Powerset
\newcommand{\pset}[1]{\mathcal{P}\left(#1\right)}
% Cardinality of a set
\DeclareMathOperator*{\card}{Card}
%%% Functions %%%
% Symbols for domain, co-domain and image of functions
\DeclareMathOperator*{\dom}{dom} % Domain of a (partial) function
\DeclareMathOperator*{\cod}{cod} % Co-domain of a function
\DeclareMathOperator*{\img}{img} % Image/range of a function
% Function composition
\DeclareMathOperator*{\comp}{\circ}
% Restriction of a function #1 to domain #2
\newcommand{\rest}[2]{{#1}|_{#2}}
% Restriction of a function #1 to domain #2 (for big #1's)
\newcommand{\bigrest}[2]{\left.#1\right|_{#2}}
% Symbols for argmax/argmin
\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\argmin}{argmin}
% Derivatives
\newcommand{\ddt}{\frac{d}{dt}}
%%% Vectors %%%
% Typeset vectors using a bold, regular math font
\renewcommand{\vec}[1]{\boldsymbol{\mathbf{#1}}}
% Vector norm
\newcommand{\vnorm}[1]{\lvert #1 \rvert}
% Inner product
\newcommand{\innerprod}[2]{\langle #1, #2 \rangle}
%%% Logic %%%
% Boolean constants
\newcommand{\false}{\mathbf{false}}
\newcommand{\true}{\mathbf{true}}
% Implication
\DeclareMathOperator*{\then}{\Rightarrow}
%%% Categories %%%
% Typeset categories using a bold, regular math font
\newcommand{\cat}[1]{\ensuremath{\boldsymbol{\mathbf{#1}}}}
% Classes in categories
\DeclareMathOperator{\ob}{ob} % Objects of a category.
\def\hom{\operatorname{hom}} % Morphisms of a category.
\newcommand{\Span}{\mathbf{Span}}
\newcommand{\Cospan}{\mathbf{Cospan}}
\newcommand{\Cocone}{\mathbf{Co\text{-}cone}}
\newcommand{\Prod}{\mathbf{Prod}}
%% Objects
\newcommand{\init}{\mathbf{0}} % Initial object
\newcommand{\term}{\mathbf{1}} % Terminal object
%% Arrows
% Simple arrows with one argument (the name of the morphism).
\newcommand{\toby}[1]{\stackrel{#1}{\longrightarrow}}
\newcommand{\getsby}[1]{\stackrel{#1}{\longleftarrow}}
% Automatically extended arrows for long names.
\newcommand{\xtoby}[1]{\xrightarrow{#1}}
\newcommand{\xgetsby}[1]{\xleftarrow{#1}}
% Inclusion arrows
\newcommand{\incds}{\hookleftarrow}
\newcommand{\incin}{\hookrightarrow}
% Inclusion arrows with one argument (the name of the morphism).
\newcommand{\incdsby}[1]{\xhookleftarrow{#1}}
\newcommand{\incinby}[1]{\xhookrightarrow{#1}}
% Epimorphism
\newcommand{\toepi}{\twoheadrightarrow}
%%% TikZ %%%
%% Arrows
% Custom, bigger "to" arrowheads for commutative diagrams.
\pgfarrowsdeclare{bigto}{bigto}
{
\arrowsize=-1.54pt%
\advance\arrowsize by -1.23\pgflinewidth%
\pgfarrowsleftextend{+\arrowsize}
\arrowsize=0.28pt%
\advance\arrowsize by .55\pgflinewidth%
\pgfarrowsrightextend{\arrowsize}
}
{
\arrowsize=0.56pt%
\advance\arrowsize by .5\pgflinewidth%
\pgfsetlinewidth{0.8\pgflinewidth}
\pgfsetdash{}{+0pt}
\pgfsetroundcap
\pgfsetroundjoin
\pgfpathmoveto{\pgfqpoint{-3\arrowsize}{4\arrowsize}}
\pgfpathcurveto
{\pgfqpoint{-2.75\arrowsize}{2.5\arrowsize}}
{\pgfqpoint{-1\arrowsize}{0.5\arrowsize}}
{\pgfqpoint{0.5\arrowsize}{0pt}}
\pgfpathcurveto
{\pgfqpoint{-1\arrowsize}{-0.5\arrowsize}}
{\pgfqpoint{-2.75\arrowsize}{-2.5\arrowsize}}
{\pgfqpoint{-3\arrowsize}{-4\arrowsize}}
\pgfusepathqstroke
}
% Custom, bigger "right to" arrowheads for partial functions.
\pgfarrowsdeclare{right bigto}{right bigto}
{
\arrowsize=-1.54pt%
\advance\arrowsize by -1.23\pgflinewidth%
\pgfarrowsleftextend{+\arrowsize}
\arrowsize=0.28pt%
\advance\arrowsize by .55\pgflinewidth%
\pgfarrowsrightextend{\arrowsize}
}
{
\arrowsize=0.56pt%
\advance\arrowsize by .5\pgflinewidth%
\pgfsetlinewidth{0.8\pgflinewidth}
\pgfsetdash{}{0pt}
\pgfsetroundjoin
\pgfsetroundcap
\pgfpathmoveto{\pgfqpoint{0.5\arrowsize}{0pt}}
\pgfpathcurveto
{\pgfqpoint{-1\arrowsize}{-0.5\arrowsize}}
{\pgfqpoint{-2.75\arrowsize}{-2.5\arrowsize}}
{\pgfqpoint{-3\arrowsize}{-4\arrowsize}}
\pgfusepathqstroke
}
% Custom, bigger "left to" arrowheads for partial functions.
\pgfarrowsdeclare{left bigto}{left bigto}
{
\arrowsize=-1.54pt%
\advance\arrowsize by -1.23\pgflinewidth%
\pgfarrowsleftextend{+\arrowsize}
\arrowsize=0.28pt%
\advance\arrowsize by .55\pgflinewidth%
\pgfarrowsrightextend{\arrowsize}
}
{
\arrowsize=0.56pt%
\advance\arrowsize by .5\pgflinewidth%
\pgfsetlinewidth{0.8\pgflinewidth}
\pgfsetdash{}{0pt}
\pgfsetroundjoin
\pgfsetroundcap
\pgfpathmoveto{\pgfqpoint{0.5\arrowsize}{0pt}}
\pgfpathcurveto
{\pgfqpoint{-1\arrowsize}{0.5\arrowsize}}
{\pgfqpoint{-2.75\arrowsize}{2.5\arrowsize}}
{\pgfqpoint{-3\arrowsize}{4\arrowsize}}
\pgfusepathqstroke
}
%% Styles
% Set the default arrow type to 'stealth' for all drawings in the
% document.
\tikzset{>=stealth}
%% TikZ styles for commutative diagrams
% Normal arrows/homomorphisms (sets defaults for other arrows)
\tikzstyle{hom}=[>=bigto, ->, line width=0.5pt]
\tikzstyle{partialhom}=[hom, >=right bigto]
% Monomorphisms and epimorphisms
\tikzstyle{mono}=[hom, >->]
\tikzstyle{epi}=[hom, ->>]
% Identity arrows/equivalences
\tikzstyle{eq}=[-, double, double equal sign distance]
% Implications/natural transformations
\tikzstyle{nat}=[-implies, double, double equal sign distance]
% TikZ style for the matrices underlying commutation diagrams.
\tikzstyle{cd-mat}=[matrix of math nodes, nodes={anchor=center}]
% Style for edge labels on top of the edge.
\tikzstyle{ontop}=[fill=white, inner sep=3pt]
%% Commutative diagrams
% Commands for drawing pushout/pullback corners next to a node.
% The only parameter specifies the name of the node next to which
% the corner should be drawn.
\newcommand{\cornersize}{.6em}
\newcommand{\cornerNW}[1]{
\draw[hom,-] #1 ++($(-2*\cornersize, \cornersize)$) --
++(0, \cornersize) -- ++($( .95*\cornersize,0)$);}
\newcommand{\cornerNE}[1]{
\draw[hom,-] #1 ++($( 2*\cornersize, \cornersize)$) --
++(0, \cornersize) -- ++($(-.95*\cornersize,0)$);}
\newcommand{\cornerSW}[1]{
\draw[hom,-] #1 ++($(-2*\cornersize,-\cornersize)$) --
++(0,-\cornersize) -- ++($( .95*\cornersize,0)$);}
\newcommand{\cornerSE}[1]{
\draw[hom,-] #1 ++($( 2*\cornersize,-\cornersize)$) --
++(0,-\cornersize) -- ++($(-.95*\cornersize,0)$);}
\newcommand{\fpbcNW}[1]{
\draw[hom,-] #1 ++($(-2*\cornersize, \cornersize)$) --
++($(0, .7*\cornersize)$) -- ++($( .8*\cornersize,0)$);}
\newcommand{\fpbcNE}[1]{
\draw[hom,-] #1 ++($( 2*\cornersize, \cornersize)$) --
++($(0, .7*\cornersize)$) -- ++($(-.8*\cornersize,0)$);}
\newcommand{\fpbcSW}[1]{
\draw[hom,-] #1 ++($(-2*\cornersize,-\cornersize)$) --
++($(0,-.7*\cornersize)$) -- ++($( .8*\cornersize,0)$);}
\newcommand{\fpbcSE}[1]{
\draw[hom,-] #1 ++($( 2*\cornersize,-\cornersize)$) --
++($(0,-.7*\cornersize)$) -- ++($(-.8*\cornersize,0)$);}