1 %----------------------------------------------------------------------------------------
2 % VARIOUS REQUIRED PACKAGES
3 %----------------------------------------------------------------------------------------
5 \usepackage{titlesec
} % Allows customization of titles
7 \usepackage[top=
3cm,bottom=
3cm,left=
3.2cm,right=
3.2cm,headsep=
10pt,
a4paper]{geometry
} % Page margins
9 \usepackage{xcolor
} % Required for specifying colors by name
11 \usepackage{graphicx} % Required for including pictures
13 \usepackage{avant
} % Use the Avantgarde font for headings
14 %\usepackage{times} % Use the Times font for headings
15 \usepackage{mathptmx
} % Use the Adobe Times Roman as the default text font together with math symbols from the SymÂbol, Chancery and ComÂputer Modern fonts
18 \usepackage{microtype
} % Slightly tweak font spacing for aesthetics
19 \usepackage[utf8
]{inputenc} % Required for including letters with accents
20 \usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
24 \usepackage{calc
} % For simpler calculation - used for spacing the index letter headings correctly
25 \usepackage{makeidx
} % Required to make an index
27 \graphicspath{{pictures/
}} % Specifies the directory where pictures are stored
29 \usepackage{lipsum
} % Inserts dummy text
31 \usepackage{tikz
} % Required for drawing custom shapes
33 \usepackage[english
]{babel
} % English language/hyphenation
35 \usepackage{enumitem
} % Customize lists
36 \setlist{nolistsep
} % Reduce spacing between bullet points and numbered lists
38 \usepackage{booktabs
} % Required for nicer horizontal rules in tables
40 \usepackage{eso-pic
} % Required for specifying an image background in the title page
42 \usepackage{listings
} % Required for inserting code snippets
44 \definecolor{ocre
}{RGB
}{243,
102,
25} % Define the orange color used for highlighting throughout the book
45 \definecolor{DarkGreen
}{rgb
}{0.0,
0.4,
0.0} % Comment color
46 \definecolor{highlight
}{RGB
}{255,
251,
204} % Code highlight color
48 \lstdefinestyle{Style1
}{ % Define a style for your code snippet, multiple definitions can be made if, for example, you wish to insert multiple code snippets using different programming languages into one document
49 language=C,
% Detects keywords, comments, strings, functions, etc for the language specified
50 backgroundcolor=
\color{highlight
},
% Set the background color for the snippet - useful for highlighting
51 basicstyle=
\footnotesize\ttfamily,
% The default font size and style of the code
52 breakatwhitespace=false,
% If true, only allows line breaks at white space
53 breaklines=true,
% Automatic line breaking (prevents code from protruding outside the box)
54 captionpos=b,
% Sets the caption position: b for bottom; t for top
55 commentstyle=
\usefont{T1}{pcr
}{m
}{sl
}\color{DarkGreen
},
% Style of comments within the code - dark green courier font
56 deletekeywords=
{},
% If you want to delete any keywords from the current language separate them by commas
57 %escapeinside={\%}, % This allows you to escape to LaTeX using the character in the bracket
58 firstnumber=
1,
% Line numbers begin at line 1
59 frame=single,
% Frame around the code box, value can be: none, leftline, topline, bottomline, lines, single, shadowbox
60 frameround=tttt,
% Rounds the corners of the frame for the top left, top right, bottom left and bottom right positions
61 keywordstyle=
\color{blue
}\bf,
% Functions are bold and blue
62 morekeywords=
{},
% Add any functions no included by default here separated by commas
63 numbers=left,
% Location of line numbers, can take the values of: none, left, right
64 numbersep=
10pt,
% Distance of line numbers from the code box
65 numberstyle=
\tiny\color{gray
},
% Style used for line numbers
66 rulecolor=
\color{black
},
% Frame border color
67 showstringspaces=false,
% Don't put marks in string spaces
68 showtabs=false,
% Display tabs in the code as lines
69 stepnumber=
5,
% The step distance between line numbers, i.e. how often will lines be numbered
70 stringstyle=
\color{purple
},
% Strings are purple
71 tabsize=
2,
% Number of spaces per tab in the code
74 %----------------------------------------------------------------------------------------
75 % MAIN TABLE OF CONTENTS
76 %----------------------------------------------------------------------------------------
78 \usepackage{titletoc
} % Required for manipulating the table of contents
80 \contentsmargin{0cm
} % Removes the default margin
81 % Chapter text styling
82 \titlecontents{chapter
}[1.25cm
] % Indentation
83 {\addvspace{15pt
}\large\sffamily\bfseries} % Spacing and font options for chapters
84 {\color{ocre!
60}\contentslabel[\Large\thecontentslabel]{1.25cm
}\color{ocre
}} % Chapter number
86 {\color{ocre!
60}\normalsize\sffamily\bfseries\;
\titlerule*
[.5pc
]{.
}\;
\thecontentspage} % Page number
87 % Section text styling
88 \titlecontents{section
}[1.25cm
] % Indentation
89 {\addvspace{5pt
}\sffamily\bfseries} % Spacing and font options for sections
90 {\contentslabel[\thecontentslabel]{1.25cm
}} % Section number
92 {\sffamily\hfill\color{black
}\thecontentspage} % Page number
94 % Subsection text styling
95 \titlecontents{subsection
}[1.25cm
] % Indentation
96 {\addvspace{1pt
}\sffamily\small} % Spacing and font options for subsections
97 {\contentslabel[\thecontentslabel]{1.25cm
}} % Subsection number
99 {\sffamily\;
\titlerule*
[.5pc
]{.
}\;
\thecontentspage} % Page number
102 %----------------------------------------------------------------------------------------
103 % MINI TABLE OF CONTENTS IN CHAPTER HEADS
104 %----------------------------------------------------------------------------------------
106 % Section text styling
107 \titlecontents{lsection
}[0em
] % Indendating
108 {\footnotesize\sffamily} % Font settings
113 % Subsection text styling
114 \titlecontents{lsubsection
}[.5em
] % Indentation
115 {\normalfont\footnotesize\sffamily} % Font settings
120 %----------------------------------------------------------------------------------------
122 %----------------------------------------------------------------------------------------
124 \usepackage{fancyhdr
} % Required for header and footer configuration
127 \renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries #1}{}} % Chapter text font settings
128 \renewcommand{\sectionmark}[1]{\markright{\sffamily\large\thesection\hspace{5pt
} #1}{}} % Section text font settings
130 \fancyhf{} \fancyhead[LE,RO
]{\sffamily\normalsize\thepage} % Font setting for the page number in the header
131 \fancyhead[LO
]{\rightmark} % Print the nearest section name on the left side of odd pages
132 \fancyhead[RE
]{\leftmark} % Print the current chapter name on the right side of even pages
133 \renewcommand{\headrulewidth}{0.5pt
} % Width of the rule under the header
134 \addtolength{\headheight}{2.5pt
} % Increase the spacing around the header slightly
135 \renewcommand{\footrulewidth}{0pt
} % Removes the rule in the footer
136 \fancypagestyle{plain
}{\fancyhead{}\renewcommand{\headrulewidth}{0pt
}} % Style for when a plain pagestyle is specified
138 % Removes the header from odd empty pages at the end of chapters
140 \renewcommand{\cleardoublepage}{
141 \clearpage\ifodd\c@page
\else
144 %\thispagestyle{empty}
148 %----------------------------------------------------------------------------------------
150 %----------------------------------------------------------------------------------------
152 \usepackage{amsmath,amsfonts,amssymb,amsthm
} % For including math equations, theorems, symbols, etc
154 \newcommand{\intoo}[2]{\mathopen{]}#1\,;
#2\mathclose{[}}
155 \newcommand{\ud}{\mathop{\mathrm{{}d
}}\mathopen{}}
156 \newcommand{\intff}[2]{\mathopen{[}#1\,;
#2\mathclose{]}}
157 \newtheorem{notation
}{Notation
}[chapter
]
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160 %%%%%%%%%%%%%%%%%%%% dedicated to boxed/framed environements %%%%%%%%%%%%%%
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 \newtheoremstyle{ocrenumbox
}% % Theorem style name
165 {\normalfont}% % Body font
167 {\small\bf\sffamily\color{ocre
}}% % Theorem head font
168 {\;
}% Punctuation after theorem head
169 {0.25em
}% Space after theorem head
170 {\small\sffamily\color{ocre
}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty
{#1}{}\@upn
{#2}}% Theorem text (e.g. Theorem 2.1)
171 \thmnote{\nobreakspace\the\thm@notefont
\sffamily\bfseries\color{black
}---
\nobreakspace#3.
}} % Optional theorem note
172 \renewcommand{\qedsymbol}{$
\blacksquare$
}% Optional qed square
174 \newtheoremstyle{blacknumex
}% Theorem style name
177 {\normalfont}% Body font
179 {\small\bf\sffamily}% Theorem head font
180 {\;
}% Punctuation after theorem head
181 {0.25em
}% Space after theorem head
182 {\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty
{#1}{}\@upn
{#2}}% Theorem text (e.g. Theorem 2.1)
183 \thmnote{\nobreakspace\the\thm@notefont
\sffamily\bfseries---
\nobreakspace#3.
}}% Optional theorem note
185 \newtheoremstyle{blacknumbox
} % Theorem style name
188 {\normalfont}% Body font
190 {\small\bf\sffamily}% Theorem head font
191 {\;
}% Punctuation after theorem head
192 {0.25em
}% Space after theorem head
193 {\small\sffamily\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty
{#1}{}\@upn
{#2}}% Theorem text (e.g. Theorem 2.1)
194 \thmnote{\nobreakspace\the\thm@notefont
\sffamily\bfseries---
\nobreakspace#3.
}}% Optional theorem note
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 %%%%%%%%%%%%% dedicated to non-boxed/non-framed environements %%%%%%%%%%%%%
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 \newtheoremstyle{ocrenum
}% % Theorem style name
202 {\normalfont}% % Body font
204 {\small\bf\sffamily\color{ocre
}}% % Theorem head font
205 {\;
}% Punctuation after theorem head
206 {0.25em
}% Space after theorem head
207 {\small\sffamily\color{ocre
}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty
{#1}{}\@upn
{#2}}% Theorem text (e.g. Theorem 2.1)
208 \thmnote{\nobreakspace\the\thm@notefont
\sffamily\bfseries\color{black
}---
\nobreakspace#3.
}} % Optional theorem note
209 \renewcommand{\qedsymbol}{$
\blacksquare$
}% Optional qed square
212 % Defines the theorem text style for each type of theorem to one of the three styles above
214 \numberwithin{dummy
}{section
}
215 \theoremstyle{ocrenumbox
}
216 \newtheorem{theoremeT
}[dummy
]{Theorem
}
217 \newtheorem{problem
}{Problem
}[chapter
]
218 \newtheorem{question
}{Question
}[chapter
]
219 \newtheorem{Warning
}{Warning
}[chapter
]
220 \newtheorem{reminder
}[question
]{Reminder
}
221 \newtheorem{exerciseT
}{Exercise
}[chapter
]
222 \theoremstyle{blacknumex
}
223 \newtheorem{exampleT
}{Example
}[chapter
]
224 \theoremstyle{blacknumbox
}
225 \newtheorem{vocabulary
}{Vocabulary
}[chapter
]
226 \newtheorem{definitionT
}{Definition
}[section
]
227 \newtheorem{corollaryT
}[dummy
]{Corollary
}
228 \theoremstyle{ocrenum
}
229 \newtheorem{proposition
}[dummy
]{Proposition
}
231 %----------------------------------------------------------------------------------------
232 % DEFINITION OF COLORED BOXES
233 %----------------------------------------------------------------------------------------
235 \newcommand\Loadedframemethod{TikZ
}
236 \RequirePackage[framemethod=
\Loadedframemethod]{mdframed
}
238 %\RequirePackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes
241 \newmdenv[skipabove=
7pt,
243 backgroundcolor=black!
5,
246 innerrightmargin=
5pt,
250 innerbottommargin=
5pt
]{tBox
}
253 \newmdenv[skipabove=
7pt,
259 backgroundcolor=ocre!
10,
262 innerrightmargin=
5pt,
264 innerbottommargin=
5pt,
270 \newmdenv[skipabove=
7pt,
278 innerrightmargin=
5pt,
283 innerbottommargin=
0pt
]{dBox
}
286 \newmdenv[skipabove=
7pt,
293 backgroundcolor=black!
5,
295 innerrightmargin=
5pt,
300 innerbottommargin=
5pt
]{cBox
}
303 % Creates an environment for each type of theorem and assigns it a theorem text style from the "Theorem Styles" section above and a colored box from above
304 \newenvironment{theorem
}{\begin{tBox
}\begin{theoremeT
}}{\end{theoremeT
}\end{tBox
}}
305 \newenvironment{exercise
}{\begin{eBox
}\begin{exerciseT
}}{\hfill{\color{ocre
}\tiny\ensuremath{\blacksquare}}\end{exerciseT
}\end{eBox
}}
306 \newenvironment{definition
}{\begin{dBox
}\begin{definitionT
}}{\end{definitionT
}\end{dBox
}}
307 \newenvironment{example
}{\begin{exampleT
}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT
}}
308 \newenvironment{corollary
}{\begin{cBox
}\begin{corollaryT
}}{\end{corollaryT
}\end{cBox
}}
310 %----------------------------------------------------------------------------------------
312 %----------------------------------------------------------------------------------------
314 \newenvironment{remark
}{\par\vskip10pt\small % Vertical white space above the remark and smaller font size
316 \leftmargin=
35pt
% Indentation on the left
317 \rightmargin=
25pt
}\item\ignorespaces % Indentation on the right
318 \makebox[-
2.5pt
]{\begin{tikzpicture
}[overlay
]
319 \node[draw=ocre!
60,line width=
1pt,circle,fill=ocre!
25,font=
\sffamily\bfseries,inner sep=
2pt,outer sep=
0pt
] at (-
15pt,
0pt)
{\textcolor{ocre
}{R
}};
\end{tikzpicture
}} % Orange R in a circle
320 \advance\baselineskip -
1pt
}{\end{list
}\vskip5pt} % Tighter line spacing and white space after remark
322 %----------------------------------------------------------------------------------------
323 % SECTION NUMBERING IN THE MARGIN
324 %----------------------------------------------------------------------------------------
327 \renewcommand{\@seccntformat
}[1]{\llap{\textcolor{ocre
}{\csname the
#1\endcsname}\hspace{1em
}}}
328 \renewcommand{\section}{\@startsection
{section
}{1}{\z@
}
329 {-
4ex \@plus -
1ex \@minus -
.4ex
}
331 {\normalfont\large\sffamily\bfseries}}
332 \renewcommand{\subsection}{\@startsection
{subsection
}{2}{\z@
}
333 {-
3ex \@plus -
0.1ex \@minus -
.4ex
}
335 {\normalfont\sffamily\bfseries}}
336 \renewcommand{\subsubsection}{\@startsection
{subsubsection
}{3}{\z@
}
337 {-
2ex \@plus -
0.1ex \@minus -
.2ex
}
339 {\normalfont\small\sffamily\bfseries}}
340 \renewcommand\paragraph{\@startsection
{paragraph
}{4}{\z@
}
341 {-
2ex \@plus-
.2ex \@minus
.2ex
}
343 {\normalfont\small\sffamily\bfseries}}
345 %----------------------------------------------------------------------------------------
347 %----------------------------------------------------------------------------------------
349 \newcommand{\thechapterimage}{}
350 \newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}
351 \def\thechapter{\arabic{chapter
}}
352 \def\@makechapterhead
#1{
353 \thispagestyle{empty
}
354 {\centering \normalfont\sffamily
355 \ifnum \c@secnumdepth >
\m@ne
358 \begin{tikzpicture
}[remember picture,overlay
]
359 \node at (current page.north west)
360 {\begin{tikzpicture
}[remember picture,overlay
]
362 \node[anchor=north west,inner sep=
0pt
] at (
0,
0)
{\includegraphics[width=
\paperwidth]{\thechapterimage}};
364 %Commenting the 3 lines below removes the small contents box in the chapter heading
365 \draw[fill=white,opacity=
.6] (
1cm,
0) rectangle (
7.7cm,-
4.7cm);
366 \node[anchor=north west
] at (
1cm,
.25cm)
{\parbox[t
][8cm
][t
]{6.6cm
}{\huge\bfseries\flushleft \printcontents{l
}{1}{\setcounter{tocdepth}{2}}}};
368 \draw[anchor=west
] (
5cm,-
9cm) node
[rounded corners=
25pt,fill=white,fill opacity=
.6,text opacity=
1,draw=ocre,draw opacity=
1,line width=
2pt,inner sep=
15pt
]{\huge\sffamily\bfseries\textcolor{black
}{\thechapter\ ---\
#1\vphantom{plPQq
}\makebox[22cm
]{}}};
370 \end{tikzpicture
}}\par\vspace*
{230\p@
}
374 \def\@makeschapterhead
#1{
375 \thispagestyle{empty
}
376 {\centering \normalfont\sffamily
377 \ifnum \c@secnumdepth >
\m@ne
380 \begin{tikzpicture
}[remember picture,overlay
]
381 \node at (current page.north west)
382 {\begin{tikzpicture
}[remember picture,overlay
]
383 \node[anchor=north west
] at (-
4pt,
4pt)
{\includegraphics[width=
\paperwidth]{\thechapterimage}};
384 \draw[anchor=west
] (
5cm,-
9cm) node
[rounded corners=
25pt,fill=white,opacity=
.7,inner sep=
15.5pt
]{\huge\sffamily\bfseries\textcolor{black
}{\vphantom{plPQq
}\makebox[22cm
]{}}};
385 \draw[anchor=west
] (
5cm,-
9cm) node
[rounded corners=
25pt,draw=ocre,line width=
2pt,inner sep=
15pt
]{\huge\sffamily\bfseries\textcolor{black
}{#1\vphantom{plPQq
}\makebox[22cm
]{}}};
387 \end{tikzpicture
}}\par\vspace*
{230\p@
}