\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage[charter]{mathdesign}
\usepackage{geometry}
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=.9in,
 top=1.0in,
 bottom=1.5in,
 right=.9in,
 }
\setlength{\columnsep}{.5in}

\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{setspace}
\usepackage{mfirstuc}
\usepackage{graphicx,changepage}
\usepackage{pgffor}

% For development
\usepackage{comment}

% Make hyperrefs work
\usepackage{hyperref}

% Set up bibliography
\usepackage[semicolon,square,sort&compress,sectionbib,numbers]{natbib}

% Chapter by chapter bib
\usepackage{chapterbib}

% Set up source code highlighting
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
columns=flexible,
breaklines=true
}

\usepackage[usenames,dvipsnames]{color}
\definecolor{greencomments}{rgb}{0,0.5,0}
\definecolor{redstrings}{rgb}{0.9,0,0}
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\definecolor{foreground}{HTML}{4D4D4C}
\definecolor{background}{HTML}{FFFFFF}
\definecolor{selection}{HTML}{D6D6D6}
\definecolor{line}{HTML}{EFEFEF}
\definecolor{comment}{HTML}{8E908C}
\definecolor{red}{HTML}{C82829}
\definecolor{orange}{HTML}{F5871F}
\definecolor{yellow}{HTML}{EAB700}
\definecolor{green}{HTML}{718C00}
\definecolor{aqua}{HTML}{3E999F}
\definecolor{blue}{HTML}{4271AE}
\definecolor{purple}{HTML}{8959A8}
\definecolor{window}{HTML}{EFEFEF}

% Has to be name shadecolor
\definecolor{shadecolor}{HTML}{EEEEEE}
\usepackage{framed}
\newcommand{\CodeSymbol}[1]{\textcolor{red}{#1}\bfseries}

\lstset{aboveskip=20pt,
belowskip=20pt,
xleftmargin=1.5cm,
xrightmargin=1.5cm,
xtopmargin=1cm,
xbottommargin=1cm,
framexrightmargin=.5em,
framexleftmargin=.5em,
frame=bt,
framextopmargin=5pt,
framexbottommargin=5pt,
backgroundcolor=\color{shadecolor},
rulecolor=\color{shadecolor},}

% Define syntax highlighting style
\usepackage{listings}
% set up quotes
\usepackage{epigraph}

\renewcommand{\epigraphrule}{0pt}
\setlength{\epigraphwidth}{.6\textwidth}
\renewcommand{\textflush}{flushepinormal}
\makeatletter
% Taken and updated from http://mirrors.ctan.org/macros/latex/contrib/epigraph/epigraph.dtx
\renewcommand{\@epitext}[1]{%
  \begin{minipage}{\epigraphwidth}\begin{\textflush} \hspace*{30pt}#1\\
    \ifdim\epigraphrule>\z@ \@epirule \else \vspace*{-.5\baselineskip} \fi
  \end{\textflush}\end{minipage}}
\makeatother

% Define titles and chapter
\usepackage[Bjornstrup]{fncychap}
\singlespacing
\title{\vspace{-15mm}\fontsize{24pt}{10pt}\selectfont\textbf{CS341 System Programming Coursebook}}
\date{}

% define custom environments, so we can change global style at will
\newcommand{\keyword}[1]{\underline{\smash{\textbf{\texttt{#1}}}}}
\newcommand{\todo}[1]{}
\renewcommand{\todo}[1]{{\color{red} TODO: {#1}}}
\lstnewenvironment{lstlisting}[1][]%
  {\noindent\minipage{\linewidth}\medskip
   \lstset{basicstyle=\ttfamily\footnotesize,frame=single,#1}}
  {\endminipage}

% For pictures
\newenvironment{proof}{\begin{shaded*}\paragraph{Proof:}}{\hfill$\square$\end{shaded*}}
\newenvironment{tableau}{\begin{shaded*}\begin{longtable}}{\end{longtable}\end{shaded*}}
\usepackage{wrapfig}


%  100/90/10/77 
\definecolor{titlepagecolor}{cmyk}{1,.9,.1,.77}
\definecolor{linecolor}{cmyk}{.01,.83,.84,0}
\definecolor{namecolor}{cmyk}{1,.50,0,.10}
%-----------------------------------------------------------------
\usepackage{csquotes}

% this is a terrible hack, but pandoc sucks
% we have to call any
\lstnewenvironment{minted}{m}
  {\noindent\minipage{\linewidth}\medskip 
   \lstset{basicstyle=\ttfamily\footnotesize,frame=single,language=#1}}
  {\endminipage}

\usepackage{float}

% title spacing

\usepackage[compact]{titlesec}

\renewcommand{\baselinestretch}{1.15}
