% TEMPLATE FILE USED FOR NATHANIEL JOHNSTON'S (nathaniel@njohnston.ca) COURSE NOTES
% Uses pieces of the LaTeX Orange Book template (https://www.latextemplates.com/template/legrand-orange-book) by Mathias Legrand and Vel, which is licensed under CC BY-NC-SA 4.0.
% This source code and these notes are also licensed under CC BY-NC-SA 4.0.

\documentclass[12pt,letterpaper,oneside,openany,extrafontsizes]{memoir}
\usepackage{afterpage}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[usenames,dvipsnames]{color}
\usepackage{enumitem}
\usepackage[letterpaper, margin=1in, tmargin=1.4in, bmargin=0.2in]{geometry}
\usepackage{graphicx}
\usepackage{latexsym}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{url}
\usepackage{natbib}
\usepackage{skull}
\usepackage{standalone}
\usepackage{systeme}\sysdelim..
\usepackage{xargs}
\usepackage{tikz}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=RedOrange,urlcolor=ocre,linktoc=page,pagebackref=true]{hyperref}
\usepackage[all]{hypcap}

\definecolor{ocre}{RGB}{0,96,128}
\definecolor{orng}{RGB}{224,112,0}
\definecolor{dred}{RGB}{164,28,0}

\def\C{\mathbb{C}}
\def\R{\mathbb{R}}

\def\a{\mathbf{a}}
\def\b{\mathbf{b}}
\def\c{\mathbf{c}}
\def\d{\mathbf{d}}
\def\e{\mathbf{e}}
\def\u{\mathbf{u}}
\def\v{\mathbf{v}}
\def\w{\mathbf{w}}
\def\x{\mathbf{x}}
\def\y{\mathbf{y}}
\def\z{\mathbf{z}}
\def\0{\mathbf{0}}

