%---------------------------------------------------------------------------------------- % VARIOUS REQUIRED PACKAGES %---------------------------------------------------------------------------------------- \usepackage{titlesec} % Allows customization of titles \usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry} % Page margins \usepackage{xcolor} % Required for specifying colors by name \usepackage{graphicx} % Required for including pictures % Font Settings \usepackage{avant} % Use the Avantgarde font for headings %\usepackage{times} % Use the Times font for headings \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 \usepackage{marvosym} \usepackage{microtype} % Slightly tweak font spacing for aesthetics \usepackage[utf8]{inputenc} % Required for including letters with accents \usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs \usepackage{pifont} % Index \usepackage{calc} % For simpler calculation - used for spacing the index letter headings correctly \usepackage{makeidx} % Required to make an index \graphicspath{{pictures/}} % Specifies the directory where pictures are stored \usepackage{lipsum} % Inserts dummy text \usepackage{tikz} % Required for drawing custom shapes \usepackage[english]{babel} % English language/hyphenation \usepackage{enumitem} % Customize lists \setlist{nolistsep} % Reduce spacing between bullet points and numbered lists \usepackage{booktabs} % Required for nicer horizontal rules in tables \usepackage{eso-pic} % Required for specifying an image background in the title page \usepackage{listings} % Required for inserting code snippets \definecolor{ocre}{RGB}{243,102,25} % Define the orange color used for highlighting throughout the book \definecolor{DarkGreen}{rgb}{0.0,0.4,0.0} % Comment color \definecolor{highlight}{RGB}{255,251,204} % Code highlight color \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 language=C, % Detects keywords, comments, strings, functions, etc for the language specified backgroundcolor=\color{highlight}, % Set the background color for the snippet - useful for highlighting basicstyle=\footnotesize\ttfamily, % The default font size and style of the code breakatwhitespace=false, % If true, only allows line breaks at white space breaklines=true, % Automatic line breaking (prevents code from protruding outside the box) captionpos=b, % Sets the caption position: b for bottom; t for top commentstyle=\usefont{T1}{pcr}{m}{sl}\color{DarkGreen}, % Style of comments within the code - dark green courier font deletekeywords={}, % If you want to delete any keywords from the current language separate them by commas %escapeinside={\%}, % This allows you to escape to LaTeX using the character in the bracket firstnumber=1, % Line numbers begin at line 1 frame=single, % Frame around the code box, value can be: none, leftline, topline, bottomline, lines, single, shadowbox frameround=tttt, % Rounds the corners of the frame for the top left, top right, bottom left and bottom right positions keywordstyle=\color{blue}\bf, % Functions are bold and blue morekeywords={}, % Add any functions no included by default here separated by commas numbers=left, % Location of line numbers, can take the values of: none, left, right numbersep=10pt, % Distance of line numbers from the code box numberstyle=\tiny\color{gray}, % Style used for line numbers rulecolor=\color{black}, % Frame border color showstringspaces=false, % Don't put marks in string spaces showtabs=false, % Display tabs in the code as lines stepnumber=5, % The step distance between line numbers, i.e. how often will lines be numbered stringstyle=\color{purple}, % Strings are purple tabsize=2, % Number of spaces per tab in the code } %---------------------------------------------------------------------------------------- % MAIN TABLE OF CONTENTS %---------------------------------------------------------------------------------------- \usepackage{titletoc} % Required for manipulating the table of contents \contentsmargin{0cm} % Removes the default margin % Chapter text styling \titlecontents{chapter}[1.25cm] % Indentation {\addvspace{15pt}\large\sffamily\bfseries} % Spacing and font options for chapters {\color{ocre!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}} % Chapter number {} {\color{ocre!60}\normalsize\sffamily\bfseries\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number % Section text styling \titlecontents{section}[1.25cm] % Indentation {\addvspace{5pt}\sffamily\bfseries} % Spacing and font options for sections {\contentslabel[\thecontentslabel]{1.25cm}} % Section number {} {\sffamily\hfill\color{black}\thecontentspage} % Page number [] % Subsection text styling \titlecontents{subsection}[1.25cm] % Indentation {\addvspace{1pt}\sffamily\small} % Spacing and font options for subsections {\contentslabel[\thecontentslabel]{1.25cm}} % Subsection number {} {\sffamily\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number [] %---------------------------------------------------------------------------------------- % MINI TABLE OF CONTENTS IN CHAPTER HEADS %---------------------------------------------------------------------------------------- % Section text styling \titlecontents{lsection}[0em] % Indendating {\footnotesize\sffamily} % Font settings {} {} {} % Subsection text styling \titlecontents{lsubsection}[.5em] % Indentation {\normalfont\footnotesize\sffamily} % Font settings {} {} {} %---------------------------------------------------------------------------------------- % PAGE HEADERS %---------------------------------------------------------------------------------------- \usepackage{fancyhdr} % Required for header and footer configuration \pagestyle{fancy} \renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries #1}{}} % Chapter text font settings \renewcommand{\sectionmark}[1]{\markright{\sffamily\large\thesection\hspace{5pt} #1}{}} % Section text font settings \fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Font setting for the page number in the header \fancyhead[LO]{\rightmark} % Print the nearest section name on the left side of odd pages \fancyhead[RE]{\leftmark} % Print the current chapter name on the right side of even pages \renewcommand{\headrulewidth}{0.5pt} % Width of the rule under the header \addtolength{\headheight}{2.5pt} % Increase the spacing around the header slightly \renewcommand{\footrulewidth}{0pt} % Removes the rule in the footer \fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} % Style for when a plain pagestyle is specified % Removes the header from odd empty pages at the end of chapters \makeatletter \renewcommand{\cleardoublepage}{ \clearpage\ifodd\c@page\else %\hbox{} %\vspace*{\fill} %\thispagestyle{empty} %\newpage \fi} %---------------------------------------------------------------------------------------- % THEOREM STYLES %---------------------------------------------------------------------------------------- \usepackage{amsmath,amsfonts,amssymb,amsthm} % For including math equations, theorems, symbols, etc \newcommand{\intoo}[2]{\mathopen{]}#1\,;#2\mathclose{[}} \newcommand{\ud}{\mathop{\mathrm{{}d}}\mathopen{}} \newcommand{\intff}[2]{\mathopen{[}#1\,;#2\mathclose{]}} \newtheorem{notation}{Notation}[chapter] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%% dedicated to boxed/framed environements %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newtheoremstyle{ocrenumbox}% % Theorem style name {0pt}% Space above {0pt}% Space below {\normalfont}% % Body font {}% Indent amount {\small\bf\sffamily\color{ocre}}% % Theorem head font {\;}% Punctuation after theorem head {0.25em}% Space after theorem head {\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1) \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note \renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square \newtheoremstyle{blacknumex}% Theorem style name {5pt}% Space above {5pt}% Space below {\normalfont}% Body font {} % Indent amount {\small\bf\sffamily}% Theorem head font {\;}% Punctuation after theorem head {0.25em}% Space after theorem head {\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1) \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note \newtheoremstyle{blacknumbox} % Theorem style name {0pt}% Space above {0pt}% Space below {\normalfont}% Body font {}% Indent amount {\small\bf\sffamily}% Theorem head font {\;}% Punctuation after theorem head {0.25em}% Space after theorem head {\small\sffamily\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1) \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%% dedicated to non-boxed/non-framed environements %%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newtheoremstyle{ocrenum}% % Theorem style name {5pt}% Space above {5pt}% Space below {\normalfont}% % Body font {}% Indent amount {\small\bf\sffamily\color{ocre}}% % Theorem head font {\;}% Punctuation after theorem head {0.25em}% Space after theorem head {\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1) \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note \renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square \makeatother % Defines the theorem text style for each type of theorem to one of the three styles above \newcounter{dummy} \numberwithin{dummy}{section} \theoremstyle{ocrenumbox} \newtheorem{theoremeT}[dummy]{Theorem} \newtheorem{problem}{Problem}[chapter] \newtheorem{question}{Question}[chapter] \newtheorem{Warning}{Warning}[chapter] \newtheorem{reminder}[question]{Reminder} \newtheorem{exerciseT}{Exercise}[chapter] \theoremstyle{blacknumex} \newtheorem{exampleT}{Example}[chapter] \theoremstyle{blacknumbox} \newtheorem{vocabulary}{Vocabulary}[chapter] \newtheorem{definitionT}{Definition}[section] \newtheorem{corollaryT}[dummy]{Corollary} \theoremstyle{ocrenum} \newtheorem{proposition}[dummy]{Proposition} %---------------------------------------------------------------------------------------- % DEFINITION OF COLORED BOXES %---------------------------------------------------------------------------------------- \newcommand\Loadedframemethod{TikZ} \RequirePackage[framemethod=\Loadedframemethod]{mdframed} %\RequirePackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes % Theorem box \newmdenv[skipabove=7pt, skipbelow=7pt, backgroundcolor=black!5, linecolor=ocre, innerleftmargin=5pt, innerrightmargin=5pt, innertopmargin=5pt, leftmargin=0cm, rightmargin=0cm, innerbottommargin=5pt]{tBox} % Exercise box \newmdenv[skipabove=7pt, skipbelow=7pt, rightline=false, leftline=true, topline=false, bottomline=false, backgroundcolor=ocre!10, linecolor=ocre, innerleftmargin=5pt, innerrightmargin=5pt, innertopmargin=5pt, innerbottommargin=5pt, leftmargin=0cm, rightmargin=0cm, linewidth=4pt]{eBox} % Definition box \newmdenv[skipabove=7pt, skipbelow=7pt, rightline=false, leftline=true, topline=false, bottomline=false, linecolor=ocre, innerleftmargin=5pt, innerrightmargin=5pt, innertopmargin=0pt, leftmargin=0cm, rightmargin=0cm, linewidth=4pt, innerbottommargin=0pt]{dBox} % Corollary box \newmdenv[skipabove=7pt, skipbelow=7pt, rightline=false, leftline=true, topline=false, bottomline=false, linecolor=gray, backgroundcolor=black!5, innerleftmargin=5pt, innerrightmargin=5pt, innertopmargin=5pt, leftmargin=0cm, rightmargin=0cm, linewidth=4pt, innerbottommargin=5pt]{cBox} % 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 \newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}} \newenvironment{exercise}{\begin{eBox}\begin{exerciseT}}{\hfill{\color{ocre}\tiny\ensuremath{\blacksquare}}\end{exerciseT}\end{eBox}} \newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}} \newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}} \newenvironment{corollary}{\begin{cBox}\begin{corollaryT}}{\end{corollaryT}\end{cBox}} %---------------------------------------------------------------------------------------- % REMARK ENVIRONMENT %---------------------------------------------------------------------------------------- \newenvironment{remark}{\par\vskip10pt\small % Vertical white space above the remark and smaller font size \begin{list}{}{ \leftmargin=35pt % Indentation on the left \rightmargin=25pt}\item\ignorespaces % Indentation on the right \makebox[-2.5pt]{\begin{tikzpicture}[overlay] \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 \advance\baselineskip -1pt}{\end{list}\vskip5pt} % Tighter line spacing and white space after remark %---------------------------------------------------------------------------------------- % SECTION NUMBERING IN THE MARGIN %---------------------------------------------------------------------------------------- \makeatletter \renewcommand{\@seccntformat}[1]{\llap{\textcolor{ocre}{\csname the#1\endcsname}\hspace{1em}}} \renewcommand{\section}{\@startsection{section}{1}{\z@} {-4ex \@plus -1ex \@minus -.4ex} {1ex \@plus.2ex } {\normalfont\large\sffamily\bfseries}} \renewcommand{\subsection}{\@startsection {subsection}{2}{\z@} {-3ex \@plus -0.1ex \@minus -.4ex} {0.5ex \@plus.2ex } {\normalfont\sffamily\bfseries}} \renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@} {-2ex \@plus -0.1ex \@minus -.2ex} {0.2ex \@plus.2ex } {\normalfont\small\sffamily\bfseries}} \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@} {-2ex \@plus-.2ex \@minus .2ex} {0.1ex} {\normalfont\small\sffamily\bfseries}} %---------------------------------------------------------------------------------------- % CHAPTER HEADINGS %---------------------------------------------------------------------------------------- \newcommand{\thechapterimage}{} \newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}} \def\thechapter{\arabic{chapter}} \def\@makechapterhead#1{ \thispagestyle{empty} {\centering \normalfont\sffamily \ifnum \c@secnumdepth >\m@ne \if@mainmatter \startcontents \begin{tikzpicture}[remember picture,overlay] \node at (current page.north west) {\begin{tikzpicture}[remember picture,overlay] \node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}}; %Commenting the 3 lines below removes the small contents box in the chapter heading \draw[fill=white,opacity=.6] (1cm,0) rectangle (7.7cm,-4.7cm); \node[anchor=north west] at (1cm,.25cm) {\parbox[t][8cm][t]{6.6cm}{\huge\bfseries\flushleft \printcontents{l}{1}{\setcounter{tocdepth}{2}}}}; \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]{}}}; \end{tikzpicture}}; \end{tikzpicture}}\par\vspace*{230\p@} \fi \fi } \def\@makeschapterhead#1{ \thispagestyle{empty} {\centering \normalfont\sffamily \ifnum \c@secnumdepth >\m@ne \if@mainmatter \startcontents \begin{tikzpicture}[remember picture,overlay] \node at (current page.north west) {\begin{tikzpicture}[remember picture,overlay] \node[anchor=north west] at (-4pt,4pt) {\includegraphics[width=\paperwidth]{\thechapterimage}}; \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]{}}}; \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]{}}}; \end{tikzpicture}}; \end{tikzpicture}}\par\vspace*{230\p@} \fi \fi } \makeatother