generated from lorossi/latex-notes-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
notestemplate.sty
executable file
·323 lines (298 loc) · 9.85 KB
/
notestemplate.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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{notestemplate}[2023-01-09 LaTeX template for my notes]
% I don't really know how those packages interact or why they do so
% but if I change the import order, something always stops working
% So don't change the order!
\RequirePackage[a4paper]{geometry} % page settings
\RequirePackage[utf8]{inputenc} % utf encoding
\RequirePackage{ccicons} % creative common icons
\RequirePackage[dvipsnames]{xcolor} % text colours
\RequirePackage[style=english]{csquotes} % for better quotes
\RequirePackage[english]{babel} % language specific stuff
\RequirePackage[T1]{fontenc} % UTF encoding
\RequirePackage{lmodern} % allows text at arbitrarily size
\RequirePackage{tikz} % for drawings
\RequirePackage{amsmath} % math environments
\RequirePackage{amsfonts} % math fonts
\RequirePackage{amssymb} % math symbols
\RequirePackage{mathtools} % math operators for asmmath
\RequirePackage{verbatim} % monospaced text blocks
\RequirePackage{listings} % syntax highlighting
\RequirePackage{enumitem} % custom enum
\RequirePackage{graphicx} % images
\RequirePackage{fontawesome} % dings
\RequirePackage{pifont} % more dings
\RequirePackage{wasysym} % math symbols
\RequirePackage{titlesec} % for sections customization
\RequirePackage{xspace} % for spacing after commands
\RequirePackage{xfrac} % for diagonal fractions
\RequirePackage{tocloft} % for spacing in TOC
\RequirePackage{nameref} % for named references
\RequirePackage{courier} % for bold in listings
\RequirePackage{anyfontsize} % for better font sizes
\RequirePackage{subcaption} % for subfigures and subcaptions
\RequirePackage{adjustbox} % to rotate and adjust floats
\RequirePackage{hyperref} % links colouring
\RequirePackage{tabularray} % for better tables
\RequirePackage{amsthm} % for theorem environments
\RequirePackage{tcolorbox} % for theorem environments style customization
\RequirePackage[style=iso]{datetime2} % datetime command
\RequirePackage{kvoptions} % for options in package
\RequirePackage{calculator} % for (mostly useless) calculations in package
%%% COMMANDS
\newcommand{\nt@year}{\the\year{}}
\ADD{\year}{1}{\nt@nextyear}
\newcommand{\nt@currentdate}{\nt@year/\nt@nextyear}
\SetupKeyvalOptions{
family=notestemplate,
prefix=nt@
}
\DeclareStringOption[Notes]{title}[Notes]
\DeclareStringOption[\nt@currentdate]{date}[\nt@currentdate]
\ProcessKeyvalOptions* % process options
%%% TEXT SETTINGS
% taller lines
\renewcommand{\baselinestretch}{1.05}
% number subparagraphs as well
\setcounter{secnumdepth}{5}
% include sub paragraphs in toc
\setcounter{tocdepth}{5}
% changed bullet for lists
\newcommand\sbullet[1][.5]{\mathbin{\vcenter{\hbox{\scalebox{#1}{\(\bullet\)}}}}}
\newcommand\striangle[1][.5]{\mathbin{\vcenter{\hbox{\scalebox{#1}{\(\blacktriangleright\)}}}}}
\renewcommand{\labelitemi}{\(\sbullet[.9]\)}
\renewcommand{\labelitemii}{\(\sbullet[.65]\)}
\renewcommand{\labelitemiii}{\(\striangle[.5]\)}
\renewcommand{\labelitemiv}{\(\rightarrrow\)}
% new line after paragraph
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{0.5em}{}
% subparagraph format
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{\thesubparagraph}{0.5em}{}
% tighter lists
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
% table spacing
\setlength{\tabcolsep}{1em} % for the horizontal padding
\renewcommand{\arraystretch}{1.4} % for the vertical padding
%%% GENERAL DOCUMENT SETTINGS
% resets equation numbering when starting a new section.
\numberwithin{equation}{section}
% page margins
\geometry{left=2cm,right=2cm,bottom=2.5cm,top=2.5cm}
% no indent for new paragraphs
\setlength{\parindent}{0em}
% hyperlinks colours
\hypersetup{
colorlinks=true,
urlcolor={black},
linkcolor={black},
citecolor={black}
}
% TOC spacing
\advance\cftsecnumwidth 0.5em\relax
\advance\cftsubsecindent 0.5em\relax
\advance\cftsubsecnumwidth 0.5em\relax
%%% TIKZ SETTINGS
% tikz libraries for automata and drawing
\usetikzlibrary{arrows,arrows.meta,automata,backgrounds,positioning,shapes}
% tikz styles
\input{tikzstyle.tikzstyles}
% standard layers used in .tikz files
\pgfdeclarelayer{edgelayer}
\pgfdeclarelayer{nodelayer}
\pgfsetlayers{background,edgelayer,nodelayer,main}
% style is applied by default to any tikzpicture included via \tikzfig
\tikzstyle{tikzfig}=[baseline=-0.25em,scale=0.5]
% style for blank nodes
\tikzstyle{none}=[inner sep=0mm]
% eternalize tikz so that it does not renders all the images each time
\usetikzlibrary{external}
\tikzexternalize[prefix=tikztemp/]
% images folder
\graphicspath{{Images/}}
%%% ENVIRONMENTS SETTINGS
% rename List into Code (according to language)
\renewcommand\lstlistingname{Code}
\renewcommand\lstlistlistingname{Codes}
% define custom colours for code environments
\definecolor{codetext}{rgb}{0.05,0.05,0.05}
\definecolor{codecomment}{rgb}{0.3,0.3,0.3}
\definecolor{codebg}{rgb}{0.97,0.97,0.97}
\definecolor{codeborder}{rgb}{0.76,0.76,0.76}
\definecolor{theorembg}{rgb}{0.97,0.97,0.97} % same as code
\definecolor{theoremborder}{rgb}{0.76,0.76,0.76} % same as code
% lstlisting pseudocode style
\lstdefinelanguage{pseudocode}{
morekeywords={NIL,and,ceil,do,downto,each,else,end,error,floor,for,if,in,nand,new,nor,or,repeat,return,swap,then,to,until,while,xnor,xor},
morecomment=[l][commentstyle]{//},
morecomment=[s][commentstyle]{/*}{*/},
}
% lstlsting custom style definition
\lstdefinestyle{custom}{
basicstyle=\color{codetext}\ttfamily\small,
commentstyle=\color{codecomment},
keywordstyle=\color{codetext}\bfseries,
backgroundcolor=\color{codebg},
rulecolor=\color{codeborder},
frame=single,
framesep=0pt,
framerule=1.5pt,
breakatwhitespace=false,
captionpos=b,
keepspaces=false,
framexleftmargin=4ex,
framexrightmargin=4ex,
framextopmargin=2ex,
framexbottommargin=2ex,
aboveskip=4ex,
belowskip=4ex,
abovecaptionskip=2ex,
numberstyle=\small,
showspaces=false,
showstringspaces=false,
showtabs=false,
showlines=false,
tabsize=2,
mathescape=true,
language=pseudocode,
breaklines=true,
breakatwhitespace=true,
breakindent=1em,
float=htbp
}
% lstlisting default style
\lstset{style=custom}
% theorem, definitions and properties styling
\tcbuselibrary{breakable}
% theorem style
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
% definition style
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
% property style
\theoremstyle{definition}
\newtheorem{property}{Property}[section]
% problem style
\theoremstyle{definition}
\newtheorem{problem}{Problem}[section]
% proposition style
\theoremstyle{definition}
\newtheorem{proposition}{Proposition}[section]
% example style
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
% notes style
\theoremstyle{definition}
\newtheorem{notes}{Notes}[section]
% remark style
\theoremstyle{definition}
\newtheorem{remarks}{Remarks}[section]
% set style for theorem-like environments
\tcbset{theorem/.style ={
before skip=4ex,
after skip=4ex,
boxsep=0mm,
top=2ex,
bottom=2ex,
left*=4ex,
right*=4ex,
colback=theorembg,
colframe=theoremborder,
sharp corners,
unbreakable
}
}
\tcolorboxenvironment{theorem}{theorem}{}
\tcolorboxenvironment{lemma}{theorem}{}
\tcolorboxenvironment{corollary}{theorem}{}
\tcolorboxenvironment{proof}{theorem}{}
% set style for definition-like environments
\tcbset{definition/.style ={
before skip=2ex,
after skip=2ex,
boxsep=1ex,
colback=theorembg,
colframe=theoremborder,
sharp corners,
}
}
\tcolorboxenvironment{definition}{definition}{}
\tcolorboxenvironment{property}{definition}{}
\tcolorboxenvironment{problem}{definition}{}
\tcolorboxenvironment{proposition}{definition}{}
\tcolorboxenvironment{example}{definition}{}
\tcolorboxenvironment{notes}{definition}{}
\tcolorboxenvironment{remarks}{definition}{}
%%% CUSTOM COMMANDS
% add commands for checkmark
\newcommand{\cmark}{\faCheck\xspace} % check
\newcommand{\cmarkthin}{\ding{51}\xspace} % check
\newcommand{\xmark}{\faTimes\xspace} % cross
\newcommand{\xmarkthin}{\ding{53}\xspace} % cross
\newcommand{\colorcmark}{\textcolor{ForestGreen}{\cmark}\xspace} % green check
\newcommand{\colorcmarkthin}{\textcolor{ForestGreen}{\cmarkthin}\xspace} % green check
\newcommand{\colorxmark}{\textcolor{BrickRed}{\xmark}\xspace} % red cross
\newcommand{\colorxmarkthin}{\textcolor{BrickRed}{\xmarkthin}\xspace} % red cross
% custom macro creation
\newcommand{\shortfor}[1]{\textit{#1}\xspace}
% command for inline quote block
\newcommand{\inlinequote}[1]{
\hspace*{-0.75em}
\textit{\textquote{#1}}
\hspace*{-0.75em}
}
% command for cover
\newcommand{\makecover} {
\pagenumbering{gobble}
\title{\Huge{\nt@title}}
\author{\Large Lorenzo Rossi and everyone who kindly helped!}
\date{\nt@date}
\maketitle
\vspace{7.5cm}
\begin{center}
\large{\textbf{Last update: \today}} \\
\bigskip
\large{These notes are distributed under Creative Commons 4.0 license - CC BY-NC \ccbynceu} \\
\end{center}
\begin{figure}[b]
\centering
\includegraphics[width=5cm]{logo.png} \\
\footnotesize no alpaca has been harmed while writing these notes
\end{figure}
\newpage
\pagenumbering{roman}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\newpage
}
% command to add tikzit image
\newcommand{\tikzfig}[2][1] {
\IfFileExists{Images/#2} {
\scalebox{#1}{
\tikzstyle{every picture}=[tikzfig]
\tikzsetnextfilename{#2}
\input{Images/#2}
}
}{
% image not found, just write it down
\textcolor{BrickRed}{
\colorbox{white}{Image Images/#2 not found!}
}
}
}
% command for indented quote block
\newcommand{\indentquote}[1]{
\vspace*{1em}
\hspace*{2.5em}%
\begin{minipage}{.9\textwidth}
\textit{\textquote{#1}}
\end{minipage}
\vspace*{1em}
}
% environment to avoid page breaks
\newenvironment{onepage}
{\begin{minipage}{\textwidth}\bigskip}{\end{minipage}}
\endinput