-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy-math.sty
286 lines (246 loc) · 9.12 KB
/
my-math.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
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
%%
%% Custom math shortcut package
%% Content:
%% - A lot of useful shortcuts
%% - Some new large operators (like sum)
%% - Custom Theorems
%%
%% Options:
%% [english] - set custom theorem names to english (default is french)
%%
%% Requires: my-preamble.sty
%%
%% Author: Dorian Lesbre
%%
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{my-math} [2023/02/24 v1.1.0 a lot of math commands]
\RequirePackage{etoolbox}
\RequirePackage{my-preamble}
\newtoggle{english}
\DeclareOption{english}{\toggletrue{english}}
\ProcessOptions\relax
% ==========================
% Math abbrieviations
% ==========================
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\U}{\mathbb{U}}
\newcommand{\D}{\mathbb{D}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\F}{\mathbb{F}}
\renewcommand{\S}{\mathbb{S}}
\newcommand{\Prob}{\mathbb{P}}
\newcommand{\Esp}{\mathbb{E}}
\newcommand{\V}{\mathbb{V}}
\newcommand{\di}{\mathrm{d}}
\newcommand{\re}{\mathrm{Re}}
\newcommand{\im}{\mathrm{Im}}
\newcommand{\id}{\mathrm{id}}
\newcommand{\gl}{\mathrm{Gl}}
\newcommand{\rg}{\mathrm{rg}}
\newcommand{\tr}{\mathrm{Tr}}
\newcommand{\DL}{\mathrm{DL}}
\newcommand{\Hom}{\mathrm{Hom}}
\newcommand{\com}{\mathrm{Com}}
\renewcommand{\ker}{\mathrm{Ker}}
\newcommand{\vect}{\mathrm{Vect}}
\renewcommand{\th}{\mathrm{Th}}
\newcommand{\card}{\mathrm{Card}}
\newcommand{\ind}{1\!\!1} % indicatrice
\newcommand{\M}{\mathcal{M}}
\newcommand{\orth}{\mathcal{O}}
\newcommand{\sorth}{\mathcal{SO}}
\newcommand{\Div}{\mathcal{D}}
\newcommand{\Lin}{\mathscr{L}}
\newcommand{\Cont}[1][]{\mathscr{C}^{#1}}
\newcommand{\B}{\mathscr{B}}
\newcommand{\E}{\mathscr{E}}
\newcommand{\et}{\text{ et }}
\newcommand{\ou}{\text{ ou }}
\newcommand{\si}{\text{ si }}
\newcommand{\bq}{\bullet \quad}
\newcommand{\transp}{{}^\mathrm{t}\!} % matrix transposition
\newcommand{\set}[1]{\left\lbrace{} #1 \right\rbrace}
\newcommand{\setp}[2]{\left\lbrace{} #1 \,\middle|\, #2 \right\rbrace}
\newcommand{\abs}[1]{\left\lvert{} #1 \right\rvert}
\newcommand{\normv}[1]{\left\Vert{} #1 \right\Vert}
\newcommand{\norm}[1]{\left\Vert{} \overrightarrow{#1} \right\Vert}
\newcommand{\floor}[1]{\left\lfloor{} #1 \right\rfloor}
\newcommand{\ceil}[1]{\left\lceil{} #1 \right\rceil}
\newcommand{\scalar}[2]{\left\langle#1,\,#2\right\rangle}
\newcommand{\intset}[2]{\left\llbracket#1, \: #2 \right\rrbracket}
\newcommand{\limit}[2]{\lim\limits_{#1\: \to\: #2}}
\newcommand{\tendsto}[2]{\xrightarrow[\: #1\: \to\:#2 \:]{}}
\newcommand{\Mat}[2][\mathbb{K}]{\mathcal{M}_{#2}\left(#1\right)}
\newcommand{\matr}[5]{\left(#1\right)_{\substack{1 \leqslant #2 \leqslant #3 \\ 1 \leqslant #4 \leqslant #5}}}
\newcommand{\conj}[1]{\xrightarrow{\quad {\displaystyle \mathscr{#1}} \quad}}
\newcommand{\diff}[2]{\frac{\mathrm{d} #1}{\mathrm{d} #2}}
\newcommand{\pdiff}[2]{\frac{\partial#1}{\partial#2}}
\newcommand{\bigdiff}[2]{\cfrac{\mathrm{d} #1}{\mathrm{d} #2}}
\newcommand{\f}[4]{\begin{array}{ccl}
#1 \! & \! \rightarrow \! & \! #2 \\
#3 \! & \! \mapsto \! & \! #4\end{array}}
\newcommand{\nCr}[2]{\left(\begin{array}{c} #1 \\ #2 \end{array} \right)}
\newcommand{\liste}[3][,\,]{#2 #1 \ldots #1 #3}
\newcommand{\impl}{\Rightarrow}
\renewcommand{\iff}{\Leftrightarrow}
\newcommand{\alg}[1]{\left\langle #1 \right\rangle}
\renewcommand{\part}[1]{{\mathcal{P}}\left(#1\right)}
\newcommand{\finpart}[1]{{\mathcal{P}_{\!\!f\!}}\left(#1\right)}
\newcommand{\finpartn}[2]{{\mathcal{P}_{\!#1\!}}\left(#2\right)}
\newcommand{\all}[1]{\forall\spac{} #1,\spac}
\newcommand{\exi}[1]{\exists\spac{} #1,\spac}
\newcommand{\llb}{\llbracket}
\newcommand{\rrb}{\rrbracket}
\newcommand{\alte}{\;\;|\;\;}
\renewcommand{\tt}[1]{\texttt{#1}}
\renewcommand{\cal}[1]{\mathcal{#1}}
\newcommand{\bb}[1]{\mathbb{#1}}
\newcommand{\ddef}{\mathrel{\triangleq}}
\newcommand{\slt}{\subset}
\newcommand{\sle}{\subseteq}
\newcommand{\sgt}{\supset}
\newcommand{\sge}{\supseteq}
\newcommand{\qlt}{\sqsubset}
\newcommand{\qle}{\sqsubseteq}
\newcommand{\qgt}{\sqsupset}
\newcommand{\qge}{\sqsupseteq}
\newcommand{\ilt}{\prec}
\newcommand{\ile}{\preccurlyeq}
\newcommand{\igt}{\succ}
\newcommand{\ige}{\succcurlyeq}
% ==========================
% Operators
% ==========================
\DeclareMathOperator*{\bigast}{\text{\Huge{$\ast$}}}
\DeclareMathOperator*{\simop}{\text{\LARGE{$\sim$}}}
\DeclareMathOperator*{\smallo}{o}
\DeclareMathOperator*{\bigO}{\text{\Large{$O$}}}
\DeclareMathOperator*{\eqas}{=}
\DeclareMathOperator*{\argmax}{\text{argmax}}
\DeclareMathOperator*{\argmin}{\text{argmin}}
% ==========================
% Theorems
% ==========================
\newtheoremstyle{custom}
{} % espace au-dessus
{} % espace en-dessous
{\normalfont} % police
{} % indentation
{\bfseries}
{} %Ponctuation
{ } %après la tête
{\thmname{#1}\thmnumber{ #2} : \def\temp{#3}\ifx\temp\empty \else (\thmnote{#3})\fi\newline} %head-spec
\theoremstyle{custom}
\makeatletter
\renewenvironment{proof}[1][\proofname]
{\par\pushQED{\qed}\normalfont\topsep6\p@\@plus6\p@\relax\trivlist\item[\hskip\labelsep\emph{#1 :}]\mbox{}}
{\popQED\endtrivlist\@endpefalse}
\makeatother
\iftoggle{english}{
\newtheorem{mylemma}{Lemma}[section]
\newtheorem{proposition}[mylemma]{Proposition}
\newtheorem{theoreme}[mylemma]{Theorem}
\newtheorem{probleme}{Problem}[section]
\newtheorem{methode}{Method}[section]
\newtheorem{algo}{Algorithm}[section]
\newtheorem{defini}{Definition}[section]
\newtheorem{mynotation}[defini]{Notation}
\newtheorem{exampl}{Example}[section]
}{
\newtheorem{mylemma}{Lemme}[section]
\newtheorem{proposition}[mylemma]{Proposition}
\newtheorem{theoreme}[mylemma]{Théorème}
\newtheorem{probleme}{Problème}[section]
\newtheorem{methode}{Méthode}[section]
\newtheorem{algo}{Algorithme}[section]
\newtheorem{defini}{Définition}[section]
\newtheorem{mynotation}[mylemma]{Notation}
\newtheorem{exampl}{Exemple}[section]
}
% ==========================
% Macro definitions
% ==========================
\newcommand{\spac}{\nobreak\hskip 0.2em plus 0.1em} % a space
\makeatletter
\newcommand{\newsymb}[3][]{
\ifstrempty{#1}{%
% symbol without def link
\expandafter\newcommand\csname#2\endcsname{#3}%
}{%
% symbol with def link
\expandafter\newcommand\csname#2\endcsname{\newlink{def:#1}{#3}}%
}%
}%
% \newsymb[tgt] {\foo} {bar} -> new macro \foo that prints bar (optionally linking to def:tgt)
\newcommand{\newfunone}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[1]{\csname#2symb\endcsname \left(##1\right)}%
}%
% \newfunone{cmd}{link}{symbol} -> new function taking one argument
% defines two macros:
% - \cmdsymb -> the function name
% - \cmd {arg} -> function call
\newcommand{\newfuntwo}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[2]{\csname#2symb\endcsname \left(##1,\spac##2\right)}%
}%
% \newfuntwo{cmd}{link}{symbol} -> new function taking two arguments
% defines two macros:
% - \cmdsymb -> the function name
% - \cmd x y -> function call
\newcommand{\newfunthree}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[3]{\csname#2symb\endcsname \left(##1,\spac##2,\spac##3\right)}%
}%
% \newfuntwo{cmd}{link}{symbol} -> new function taking three arguments
% defines two macros:
% - \cmdsymb -> the function name
% - \cmd x y z -> function call
\newcommand{\newfunfour}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[4]{\csname#2symb\endcsname \left(##1,\spac##2,\spac##3,\spac##4\right)}%
}%
% \newfuntwo{cmd}{link}{symbol} -> new function taking four arguments
% defines two macros:
% - \cmdsymb -> the function name
% - \cmd x y z t -> function call
\newcommand{\newinfix}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[2]{##1 \mathbin{\csname#2symb\endcsname} ##2}%
}%
% \newinfix{cmd}{link}{symbol} -> new infix operator
% defines two macros:
% - \cmdsymb -> the function name
% - \cmd x y -> function call
\newcommand{\newinfixrel}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[2]{##1 \mathrel{\csname#2symb\endcsname} ##2}%
}%
% Same as new infix but with bigger space (for relations, not binary operators)
\newcommand{\newlamone}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[1]{\csname#2symb\endcsname\spac##1}%
}%
% \newlamone{cmd}{link}{symbol} -> same as newfunone but uses OCaml style syntax for function calls
\newcommand{\newlamtwo}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[2]{\csname#2symb\endcsname\spac##1\spac##2}%
}%
% \newlamtwo{cmd}{link}{symbol} -> same as newfuntwo but uses OCaml style syntax for function calls
\newcommand{\newlamthree}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[3]{\csname#2symb\endcsname\spac##1\spac##2\spac##3}%
}%
% \newlamthree{cmd}{link}{symbol} -> same as newfunthree but uses OCaml style syntax for function calls
\newcommand{\newlamfour}[3][]{%
\newsymb[#1]{#2symb}{#3}%
\expandafter\newcommand\csname#2\endcsname[4]{\csname#2symb\endcsname\spac##1\spac##2\spac##3\spac##4}%
}%
% \newlamfour{cmd}{link}{symbol} -> same as newfunfour but uses OCaml style syntax for function calls
\makeatother
\endinput
%% End of file my-math.sty