forked from MathxStudio/LaTeX-Templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
allan.sty
417 lines (361 loc) · 12.9 KB
/
allan.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
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% allan.sty
% Allan Pan all rights reserved.
% Remember to put this file in a folder along with other .sty files
% e.g. C:\Users\Allan\AppData\Local\Programs\MiKTeX\tex\latex\allan
% For the \newcommand part, e.g. \newcommand{\CC}{\mathbb{C}}, all you need to know is that
% the 'newcommand' is in the first bracket and the effects are in the last bracket. So if you
% want to type \mathbb{C}, you can simply type \CC. For commands defined with a '[]' in the
% middle, it means that you can use certain parameters. e.g. \newcommand{\lleq}[1]{\xlongequal{\mathrm{#1}}}.
% If you want to type '\xlongequal{\mathrm{Lemma}}', you can simply type '\lleq{Lemma}'.
% Problem with the 'lstlisting' environment: please make sure that there are EXACTLY 16 (or usually 4
% TAB sizes) before the leftmost character.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{allan}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Part One - packages needed
% for colored frames
\usepackage[framemethod=TikZ]{mdframed}
\usetikzlibrary{shadows}
\usepackage{transparent}
\usepackage{xcolor}
\usepackage{mwe}
\usepackage{graphicx}
% for math display
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{extarrows}
% for python code
\usepackage{accsupp}
\newcommand{\emptyaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}
\usepackage{listings}
% for pseudocode
\usepackage{clrscode3e}
% for font
\usepackage[T1]{fontenc}
% for title
\usepackage{titlesec}
% \titleformat{\section}{\color{black}\normalfont\huge\bfseries}{\color{allandarkblue} Section \textbf{\thesection}}{0.5cm}{}
% \titleformat{\subsection}{\color{black}\normalfont\large\bfseries}{\color{allandarkblue} \textbf{§ \thesubsection}}{0.5cm}{}
\titleformat{\section}{\color{black}\normalfont\fontfamily{qpl}\selectfont\huge\bfseries}{\color{allandarkblue} Section \textbf{\thesection}}{0.5cm}{}
\titleformat{\subsection}{\color{black}\normalfont\fontfamily{qpl}\selectfont\large\bfseries}{\color{allandarkblue} \textbf{§ \thesubsection}}{0.3cm}{}
\titleformat{ \subsubsection }{ \color{black}\normalfont\fontfamily{qpl}\selectfont\scriptsize\bfseries } {\color{allandarkblue} \textbf{\thesubsubsection}}{0.3cm}{}
% for hyperlink
\usepackage[colorlinks, linkcolor = allancyan, anchorcolor = allanblue, citecolor = allanblue]{hyperref}
% for headers
\usepackage{geometry}
\geometry{a4paper,left=2cm,right=2cm,top=3cm,bottom=3cm}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.0pt}
\pagestyle{fancy}
\lhead{Allan Pan}
\chead{}
\rhead{\nouppercase{\leftmark}}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\setlength\headwidth{\textwidth}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Part Two - Colors
% for colored frames
\definecolor{allanblue}{rgb}{0.227451,0.372549,0.803922}
\definecolor{allanred}{rgb}{0.933333,0.172549,0.172549}
\definecolor{allangreen}{rgb}{0.133333,0.545098,0.133333}
\definecolor{allanorange}{rgb}{1,0.498039,0}
\definecolor{allanpurple}{rgb}{0.607843,0.188235,1}
\definecolor{allancyan}{rgb}{0,0.898039,0.933333}
\definecolor{allanyellow}{rgb}{1,0.843137,0}
\definecolor{allandarkblue}{rgb}{0.0980392,0.0980392,0.439216}
% for python code
\definecolor{commentcolor}{RGB}{85,139,78}
\definecolor{stringcolor}{RGB}{206,145,108}
\definecolor{keywordcolor}{RGB}{34,34,250}
\definecolor{backcolor}{RGB}{220,220,220}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Part Three - Frequent mathematical symbols
% require packages amsmath and amssymb
\newcommand{\BB}{\mathbb{B}} % open ball in topology
\newcommand{\BBC}{\overline{\mathbb{B}}} % closed ball in topology
\newcommand{\CC}{\mathbb{C}} % complex field
\newcommand{\FF}{\mathbb{F}} % complete system of residues
\newcommand{\NN}{\mathbb{N}} % natural number field (1, 2, ...)
\newcommand{\QQ}{\mathbb{Q}} % rational number field
\newcommand{\RR}{\mathbb{R}} % real number field
\newcommand{\ZZ}{\mathbb{Z}} % integer field
\newcommand{\PP}{\mathbb{P}} % prime field
\newcommand{\KK}{\mathbb{K}} % real or complex field (common notation used in vector spaces)
\newcommand{\testmathsymbols}{\[\frac{\left( \frac{1}{\sqrt{2\pi \sigma _{0}^{2}}} \right) ^n\exp \left\{ \frac{\left( -\sum\limits_{i=1}^n{\left( x_i-\mu _0 \right) ^2} \right)}{2\sigma _{0}^{2}} \right\}}{\left\{ \frac{1}{\left( \frac{2\pi}{n} \right) \sum\limits_{i=1}^n{\left( x_i-\mu _0 \right) ^2}} \right\} ^{\frac{n}{2}}e^{-\frac{n}{2}}}\]}
\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}
\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
\newcommand{\dang}{\measuredangle} % directed angle
\newcommand{\ray}[1]{\overrightarrow{#1}}
\newcommand{\seg}[1]{\overline{#1}}
\newcommand{\arc}[1]{\wideparen{#1}}
\newcommand{\ddef}{\xlongequal{\mathrm{def}}}
\newcommand{\du}{^\circ}
\newcommand{\modd}{\mathrm{mod}\:}
\newenvironment{techlnk}[1]{\color{allandarkblue}\fontfamily{qcr}\selectfont{#1}\normalfont\color{black}}
\newcommand{\defword}[1]{\textbf{\color{allandarkblue} #1}\color{black}}
\newcommand{\itembf}[1]{\item\textbf{#1}}
\newcommand{\itemit}[1]{\item\textit{#1}}
\newcommand{\itembfit}[1]{\item\textbf{\textit{#1}}}
\newcommand{\itemdef}[1]{\item \defword{#1}\quad}
\newcommand{\iteminfo}[1]{\item \textbf{(#1)}}
\newcommand{\testline}{\underline{\hbox to 40mm{}}}
\newcommand{\degree}{^\circ}
\newcommand{\YS}{\text{原式}}
\newcommand{\sgn}{\mathrm{sgn}}
% More script letters etc.
\newcommand{\SA}{\mathcal A}
\newcommand{\SB}{\mathcal B}
\newcommand{\SC}{\mathcal C}
\newcommand{\SF}{\mathcal F}
\newcommand{\SG}{\mathcal G}
\newcommand{\SH}{\mathcal H}
\newcommand{\SO}{\mathcal O}
\newcommand{\SP}{\mathcal P}
\newcommand{\SCA}{\mathscr A}
\newcommand{\SCB}{\mathscr B}
\newcommand{\SCC}{\mathscr C}
\newcommand{\SCD}{\mathscr D}
\newcommand{\SCE}{\mathscr E}
\newcommand{\SCF}{\mathscr F}
\newcommand{\SCG}{\mathscr G}
\newcommand{\SCH}{\mathscr H}
% Mathfrak primes
\newcommand{\km}{\mathfrak m}
\newcommand{\kp}{\mathfrak p}
\newcommand{\kq}{\mathfrak q}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Part Four - basic environments and display styles
% for cycle permutations
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\cycle}{ O{\;} m }
{
(
\alec_cycle:nn { #1 } { #2 }
)
}
\seq_new:N \l_alec_cycle_seq
\cs_new_protected:Npn \alec_cycle:nn #1 #2
{
\seq_set_split:Nnn \l_alec_cycle_seq { , } { #2 }
\seq_use:Nn \l_alec_cycle_seq { #1 }
}
\ExplSyntaxOff
% for numbered equations
\newcommand{\sub}[1]{\mdfsubtitle{#1}}
\newcounter{alemma}[section]
\newcounter{asublemma}[section]
\newcommand{\showlemma}{\thesection.\arabic{alemma}}
\newcommand{\showsublemma}{\thesection.\arabic{asublemma}}
\newcommand{\updatelemma}{\refstepcounter{alemma}}
\newcommand{\updatesublemma}{\refstepcounter{asublemma}}
\newcommand{\sublemma}{\sub{\color{allanred} Proof of Lemma \updatesublemma\showsublemma}}
\newcounter{aclaim}[section]
\newcounter{asubclaim}[section]
\newcommand{\showclaim}{\thesection.\arabic{aclaim}}
\newcommand{\showsubclaim}{\thesection.\arabic{asubclaim}}
\newcommand{\updateclaim}{\refstepcounter{aclaim}}
\newcommand{\updatesubclaim}{\refstepcounter{asubclaim}}
\newcommand{\subclaim}{\sub{\color{allanorange} Proof of Claim \updatesubclaim\showsubclaim}}
\newcounter{afact}[section]
\newcounter{asubfact}[section]
\newcommand{\showfact}{\thesection.\arabic{afact}}
\newcommand{\showsubfact}{\thesection.\arabic{asubfact}}
\newcommand{\updatefact}{\refstepcounter{afact}}
\newcommand{\updatesubfact}{\refstepcounter{asubfact}}
\newcommand{\subfact}{\sub{\color{allangreen} Proof of Fact \updatesubfact\showsubfact}}
% for pseudocode
\lstset{
language=python, % Python highlight
mathescape = true,
linewidth=\linewidth, % width of list
basicstyle=\tt,
commentstyle=\color{commentcolor},
keywordstyle=\color{keywordcolor},
stringstyle=\color{stringcolor},
showstringspaces = false,
showspaces=false,
numbers=left, % line numbers on the left
numberstyle=\tiny\emptyaccsupp,
numbersep=5pt,
framerule=0pt,
emptylines=1, % empty lines more than one will be considered as one empty line
xleftmargin=0.5cm,
tabsize=4,
gobble=15 % omit first 4 characters of each line
%
}
\newmdenv[%
% documentation: https://mirror.foobar.to/CTAN/macros/latex/contrib/mdframed/mdframed.pdf
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 1pt,
roundcorner = 5pt,
linecolor = black,
backgroundcolor = allanred!5,%
%
% frametitle settings
frametitle = {\color{allanred} Lemma \updatelemma\showlemma},
frametitlerule = true,
frametitlebackgroundcolor = allanred!15,%
%
% subtitle settings
subtitleabovelinecolor = allanred,
subtitlebelowlinecolor = allanred,
subtitlebelowline=true,
subtitleaboveline=true,
subtitlebackgroundcolor = allanred!15,
subtitleinneraboveskip = 0.4\baselineskip,
subtitleinnerbelowskip = 0.4\baselineskip,
% \begin{allanlemma}
% text below title
% \mdfsubtitle{\color{allanred} Proof of Lemma}
% text below subtitle
% $$
% \frac{\left( \frac{1}{\sqrt{2\pi \sigma _{0}^{2}}} \right) ^n\exp \left\{ \frac{\left( -\sum_{i=1}^n{\left( x_i-\mu _0 \right) ^2} \right)}{2\sigma _{0}^{2}} \right\}}{\left\{ \frac{1}{\left( \frac{2\pi}{n} \right) \sum_{i=1}^n{\left( x_i-\mu _0 \right) ^2}} \right\} ^{\frac{n}{2}}e^{-\frac{n}{2}}}
% $$
% \end{allanlemma}
]{allanlemma}
\newmdenv[%
% documentation: https://mirror.foobar.to/CTAN/macros/latex/contrib/mdframed/mdframed.pdf
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 1pt,
roundcorner = 5pt,
linecolor = black,
backgroundcolor = allangreen!5,%
%
% frametitle settings
frametitle = {\color{allangreen} Fact \updatefact\showfact},
frametitlerule = true,
frametitlebackgroundcolor = allangreen!15,%
%
% subtitle settings
subtitleabovelinecolor = allangreen,
subtitlebelowlinecolor = allangreen,
subtitlebelowline=true,
subtitleaboveline=true,
subtitlebackgroundcolor = allangreen!15,
subtitleinneraboveskip = 0.4\baselineskip,
subtitleinnerbelowskip = 0.4\baselineskip,
]{allanfact}
\newmdenv[%
% documentation: https://mirror.foobar.to/CTAN/macros/latex/contrib/mdframed/mdframed.pdf
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 1pt,
roundcorner = 5pt,
linecolor = black,
backgroundcolor = allanorange!5,%
%
% frametitle settings
frametitle = {\color{allanorange} Claim \updateclaim\showclaim},
frametitlerule = true,
frametitlebackgroundcolor = allanorange!15,%
%
% subtitle settings
subtitleabovelinecolor = allanorange,
subtitlebelowlinecolor = allanorange,
subtitlebelowline=true,
subtitleaboveline=true,
subtitlebackgroundcolor = allanorange!15,
subtitleinneraboveskip = 0.4\baselineskip,
subtitleinnerbelowskip = 0.4\baselineskip,
]{allanclaim}
\newmdtheoremenv[%
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 1.5pt,
roundcorner = 5pt,
linecolor = allanblue,
backgroundcolor = allanblue!10,
]{allantheorem}{Theorem}[section]
\mdfdefinestyle{allanremark}{%
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 2.5pt,
roundcorner = 0pt,
linecolor = black,
backgroundcolor = black!10,
topline = false,
bottomline = false,
leftline = true,
rightline = false,
innertopmargin = 0.3cm,
}
\newenvironment{allanenvremark}{%
\begin{mdframed}[style = allanremark]%
\textbf{Remark.}
}{%
\end{mdframed}
}
\mdfdefinestyle{allanhypothesis}{%
skipabove = 0.5cm,
skipbelow = 0cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 2.5pt,
roundcorner = 0pt,
linecolor = allanpurple,
backgroundcolor = allanpurple!10,
topline = false,
bottomline = false,
leftline = true,
rightline = false,
innertopmargin = 0.3cm,
}
\newenvironment{allanenvhypothesis}{%
\begin{mdframed}[style = allanhypothesis]%
\textbf{\color{allanpurple} Hypothesis --}
}{%
\end{mdframed}
\textit{Justification --}
}
\newmdenv[%
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 1.5pt,
roundcorner = 5pt,
linecolor = allandarkblue,
backgroundcolor = allandarkblue!5,%
%
% frametitle settings
frametitle = {\color{allandarkblue} Algorithm},
frametitlerule = true,
frametitlebackgroundcolor = allandarkblue!15,%
]{allanpy}
\newmdenv[%
skipabove = 0.5cm,
skipbelow = 0.5cm,
leftmargin = 0cm,
rightmargin = 0cm,
linewidth = 0.7pt,
roundcorner = 5pt,
linecolor = allandarkblue,%
%
% frametitle settings
frametitle = {\color{allandarkblue} Explanation},
frametitlerule = true,
frametitlebackgroundcolor = allandarkblue!15,%
]{allaninpseudo}