\def\cS{\mathcal{S}}
\def\M{\mathcal{M}}
\def\P{\mathcal{P}}
\def\V{\mathcal{V}}
\def\W{\mathcal{W}}
\newcommand*{\diff}{\mathop{}\:\!d}
\newcommand\ip[2]{\ensuremath{\langle#1,#2\rangle}}

% Boxed/framed environments
\newtheoremstyle{drednumbox}%
{0pt}% Space above
{0pt}% Space below
{\normalfont}%
{}% Indent amount
{}%
{\\[0.5em]}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\sffamily\large\color{dred}\bfseries\thmname{#1}\nobreakspace\thmnumber{#2}% Theorem text (e.g. Theorem 2.1)
	\thmnote{\nobreakspace\sffamily\bfseries\color{black}---\nobreakspace#3}}
\renewcommand{\qedsymbol}{$\blacksquare$}


% Boxed/framed environments
\newtheoremstyle{ocrenumbox}%
{10pt}% Space above
{0pt}% Space below
{\normalfont}%
{}% Indent amount
{}%
{\\[0.5em]}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\sffamily\large\color{ocre}\bfseries\thmname{#1}\nobreakspace\thmnumber{#2}% Theorem text (e.g. Theorem 2.1)
	\thmnote{\nobreakspace\sffamily\bfseries\color{black}---\nobreakspace#3}}
\renewcommand{\qedsymbol}{$\blacksquare$}


% Boxed/framed environments
\newtheoremstyle{orngnumbox}%
{10pt}% Space above
{0pt}% Space below
{\normalfont}%
{}% Indent amount
{}%
{\\[0.5em]}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\sffamily\large\color{orng}\bfseries\thmname{#1}\nobreakspace\thmnumber{#2}% Theorem text (e.g. Theorem 2.1)
	\thmnote{\nobreakspace\sffamily\bfseries\color{black}---\nobreakspace#3}}
\renewcommand{\qedsymbol}{$\blacksquare$}



\newcounter{dummyT} 
\newcounter{dummyD} 
\numberwithin{dummyT}{chapter}
\numberwithin{dummyD}{chapter}
\newtheorem*{claim}{Claim}
\newtheorem*{cor}{Corollary}
\newtheorem*{conclusion}{Conclusion}
\newtheorem*{lemma}{Lemma}
\newtheorem*{prop}{Proposition}
\newtheorem*{prob}{Problem}
\newtheorem*{exam}{Example}
\newtheorem*{rem}{Remark}


\theoremstyle{ocrenumbox}
\newtheorem{definitionT}[dummyD]{Definition}

\theoremstyle{orngnumbox}
\newtheorem{theoremeT}[dummyT]{Theorem}

\theoremstyle{drednumbox}
\newtheorem{corollaryT}[dummyT]{Corollary}

\setlist[enumerate,1]{label=\alph*),font=\bfseries}


%----------------------------------------------------------------------------------------
%	DEFINITION OF COLORED BOXES
%----------------------------------------------------------------------------------------

\RequirePackage[framemethod=default]{mdframed}

% Theorem box
\newmdenv[skipabove=14pt,
skipbelow=14pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=orng,
backgroundcolor=black!5,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=10pt]{tBox}

% Definition box
\newmdenv[skipabove=14pt,
skipbelow=14pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=ocre,
backgroundcolor=black!5,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=10pt]{dBox}

% Corollary box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=dred,
backgroundcolor=black!5,
innerleftmargin=8pt,
innerrightmargin=8pt,
innertopmargin=8pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=8pt]{cBox}	

\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
\newenvironment{corollary}{\begin{cBox}\begin{corollaryT}}{\end{corollaryT}\end{cBox}}			


\newcommand{\horlines}[2][\linewidth]{%
	\noindent\begin{tikzpicture}
		\draw[line width=0.1mm, white] (0,0.3) -- (#1,0.3);
		\draw[line width=0.1mm, white] (0,#2+1.2) -- (#1,#2+1.2);
		\foreach \x in {1,...,#2} {
			\draw[line width=0.1mm, black!10] (0,\x) -- (#1,\x);
		}
	\end{tikzpicture}}


% This next block allows for custom numbering of exercises
\newtheorem{innercustomexer}{Exercise}
\newenvironment{customexer}[1]
  {\renewcommand\theinnercustomexer{#1}\innercustomexer}
  {\endinnercustomexer}
  
\newcommand{\exx}[2][3]{\begin{exam}\textit{#2} \\ \horlines{#1}\end{exam}}
\newcommand{\bra}[1]{\langle #1 |}
\newcommand{\ket}[1]{| #1 \rangle}
\newcommand{\braket}[2]{\langle #1 | #2 \rangle}
\newcommand{\ketbra}[2]{| #1 \rangle\langle #2 |}
\newcommand{\bb}[1]{\mathbb{#1}}
\newcommand{\cl}[1]{\mathcal{#1}}
\newcommand{\defeq}{\stackrel{\smash{\textnormal{\tiny def}}}{=}}

\title{\coursecode \ -- \coursename}
\author{\instructorname}

%%% Some adjustments to make the ToC function how we want
\renewcommand*\contentsname{Table of Contents}
\renewcommand*{\cftchaptername}{Week\space}

% BEGIN CUSTOM CHAPTER HEADER
\makeatletter
\newcommand\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\setlength\midchapskip{10pt}
\makechapterstyle{VZ14}{
\renewcommand\chapternamenum{}
\renewcommand\printchaptername{}
\renewcommand\chapnamefont{\Large\scshape}
\renewcommand\printchapternum{%
\vspace*{-9em}
\chapnamefont\null\thickhrulefill\quad
\coursename \ -- Week\space\arabic{chapter}\quad\thickhrulefill}
\renewcommand\printchapternonum{%
\par\thickhrulefill\par\vskip\midchapskip
\hrule\vskip\midchapskip
}
\renewcommand\chaptitlefont{\huge\scshape\centering}
\renewcommand\afterchapternum{%
\par\nobreak\vskip\midchapskip\hrule\vskip\midchapskip}
\renewcommand\afterchaptertitle{%
\par\vskip\midchapskip\hrule\nobreak\vskip\afterchapskip}
}
\makeatother
\chapterstyle{VZ14}
% END CUSTOM CHAPTER HEADER

% Modification of the `headings' page style
\nouppercaseheads
\makeheadrule{headings}{\textwidth}{\normalrulethickness}
\makeevenhead{headings}{\thepage}{}{\textsc{\leftmark}}
\makeoddhead{headings}{\textsc{\coursename} -- Week\space\arabic{chapter}}{}{\thepage}
\addtopsmarks{headings}{}{
  \createmark{chapter}{both}{nonumber}{}{. \space}
}
\pagestyle{headings}

\setlength{\parskip}{0pt}
\setsecheadstyle{\Large\bfseries\raggedright}
\setsubsecheadstyle{\large\bfseries\raggedright}

\sloppybottom

\begin{document}