Skip to content

Commit 29be36b

Browse files
committed
Add Unit 1
1 parent 3390fa5 commit 29be36b

File tree

8 files changed

+194
-6
lines changed

8 files changed

+194
-6
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
/.vscode/
1010
/out/
1111
*.thm
12-
*.toc
12+
*.toc
13+
*.pygtex
14+
*.pygstyle
15+
/_minted-notes/
16+
/old/

notes.tex

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
\providecommand{\main}{.}
12
\documentclass[11pt, a4paper]{book}
23

34
\usepackage{notestyles}
@@ -12,4 +13,5 @@
1213
\end{titlepage}
1314
\clearpage\begingroup\pagestyle{empty}\cleardoublepage\endgroup
1415
\tableofcontents
16+
\addfile{units/unit01/unit01.tex}
1517
\end{document}

notestyles.sty

+54-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,64 @@
2626

2727
% Fonts
2828
\RequirePackage[T1]{fontenc}
29-
\RequirePackage{charter}
30-
\RequirePackage[varqu,varl]{inconsolata}
31-
\RequirePackage[type1]{cabin}
32-
\RequirePackage[xcharter]{newtxmath}
33-
\RequirePackage{bm}
29+
\RequirePackage{unicode-math}
30+
\setmainfont{XCharter}
31+
\setsansfont{Cabin}
32+
\setmathfont{XCharter Math}
33+
\setmonofont{Source Code Pro}
34+
35+
% Colors
36+
\RequirePackage[dvipsnames,table]{xcolor}
37+
\definecolor{lightGrey}{rgb}{0.9,0.9,0.9}
38+
\colorlet{codeColor}{PineGreen!15!white}
39+
\colorlet{codeBorder}{PineGreen}
40+
\colorlet{definitionColor}{Aquamarine!30!white}
41+
\colorlet{definitionBorder}{Aquamarine!75!black}
42+
\colorlet{definitionCode}{definitionColor!35!white}
43+
\colorlet{exampleColor}{blue!15!white}
44+
\colorlet{exampleTitle}{black}
45+
\colorlet{exampleCode}{exampleColor!35!white}
46+
\colorlet{noteColor}{red!15!white}
47+
\colorlet{noteBorder}{red!75!black}
48+
\colorlet{noteCode}{noteColor!35!white}
3449

