
%%% ----------------------------------------------------------------------

% Packages
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{mathrsfs}
\usepackage{bigints}
\usepackage{relsize}

% Set the paper size here.
% Book size: paperwidth=170mm, paperheight=240mm
% A4:        paperwidth=210mm, paperheight=297mm
% US Letter: paperwidth=216mm, paperheight=279mm
\usepackage[paperwidth=210mm, paperheight=297mm]{geometry}

\usepackage{tocloft}
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
% Width of equation number in List of Equations.
\setlength{\cftmyequationsnumwidth}{3.0em}
% Width of list number in list of figures.
\setlength{\cftfignumwidth}{3.0em}
% Width of section numbers in table of contents.
\setlength{\cftsecnumwidth}{2.8em}
\setlength{\cftsubsecnumwidth}{3.5em}

% For decimal aligned columns.
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
% Keeps figures in the sections where they are defined.
\usepackage[section]{placeins}
\usepackage{txfonts}
\usepackage{graphicx}
%\usepackage{grfext}
%\PrependGraphicsExtensions*{.png,.PNG}
% [hypcap=false] gets rid of this message:
% The option `hypcap=true' will be ignored for this(caption) particular \caption
% when \captionof is used.
\usepackage[hypcap=false]{caption}
\usepackage{floatrow}
\usepackage{wrapfig}
\usepackage{floatrow}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage[dvipsnames]{xcolor}
\usepackage{array}
\usepackage{lettrine}
\usepackage{indentfirst}
% You may need to comment out the microtype package if compilation
%    takes a long time, and uncomment for the final run.
\usepackage{microtype}
\usepackage{titlesec}
%\titleformat{\chapter}{\large\bfseries}{\thesection}{1em}{\hrule}
%\usepackage{tikz}
\usepackage{listings}
% Set the default code style.
\lstset{
%basicstyle=\normalsize\ttfamily\color{Sepia},
basicstyle=\normalsize\ttfamily\color{Blue},
    %frame=tb, % draw a frame at the top and bottom of the code block
    tabsize=2, % tab space width
    showstringspaces=false, % don't mark spaces in strings
    %numbers=left, % display line numbers on the left
    commentstyle=\color{Green}, % comment color
    keywordstyle=\color{Blue}, % keyword color
    stringstyle=\color{Maroon} % string color
}
% justification is raggedright (i.e. left aligned)
% singlelinecheck=off means that the justification setting is used even when the caption is only a single line long. 
% if singlelinecheck=on, then caption is always centered when the caption is only one line.
%\captionsetup[lstlisting]{labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedright}
\captionsetup[lstlisting]{labelfont=normalfont,textfont=bf,singlelinecheck=off,justification=raggedright}
% Fix spacing in the listing of the listings.
\makeatletter
\renewcommand*{\l@lstlisting}[2]{\@dottedtocline{1}{1.5em}{3.0em}{#1}{#2}}
\makeatother

% Here we are using the BibTeX key as the citation key.
% Notes:
% 1. sorting=debug is essential to maintain the alphabetic order in the bibliography.
% 2. In the Misc entries, make sure the author field is present, otherwise the
%    key will be [].
\usepackage[style=alphabetic,refsection=chapter,backend=biber,sorting=debug]{biblatex}

\DeclareFieldFormat{labelalpha}{\thefield{entrykey}}
\DeclareFieldFormat{extraalpha}{}

\addbibresource{Bibliography.bib}

% Make an index
\usepackage{makeidx}
\makeindex

\usepackage{url}
%% Load the hyperref package last.
\usepackage{hyperref}
\hypersetup{
    colorlinks = true,
    linkbordercolor = {White},
    urlcolor = {Blue},
    linkcolor = {Brown},
    citecolor = {BlueViolet}
}

% To ensure the links are clickable this package must load after hyperref.
\usepackage[toc,nonumberlist]{glossaries}
%\usepackage[toc]{glossaries}

%%% ----------------------------------------------------------------------
% Some general global declarations

% Use a bit more of the page.
\addtolength{\textwidth}{50pt}
\addtolength{\evensidemargin}{-25pt}
\addtolength{\oddsidemargin}{-25pt}

% Graphics paths and extensions.
\graphicspath{{Figures/}{Figures/Scraped/}{Figures/Headings/}}
% Prefer pdf over png.
\DeclareGraphicsExtensions{%
    .pdf,.PDF,%
    .png,.PNG,%
    .jpg,.mps,.jpeg,.jbig2,.jb2,.JPG,.JPEG,.JBIG2,.JB2}

%%% ----------------------------------------------------------------------
% Commands

% Put a ruled line above and below the chapter with
% Chapter <Number> on the right of the page.
\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%                                 % Insert 50pt (vertical) space
  {\parindent \z@ \raggedright \normalfont         % No paragraph indent, ragged right
    \ifnum \c@secnumdepth >\m@ne                   % If you should number chapters
      \if@mainmatter                               % ... and you're in \mainmatter
      \noindent\rule[6\p@]{\textwidth}{1\p@}       % Raise line 1pt thick by 6pt
      \rightline{
        \huge\bfseries \@chapapp\space \thechapter % huge, bold, Chapter + number
        }
        \noindent\rule{\textwidth}{1\p@}           % Line 1pt thick
        \par\nobreak                               % paragraph break without page break
        \vskip 20\p@                               % Insert 20pt (vertical) space
      \fi
    \fi
    \interlinepenalty\@M                           % Penalty
    \Huge \bfseries #1 \par\nobreak                 % Huge, bold chapter title
    \vskip 40\p@                                   % Insert 40pt (vertical) space
  }}
\makeatother

% Make a nice first letter in a paragraph.
\newcommand{\firstletter}[1] {\lettrine[lines=2, lraise=0.7]{\color{Sepia}\textit{#1}}}

%%% ----------------------------------------------------------------------

  % Horizontal spacing.
  % \, small space 3/18 quad.
  % \: medium space 4/18 quad.
  % \; large space 5/18 quad.
  % \! negative space -3/18 quad.
%%% ----------------------------------------------------------------------

