1%---------------------------------------------------------------------------------------- 2% VARIOUS REQUIRED PACKAGES 3%---------------------------------------------------------------------------------------- 4 5\usepackage{titlesec} % Allows customization of titles 6 7\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry} % Page margins 8 9\usepackage{xcolor} % Required for specifying colors by name 10 11\usepackage{graphicx} % Required for including pictures 12% Font Settings 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 Symbol, Chancery and Computer Modern fonts 16\usepackage{marvosym} 17 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 21 22\usepackage{pifont} 23% Index 24\usepackage{calc} % For simpler calculation - used for spacing the index letter headings correctly 25\usepackage{makeidx} % Required to make an index 26 27\graphicspath{{pictures/}} % Specifies the directory where pictures are stored 28 29\usepackage{lipsum} % Inserts dummy text 30 31\usepackage{tikz} % Required for drawing custom shapes 32 33\usepackage[english]{babel} % English language/hyphenation 34 35\usepackage{enumitem} % Customize lists 36\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists 37 38\usepackage{booktabs} % Required for nicer horizontal rules in tables 39 40\usepackage{eso-pic} % Required for specifying an image background in the title page 41 42\usepackage{listings} % Required for inserting code snippets 43 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 47 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 49language=C, % Detects keywords, comments, strings, functions, etc for the language specified 50backgroundcolor=\color{highlight}, % Set the background color for the snippet - useful for highlighting 51basicstyle=\footnotesize\ttfamily, % The default font size and style of the code 52breakatwhitespace=false, % If true, only allows line breaks at white space 53breaklines=true, % Automatic line breaking (prevents code from protruding outside the box) 54captionpos=b, % Sets the caption position: b for bottom; t for top 55commentstyle=\usefont{T1}{pcr}{m}{sl}\color{DarkGreen}, % Style of comments within the code - dark green courier font 56deletekeywords={}, % 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 58firstnumber=1, % Line numbers begin at line 1 59frame=single, % Frame around the code box, value can be: none, leftline, topline, bottomline, lines, single, shadowbox 60frameround=tttt, % Rounds the corners of the frame for the top left, top right, bottom left and bottom right positions 61keywordstyle=\color{blue}\bf, % Functions are bold and blue 62morekeywords={}, % Add any functions no included by default here separated by commas 63numbers=left, % Location of line numbers, can take the values of: none, left, right 64numbersep=10pt, % Distance of line numbers from the code box 65numberstyle=\tiny\color{gray}, % Style used for line numbers 66rulecolor=\color{black}, % Frame border color 67showstringspaces=false, % Don't put marks in string spaces 68showtabs=false, % Display tabs in the code as lines 69stepnumber=5, % The step distance between line numbers, i.e. how often will lines be numbered 70stringstyle=\color{purple}, % Strings are purple 71tabsize=2, % Number of spaces per tab in the code 72} 73 74%---------------------------------------------------------------------------------------- 75% MAIN TABLE OF CONTENTS 76%---------------------------------------------------------------------------------------- 77 78\usepackage{titletoc} % Required for manipulating the table of contents 79 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 85{} 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 91{} 92{\sffamily\hfill\color{black}\thecontentspage} % Page number 93[] 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 98{} 99{\sffamily\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number 100[] 101 102%---------------------------------------------------------------------------------------- 103% MINI TABLE OF CONTENTS IN CHAPTER HEADS 104%---------------------------------------------------------------------------------------- 105 106% Section text styling 107\titlecontents{lsection}[0em] % Indendating 108{\footnotesize\sffamily} % Font settings 109{} 110{} 111{} 112 113% Subsection text styling 114\titlecontents{lsubsection}[.5em] % Indentation 115{\normalfont\footnotesize\sffamily} % Font settings 116{} 117{} 118{} 119 120%---------------------------------------------------------------------------------------- 121% PAGE HEADERS 122%---------------------------------------------------------------------------------------- 123 124\usepackage{fancyhdr} % Required for header and footer configuration 125 126\pagestyle{fancy} 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 129 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 137 138% Removes the header from odd empty pages at the end of chapters 139\makeatletter 140\renewcommand{\cleardoublepage}{ 141\clearpage\ifodd\c@page\else 142%\hbox{} 143%\vspace*{\fill} 144%\thispagestyle{empty} 145%\newpage 146\fi} 147 148%---------------------------------------------------------------------------------------- 149% THEOREM STYLES 150%---------------------------------------------------------------------------------------- 151 152\usepackage{amsmath,amsfonts,amssymb,amsthm} % For including math equations, theorems, symbols, etc 153 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] 158 159%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 160%%%%%%%%%%%%%%%%%%%% dedicated to boxed/framed environements %%%%%%%%%%%%%% 161%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 162\newtheoremstyle{ocrenumbox}% % Theorem style name 163{0pt}% Space above 164{0pt}% Space below 165{\normalfont}% % Body font 166{}% Indent amount 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 173 174\newtheoremstyle{blacknumex}% Theorem style name 175{5pt}% Space above 176{5pt}% Space below 177{\normalfont}% Body font 178{} % Indent amount 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 184 185\newtheoremstyle{blacknumbox} % Theorem style name 186{0pt}% Space above 187{0pt}% Space below 188{\normalfont}% Body font 189{}% Indent amount 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 195 196%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 197%%%%%%%%%%%%% dedicated to non-boxed/non-framed environements %%%%%%%%%%%%% 198%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 199\newtheoremstyle{ocrenum}% % Theorem style name 200{5pt}% Space above 201{5pt}% Space below 202{\normalfont}% % Body font 203{}% Indent amount 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 210\makeatother 211 212% Defines the theorem text style for each type of theorem to one of the three styles above 213\newcounter{dummy} 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} 230 231%---------------------------------------------------------------------------------------- 232% DEFINITION OF COLORED BOXES 233%---------------------------------------------------------------------------------------- 234 235\newcommand\Loadedframemethod{TikZ} 236\RequirePackage[framemethod=\Loadedframemethod]{mdframed} 237 238%\RequirePackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes 239 240% Theorem box 241\newmdenv[skipabove=7pt, 242skipbelow=7pt, 243backgroundcolor=black!5, 244linecolor=ocre, 245innerleftmargin=5pt, 246innerrightmargin=5pt, 247innertopmargin=5pt, 248leftmargin=0cm, 249rightmargin=0cm, 250innerbottommargin=5pt]{tBox} 251 252% Exercise box 253\newmdenv[skipabove=7pt, 254skipbelow=7pt, 255rightline=false, 256leftline=true, 257topline=false, 258bottomline=false, 259backgroundcolor=ocre!10, 260linecolor=ocre, 261innerleftmargin=5pt, 262innerrightmargin=5pt, 263innertopmargin=5pt, 264innerbottommargin=5pt, 265leftmargin=0cm, 266rightmargin=0cm, 267linewidth=4pt]{eBox} 268 269% Definition box 270\newmdenv[skipabove=7pt, 271skipbelow=7pt, 272rightline=false, 273leftline=true, 274topline=false, 275bottomline=false, 276linecolor=ocre, 277innerleftmargin=5pt, 278innerrightmargin=5pt, 279innertopmargin=0pt, 280leftmargin=0cm, 281rightmargin=0cm, 282linewidth=4pt, 283innerbottommargin=0pt]{dBox} 284 285% Corollary box 286\newmdenv[skipabove=7pt, 287skipbelow=7pt, 288rightline=false, 289leftline=true, 290topline=false, 291bottomline=false, 292linecolor=gray, 293backgroundcolor=black!5, 294innerleftmargin=5pt, 295innerrightmargin=5pt, 296innertopmargin=5pt, 297leftmargin=0cm, 298rightmargin=0cm, 299linewidth=4pt, 300innerbottommargin=5pt]{cBox} 301 302 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}} 309 310%---------------------------------------------------------------------------------------- 311% REMARK ENVIRONMENT 312%---------------------------------------------------------------------------------------- 313 314\newenvironment{remark}{\par\vskip10pt\small % Vertical white space above the remark and smaller font size 315\begin{list}{}{ 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 321 322%---------------------------------------------------------------------------------------- 323% SECTION NUMBERING IN THE MARGIN 324%---------------------------------------------------------------------------------------- 325 326\makeatletter 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} 330{1ex \@plus.2ex } 331{\normalfont\large\sffamily\bfseries}} 332\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@} 333{-3ex \@plus -0.1ex \@minus -.4ex} 334{0.5ex \@plus.2ex } 335{\normalfont\sffamily\bfseries}} 336\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@} 337{-2ex \@plus -0.1ex \@minus -.2ex} 338{0.2ex \@plus.2ex } 339{\normalfont\small\sffamily\bfseries}} 340\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@} 341{-2ex \@plus-.2ex \@minus .2ex} 342{0.1ex} 343{\normalfont\small\sffamily\bfseries}} 344 345%---------------------------------------------------------------------------------------- 346% CHAPTER HEADINGS 347%---------------------------------------------------------------------------------------- 348 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 356\if@mainmatter 357\startcontents 358\begin{tikzpicture}[remember picture,overlay] 359\node at (current page.north west) 360{\begin{tikzpicture}[remember picture,overlay] 361 362\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}}; 363 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}}}}; 367 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]{}}}; 369\end{tikzpicture}}; 370\end{tikzpicture}}\par\vspace*{230\p@} 371\fi 372\fi 373} 374\def\@makeschapterhead#1{ 375\thispagestyle{empty} 376{\centering \normalfont\sffamily 377\ifnum \c@secnumdepth >\m@ne 378\if@mainmatter 379\startcontents 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]{}}}; 386\end{tikzpicture}}; 387\end{tikzpicture}}\par\vspace*{230\p@} 388\fi 389\fi 390} 391\makeatother 392