-
Notifications
You must be signed in to change notification settings - Fork 0
/
lecture-notes.sty
301 lines (234 loc) · 9.07 KB
/
lecture-notes.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
\ProvidesPackage{lecture-notes}
%% PACKAGES %%
\usepackage{geometry} % page layout
\usepackage{setspace} % spacing of text
\usepackage{enumitem} % lists
\usepackage{caption} % captions
\usepackage{calc} % provides the '\widthof' command
\usepackage[many]{tcolorbox} % boxes, 'many' loads additional libraries
\usepackage{ccicons} % icons for Creative Commons licenses
\usepackage{graphicx} % images
\graphicspath{{./images/}} % sets path for images
\usepackage{amsthm} % theorem setup of AMS document classes
\usepackage{amssymb} % math symbols, operators, etc.
\usepackage{amsfonts} % extended set of fonts for use in mathematics
\usepackage{mathtools} % tools for mathematical typesetting
\usepackage{physics} % includes the \norm and \abs commands
\usepackage{nicefrac} % for typesetting "nice" fractions
%% TIKZ %%
\usepackage{tikz}
\usetikzlibrary{
backgrounds,
calc,
fadings,
shapes.callouts,
shapes.arrows
} % additional TikZ libraries
%% FONT & LINE SPACING %%
\usepackage[sfdefault, light]{FiraSans}
\onehalfspacing % line spacing
%% PAGE SETUP %%
% Compute the height of the page numbers printed on each page
\newlength{\pagemarkheight}
\settoheight{\pagemarkheight}{\bfseries\sffamily 1}
\geometry{
twoside,
top=26mm,
inner=16mm,
outer=16mm,
bottom=16mm,
headsep=26mm-(8mm+\pagemarkheight)
}
%% HEADERS & FOOTERS %%
% Loading 'scrlayer-scrpage' automatically activates the pagestyle 'scrheadings' and swaps the page styles 'headings' for 'scrheadings' and 'plain' for 'plain.scrheadings'
\usepackage[
automark,
headsepline=0pt,
headwidth=\textwidth+8mm:0pt % extend header 8mm
]{scrlayer-scrpage}
\setkomafont{pageheadfoot}{\color{gray}}
\setkomafont{pagenumber}{\color{blue}\bfseries}
% NOTE: Using the starred commands changes both page styles at once
\ofoot*{}
\rohead*{\headmark\hspace{8mm-\widthof{\pagemark}}\pagemark}
\lehead*{\pagemark\hspace{8mm-\widthof{\pagemark}}\headmark}
%% LISTS %%
\setlist[1]{labelindent=\parindent}
\setlist[enumerate, 1]{label = (\arabic*)} % first level
\setlist[enumerate, 2]{label = (\alph*)} % second level
%% CAPTIONS %%
\addtokomafont{caption}{\small} % font of caption text
\setkomafont{captionlabel}{\bfseries} % font of caption label
\renewcommand*{\captionformat}{\quad} % no colon as separator
\setcaptionalignment{j} % justify caption
\setcapindent{0mm} % no indentation for multi-line captions
\captionsetup{parindent=\parindent} % controls paragraph indentation
%% QUOTES %%
\newcommand{\say}[1]{``#1''}
%% COLORS %%
\definecolor{blue}{HTML}{0069B3}
\definecolor{gray}{HTML}{53606B}
\definecolor{lightblue}{HTML}{DCE6EB}
\definecolor{red}{HTML}{E7004A}
\definecolor{green}{HTML}{00BD67}
\definecolor{purple}{HTML}{4E00BB}
\definecolor{orange}{HTML}{FF9000}
\definecolor{yellow}{HTML}{FFBE00}
\definecolor{dark-gray}{HTML}{414141} % MIT OpenCourseWare
\definecolor{dark-red}{HTML}{7B1429} % MIT OpenCourseWare
\definecolor{desmos-blue}{HTML}{245AA3} % Desmos Graphing Calculator
\definecolor{desmos-red}{HTML}{B82F32} % Desmos Graphing Calculator
\definecolor{desmos-green}{HTML}{2E7C36} % Desmos Graphing Calculator
%% BOXES %%
\tcbset{
enhanced,
breakable,
sharp corners=all
}
\newtcolorbox{thm}{colback=blue!50!white, colframe=blue!50!white}
\newtcolorbox{prop}{colback=blue!25!white, colframe=blue!25!white}
\newtcolorbox{lem}{colback=lightblue, colframe=lightblue}
\newtcolorbox{cor}{colback=lightblue, colframe=lightblue}
\newtcolorbox{defi}{colback=gray!50!white, colframe=gray!50!white}
%% MATH ENVIRONMENTS WITH BOXES %%
\newtheorem{Theorem}{Theorem}[chapter]
\newenvironment{theorem}{
\begin{thm}
\begin{Theorem}
}{
\end{Theorem}
\end{thm}
}
\newtheorem{Proposition}[Theorem]{Proposition}
\newenvironment{proposition}{
\begin{prop}
\begin{Proposition}
}{
\end{Proposition}
\end{prop}
}
\newtheorem{Lemma}[Theorem]{Lemma}
\newenvironment{lemma}{
\begin{lem}
\begin{Lemma}
}{
\end{Lemma}
\end{lem}
}
\newtheorem{Corollary}[Theorem]{Corollary}
\newenvironment{corollary}{
\begin{cor}
\begin{Corollary}
}{
\end{Corollary}
\end{cor}
}
\newtheorem{Definition}[Theorem]{Definition}
\newenvironment{definition}{
\begin{defi}
\begin{Definition}
}{
\end{Definition}
\end{defi}
}
%% MATH ENVIRONMENTS WITHOUT BOXES %%
\newtheorem{example}[Theorem]{Example}
\newtheorem{remark}[Theorem]{Remark}
%% HIGHLIGHT MATH DISPLAYS %%
\newcommand{\highlightMath}[1]{
\tcboxmath[colback=gray!25!white, colframe=gray!25!white]{
#1
}
}
%% NUMBERING OF EQUATIONS %%
\numberwithin{equation}{chapter}
%% EXERCISES & SOLUTIONS %%
\newtheorem{exercise}{Exercise}[]
\newenvironment{solution}[1]{
\begin{proof}[\normalfont\textbf{Solution to Exercise #1}]
}{
\end{proof}
}
%% MATH %%
\newcommand*{\e}{\mathrm{e}} % Euler's number
\newcommand*{\R}{\mathbb{R}} % real numbers
\newcommand*{\N}{\mathbb{N}} % natural numbers
\renewcommand*{\P}{\mathbb{P}} % probability measure
\newcommand*{\set}[1]{\left\{#1\right\}} % set notation
\newcommand*{\given}[1][]{\mathrel{#1|}} % vertical bar w/ spacing
\newcommand*{\with}[1][]{\mathrel{#1|}} % same as above
\DeclareMathOperator{\power}{\wp} % power set
\DeclareMathOperator*{\argmax}{argmax} % argmax
\DeclareMathOperator*{\argmin}{argmin} % argmin
\DeclareMathOperator{\sgn}{sgn} % sign function
\DeclareMathOperator{\Exp}{\mathbb{E}} % expectation
\DeclareMathOperator{\Var}{Var} % variance
\DeclareMathOperator{\Cov}{Cov} % covariance
\DeclareMathOperator{\MSE}{MSE} % mean squared error
\DeclareMathOperator{\Ber}{Ber} % Bernoulli distribution
\DeclareMathOperator{\Rad}{Rad} % Rademacher distribution
\newcommand*{\dx}{\, \mathrm{d}x} % dx
\newcommand*{\dt}{\, \mathrm{d}t} % dt
\newcommand*{\du}{\, \mathrm{d}u} % du
\renewcommand*{\dv}{\, \mathrm{d}v} % dv
\newcommand*{\dP}{\, \mathrm{d}\P} % dP
\newcommand*{\ind}[1]{\mathbf{1}_{#1}} % indicator function
\newcommand*{\indSet}[1]{\mathbf{1}_{\set{#1}}} % indicator function (v2)
%% SPACING BEFORE & AFTER DELIMITERS %%
% Based on https://tex.stackexchange.com/questions/2607/spacing-around-left-and-right
\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}
%% COLORED DELIMITERS %%
\newcommand{\cLeft}[2][.]{%
\begingroup\colorlet{leftColor}{.}
\color{#1}\left#2\color{leftColor}
} % left delimiter
\newcommand{\cRight}[2][.]{%
\color{#1}\right#2\endgroup
} % right delimiter
%% "PART" TITLE PAGES %%
% Based on https://tex.stackexchange.com/questions/705424/getting-rid-of-additional-space-above-and-below-the-title-of-a-part
% Remove the "." after "Part <counter>"
\renewcommand\partformat{%
\partname~\thepart%
}
% Get rid of any formatting of the title appearing on 'part' pages
\setkomafont{part}{}
\setkomafont{partnumber}{}
% Modify page layout
\newcounter{image}
\renewcommand\partlineswithprefixformat[3]{%
\thispagestyle{empty}%
\begin{tikzpicture}[remember picture, overlay]
% HEADLINE
\node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (headline) at ($(current page.south west) + (16mm, 72mm)$) {\fontsize{24pt}{34pt}\let\strut\relax\bfseries #3\par};
% SUBHEADLINE
\node[rectangle, anchor=south west, inner sep=0pt, text width=130mm, text=white] (subheadline) at ($(headline.north west) + (0, 16mm)$) {\fontsize{12pt}{14pt}\bfseries #2\par};
\begin{scope}[on background layer]
% LIGHTBLUE BACKGROUND
% \fill[lightblue] ($(current page.north west) + (8mm, -38mm)$) rectangle ($(current page.east |- subheadline.north) + (0, 16mm)$);
% BACKGROUND IMAGE
\setcounter{image}{\value{part}}
\node[opacity=.5, anchor=north west, inner sep=0pt] at ($(current page.north west) + (8mm, -38mm)$) {\includegraphics[width=202mm]{backgrounds/part-\arabic{image}}};
% LOGO
% \node[anchor=north east, inner sep=0pt] (jlu) at ($(current page.north east) - (8mm, 8mm)$) {\includegraphics[width=48mm, height=60mm]{tmp/logo}};
% BLUE TEXTBOX
\fill[blue, fill opacity=0.9] ($(current page.west |- subheadline.north) + (0mm, 32mm)$) rectangle ($(current page.west |- headline.south) + (154mm, -16mm)$);
\end{scope}
\end{tikzpicture}
}
%% BIBLIOGRAPHY %%
\usepackage[
backend=biber,
style=alphabetic
]{biblatex}
%% HYPERLINKS %%
\usepackage{hyperref} % adds hyperlinks to PDF (LAST PACKAGE TO LOAD!)
\hypersetup{
colorlinks=true,
citecolor=blue!80!black, % citations
linkcolor=blue!80!black, % internal links (figures, sections, etc.)
urlcolor=blue!80!black % web links
}