3550
% Tables
3651
\RequirePackage{tabularray}
3752
\UseTblrLibrary{booktabs}
53+
\UseTblrLibrary{varwidth}
54+
\SetTblrInner[tblr]{measure=vbox}
55+
\newcommand{\nl}{\\}
56+
57+
% Code
58+
\RequirePackage{minted}
59+
60+
\RequirePackage{etoolbox}
61+
\makeatletter
62+
% replace \medskip before the box with nothing, i.e., remove it
63+
\patchcmd{\minted@colorbg}{\medskip}{}{}{}
64+
\makeatother
65+
66+
67+
% Color Boxes
68+
\RequirePackage{tcolorbox}
69+
\tcbuselibrary{breakable}
70+
\RequirePackage{adjustbox}
71+
\newenvironment{codebox}[2][]
72+
{\tcolorbox[breakable, colback=codeColor, colframe=codeBorder, fonttitle=\bfseries, title={#2}, center title, parbox=false, center, #1]}
73+
{\endtcolorbox}
74+
\newenvironment{definition}[2][]
75+
{\tcolorbox[breakable, colback=definitionColor, colframe=definitionBorder, fonttitle=\bfseries, title={#2}, center title, parbox=false, center, #1]}
76+
{\endtcolorbox}
77+
\newenvironment{example}[1][]
78+
{\tcolorbox[coltitle=exampleTitle, colback=exampleColor, breakable, detach title, before upper={\tcbtitle\quad}, title=\textbf{Example}, parbox=false, center, #1]}
79+
{\endtcolorbox}
80+
\newenvironment{sidenote}[2][]
81+
{\tcolorbox[breakable, colback=noteColor, colframe=noteBorder, fonttitle=\bfseries, title={#2}, center title, parbox=false, center, #1]}
82+
{\endtcolorbox}
83+
84+
% Indented Paragraphs
85+
\RequirePackage{changepage}
86+
\newenvironment{indentparagraph}{\begin{adjustwidth}{2em}{}}{\end{adjustwidth}}
3887

3988
% Include/Input Subfiles
4089
\RequirePackage{xstring}

package_intellisense/notestyles.cwl

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# notestyles
2+
\addfile[input]{<filename>}
3+
\addfile{<filename>}
4+
\begin{codebox}{title}
5+
\begin{definition}{title}
6+
\begin{example}
7+
\begin{exercise}{title}
8+
\begin{indentparagraph}
9+
\begin{sidenote}{title}
10+
\concept{text}
11+
\end{codebox}
12+
\end{definition}
13+
\end{example}
14+
\end{exercise}
15+
\end{indentparagraph}
16+
\end{sidenote}
17+
\nl
18+
\question{text}
19+
\rulebookend
20+
\rulechapterend
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"addfile[]{}": {
3+
"command": "addfile[input]{<filename>}",
4+
"package": "notestyles",
5+
"snippet": "addfile[${2:input}]{${1:<filename>}}"
6+
},
7+
"addfile{}": {
8+
"command": "addfile{<filename>}",
9+
"package": "notestyles",
10+
"snippet": "addfile{${1:<filename>}}"
11+
},
12+
"concept{}": {
13+
"command": "concept{text}",
14+
"package": "notestyles",
15+
"snippet": "concept{${1:text}}"
16+
},
17+
"nl": {
18+
"command": "nl",
19+
"package": "notestyles",
20+
"snippet": "nl"
21+
},
22+
"question{}": {
23+
"command": "question{text}",
24+
"package": "notestyles",
25+
"snippet": "question{${1:text}}"
26+
},
27+
"rulebookend": {
28+
"command": "rulebookend",
29+
"package": "notestyles",
30+
"snippet": "rulebookend"
31+
},
32+
"rulechapterend": {
33+
"command": "rulechapterend",
34+
"package": "notestyles",
35+
"snippet": "rulechapterend"
36+
}
37+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"codebox{}": {
3+
"name": "codebox",
4+
"detail": "codebox{title}",
5+
"snippet": "{${1:title}}",
6+
"package": "notestyles"
7+
},
8+
"definition{}": {
9+
"name": "definition",
10+
"detail": "definition{title}",
11+
"snippet": "{${1:title}}",
12+
"package": "notestyles"
13+
},
14+
"exercise{}": {
15+
"name": "exercise",
16+
"detail": "exercise{title}",
17+
"snippet": "{${1:title}}",
18+
"package": "notestyles"
19+
},
20+
"indentparagraph": {
21+
"name": "indentparagraph",
22+
"detail": "indentparagraph",
23+
"snippet": "",
24+
"package": "notestyles"
25+
},
26+
"sidenote{}": {
27+
"name": "sidenote",
28+
"detail": "sidenote{title}",
29+
"snippet": "{${1:title}}",
30+
"package": "notestyles"
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
double ave(double n1, double n2)
2+
{
3+
return ((n1 + n2)/2.0);
4+
}
5+
double ave(double n1, double n2, double n3)
6+
{
7+
return ((n1 + n2 + n3)/2.0);
8+
}

units/unit01/unit01.tex

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
\providecommand{\main}{../..}
2+
\documentclass[\main/notes.tex]{subfiles}
3+
4+
\begin{document}
5+
\chapter{Overloading \& Assert Macro}
6+
\section{Overloading}
7+
\begin{definition}{Overloading}
8+
Define two or more functions with the same function name.\\
9+
Must have either (or both):
10+
\begin{itemize}[nosep]
11+
\item different number of formal parameters
12+
\item formal parameters of different types across the functions
13+
\end{itemize}
14+
\inputminted[bgcolor=definitionCode]{cpp}{\subfix{code/01_overload_example.cpp}}
15+
16+
\noindent Automatically converts to the correct type needed for a function, unless there is already an overloaded function with that type.
17+
\end{definition}
18+
\section{Assert Macro}
19+
\begin{definition}{\texttt{assert} Macro}
20+
Ensure that expected conditions are true at the location of the \texttt{assert} statement. If the conditions are not, the program will display an error message, and abort.
21+
22+
\begin{minted}[bgcolor=definitionCode]{cpp}
23+
#include <cassert>
24+
assert(boolean_expression)
25+
\end{minted}
26+
27+
\noindent To ensure that assertion errors are not shown to users when a program is distributed, use
28+
\begin{minted}[bgcolor=definitionCode]{cpp}
29+
#define NDEBUG
30+
#include <cassert>
31+
\end{minted}
32+
\end{definition}
33+
34+
\rulechapterend
35+
36+
\end{document}

0 commit comments

Comments
 (0)