-
Notifications
You must be signed in to change notification settings - Fork 0
/
notestemplate.sty
272 lines (234 loc) · 7.39 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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{notestemplate}[2022/02/28 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{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{hyperref} % links colouring
\RequirePackage{verbatim} % monospaced text blocks
\RequirePackage{listings} % syntax highlighting
\RequirePackage{enumitem} % custom enum
\RequirePackage{wrapfig} % wrap figures
\RequirePackage{graphicx} % images
\RequirePackage{fontawesome} % dings
\RequirePackage{titlesec} % for sections customization
\RequirePackage{amsmath} % for better math typesetting
\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 listlng
\RequirePackage{anyfontsize} % for better font sizes
\RequirePackage{subcaption} % for subfigures and subcaptions
\RequirePackage[style=iso]{datetime2} % datetime command
\ProcessOptions\relax
% tikz libraries for automata and drawing
\usetikzlibrary{automata, positioning, backgrounds, arrows, arrows.meta, shapes, shapes.geometric, shapes.misc}
% 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/}}
% 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}{}
% add commands for checkmark
\newcommand{\cmark}{\faCheck\xspace} % check
\newcommand{\xmark}{\faTimes\xspace} % cross
\newcommand{\colorcmark}{\textcolor{ForestGreen}{\cmark}\xspace} % green check
\newcommand{\colorxmark}{\textcolor{BrickRed}{\xmark}\xspace} % red cross
% cusom macro creation
\newcommand{\shortfor}[1]{\textit{#1}\xspace}
% tighter lists
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
% resets equation numbering when starting a new section.
\numberwithin{equation}{section}
% page margins
\geometry{left = 2 cm, right = 2 cm, bottom = 2.5 cm, top = 2.5 cm}
\setlength{\parindent}{0em}
% hyperlinks colours
\hypersetup{
colorlinks=true,
urlcolor={black},
linkcolor={black},
citecolor={black}
}
% table spacing
\setlength{\tabcolsep}{1em} % for the horizontal padding
\renewcommand{\arraystretch}{1.4} % for the vertical padding
% TOC spacing
\advance\cftsecnumwidth 0.5em\relax
\advance\cftsubsecindent 0.5em\relax
\advance\cftsubsecnumwidth 0.5em\relax
% rename List into Listato o Code (according to language)
\iflanguage{italian} {
\renewcommand\lstlistingname{Listato}
\renewcommand\lstlistlistingname{Listati}
}{
\renewcommand\lstlistingname{Code}
\renewcommand\lstlistlistingname{Codes}
}
% 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!}
}
}
}
% lstlisting style definition for pseudocode
\lstdefinestyle{pseudocode}{
commentstyle=\color{gray},
keywordstyle=\color{black}\bfseries,
basicstyle=\ttfamily,
breakatwhitespace=false,
captionpos=b,
keepspaces=false,
numbers=left,
xleftmargin=10pt,
belowcaptionskip=20pt,
numberstyle=\small,
showspaces=false,
showstringspaces=false,
showtabs=false,
showlines=false,
tabsize=2,
morekeywords={and,ceil,downto,each,else,end,error,floor,for,if,in,nand,new,NIL,nor,or,repeat,return,swap,then,to,while,xnor,xor,do,until},
mathescape=true,
morecomment=[l][commentstyle]{//},
}
% lstlsting style definition for C
\lstdefinestyle{customc}{
commentstyle=\color{darkgray},
keywordstyle=\color{black}\bfseries,
basicstyle=\ttfamily\footnotesize,
language=C,
showstringspaces=false,
tabsize=2,
}
% command for indented quote block
\newcommand{\indentquote}[1]{
\vspace*{1em}
\hspace*{2.5em}%
\begin{minipage}{.9\textwidth}
\textit{\textquote{#1}}
\end{minipage}
\vspace*{1em}
}
% command for inline quote block
\newcommand{\inlinequote}[1]{
\hspace*{-0.75em}
\textit{\textquote{#1}}
\hspace*{-0.75em}
}
% command for my signature
\newcommand{\signature}{
\hspace{5cm}
\begin{flushright}
\textit{Lorenzo Rossi}
\end{flushright}
}
% white on gray text
\newcommand{\whiteongray}[1]{
\textcolor{white}{\colorbox{gray}{\strut #1}}
}
% command for when I can't be bothered
\newcommand{\TODO}{
\bigskip
\begin{center}
\Huge
\texttt{\textcolor{BrickRed}{TODO}}
\end{center}
\bigskip
}
% command for when I am slightly bothered
\newcommand{\WIP}{
\bigskip
\begin{center}
\Huge
\texttt{\textcolor{ForestGreen}{WIP}}
\end{center}
\bigskip
}
% command for cover
\newcommand{\makecover}[2] {
\pagenumbering{gobble}
\title{\Huge{#1}}
\iflanguage{italian} {
\author{\Large Lorenzo Rossi e tutti coloro che mi hanno aiutato!}
}{
\author{\Large Lorenzo Rossi and everyone who kindly helped!}
}
\date{#2}
\maketitle
\vspace{7.5cm}
\begin{center}
\iflanguage{italian} {
\large{\textbf{Ultimo aggiornamento: \today}} \\
\bigskip
\large{Questi appunti sono distributi con licenza Creative Commons 4.0 - CC BY-NC \ccbynceu} \\
}{
\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} \\
\iflanguage{italian} {
\footnotesize nessun alpaca è stato ferito nella scrittura di questi appunti
}{
\footnotesize no alpaca has been harmed while writing these notes
}
\end{figure}
\newpage
\pagenumbering{roman}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\newpage
}
\endinput