\documentclass[11pt,a4paper,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\geometry{bindingoffset=1.5cm} % Force larger margin next to binding
\usepackage{natbib}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[colorlinks=true,linkcolor=black,citecolor=black,urlcolor=black]{hyperref}
\usepackage{epstopdf}
\usepackage{setspace}
\usepackage{listings}
\usepackage{color}
\usepackage{epstopdf}
\onehalfspacing
%% YOU SHOULDN'T NEED TO MODIFY THE TEXT ABOVE THIS POINT - IT SPECIFIES A FORMAT THAT MATCHES THE UNIVERSITY OF ABERDEEN MSc THESIS REGULATIONS

%% MACROS
\newcommand{\mathbi}[1]{\boldsymbol{ #1 }}
\newcommand{\fracp}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\fracd}[2]{\frac{\mathrm{d} #1}{\mathrm{d} #2}}
\newcommand{\fracD}[2]{\frac{D #1}{D #2}}
\renewcommand{\d}[1]{\mathrm{d} #1}

\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}


%% THESE OPTIONS AUTOMATICALLY FORMAT COMPUTER CODE, SHOULD YOU WANT TO INCLUDE CODE IN YOUR DISSERTATION.
\lstset{ %
  backgroundcolor=\color{white},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
  basicstyle=\ttfamily\footnotesize,        % the size of the fonts that are used for the code
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % sets automatic line breaking
  captionpos=b,                    % sets the caption-position to bottom
  commentstyle=\color{mygreen},    % comment style
  deletekeywords={...},            % if you want to delete keywords from the given language
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  frame=single,	                   % adds a frame around the code
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  keywordstyle=\color{blue},       % keyword style
  language=Octave,                 % the language of the code
  morekeywords={*,...},           % if you want to add more keywords to the set
  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
  numbersep=5pt,                   % how far the line-numbers are from the code
  numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % underline spaces within strings only
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=1,                    % the step between two line-numbers. If it's 1, each line will be numbered
  stringstyle=\color{mymauve},     % string literal style
  tabsize=2,	                   % sets default tabsize to 2 spaces
  title=\lstname                   % show the filename of files included with \lstinputlisting; also try caption instead of title
}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% DOCUMENT STARTS HERE
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
 
%%%%%%%%%%%%%%%%%%%%%%%%%%
% This generates the title page
%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{titlepage}
 \begin{center}
  ~\vspace{2cm} \\
  \includegraphics[width=7cm]{figures/UoA_Stacked_Logo_RGB} \\
  \vspace{2cm}  
  \Huge{Title} \\
  \vspace{2cm}
  \Large{EG59XX Individual Project in XXX Engineering} \\
  \vspace{1cm}
  By \\
  \vspace{1cm}
  \large{Morgiane, Ph.D., M.Eng. etc.} \\
  STUDENT NUMBER \\
  \vspace{1.5cm}
  \textit{A dissertation submitted in partial fulfilment of the requirements of the award of Master of Science in XXX Engineering at the University of Aberdeen} \\
  \vspace{1cm}
  (Month, year) \\
  \vspace{1cm}
  ~
 \end{center}
\end{titlepage}
\pagenumbering{roman} 
  
\addcontentsline{toc}{chapter}{Abstract} % Add abstract to table of contents
\begin{abstract}
\thispagestyle{plain} % Add page number to abstract
\setcounter{page}{2}
In this dissertation, I will discuss most efficient ways of teaching \LaTeX to PGTs students.
\end{abstract}  


% Table of contents
\tableofcontents

% Table of figures
\listoffigures

% Table of tables
\listoftables

\cleardoublepage

%%%%%%%%%%%%%%%%%%
% Here start the chapters, sections and subsections
%%%%%%%%%%%%%%%%%%

\chapter{Introduction}
This chapter introduces the topic ....

\section{Text in bold}

\subsection{Example of subsection}

\textbf{Hello world!}

\section{Text in Italic}

\textit{Hello world!}

\section{Text in color}

\textcolor{cyan}{Hello world!}

\begin{itemize}
\item \textcolor{red}{\textit{Formatting text with Latex}};
\item \textcolor{blue}{\textbf{Trying a few commands}}
\end{itemize}

\chapter{Figures and Tables}

\section{Figures}

Figure~\ref{fig:fig2} was borrowed from MathCentre and Table~\ref{tab:staff} was created after the SMSN website. % here goes the cross-referencing

%The figures:
%The option \centering centers the figure
\begin{figure}[h]
\centering\includegraphics[width = 3cm]{figures/figure1}
\caption{Scottish Maths Support Network Logo\label{fig:fig1}}
\end{figure}

\begin{figure}[h]
\centering\includegraphics[scale=0.3]{figures/figure2}
\caption{Creative Common Symbol\label{fig:fig2}}
\end{figure}

\section{Table}
%The table:
\begin{table}[h]
\centering
\begin{tabular}{l l l}
 Surname & Name & Role\\
\hline
Macdonald & Callum & Chair \\
Durkacz & Kate & Treasurer \\
Ahmed & Shazia & Secretary \\
Davidson & Peter & Committee Member \\
Richard & Morgiane & Committee Member
\end{tabular}
\caption{Members of the SMSN committee\label{tab:staff}} % this is the caption with label
\end{table}

\chapter{Mathematics Examples}

\section{Displayed Maths}
The equation:
\[
ax^2+bx+c=0
\]

\section{Inline Maths}
%Example of inline maths
has 2 solutions \( x_1 = \frac{-b + \sqrt{b^2-4\cdot a\cdot c}}{2a}\) and \(x_2 = \frac{-b - \sqrt{b^2-4\cdot a\cdot c}}{2a}\).

\section{Systems of Equations}

%Using cross-referencing with equations
The following equations:
\begin{align}
\frac{dy}{dx} + 3y &= e^x \label{ODE1}\\
\frac{d^2y}{dx^2} + 5\frac{dy}{dx} +2y & =(x-1)^2 \label{ODE2}
\end{align}

are ordinary differential equations. Equation~\ref{ODE1} is an ODE of the first order and Equation~\ref{ODE2} is an ODE of the second order.

\section{Matrices}

The matrix of following system of equations:

%Examples of system of equation with curly bracket on the left only
%The system must be written in an array (\begin{array} environment)
%The curly bracket is written as \left\{ and must be finished by a \right. at the end
\[
\left\{
\begin{array}{l l}
x-3y+4z &= 5\\
2x + y + z &=3 \\
4x+3y+5z &=1\\ 
\end{array}
\right.
\]

is:

\[
\begin{pmatrix}
1 & -3 & 4 \\
2 & 1 & 1 \\
4 & 3 & 5
\end{pmatrix}
\]

The identity matrix, in any dimension, has the form:

\[
\begin{pmatrix}
1 & 0 & \dots & 0 \\
0 & 1 & \dots & 0\\
\vdots & \vdots & \ddots & \vdots \\
0 & \dots & \dots & 1
\end{pmatrix}
\]

\chapter{Conclusions}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% APPENDIX
%%%%%%%%%%%%%%%%%%%%%%%%%%
\appendix
\chapter{Matlab code}
Description of Matlab code

%%%%%%%%%%%%%%%%%%%%%%%%%%
% SECTION
%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Matlab code to solve differential equation}

\begin{lstlisting}[language=Matlab]
N = 10;                    % Number of grid points
x = linspace(0,0.5*pi,N);  % Setup the x grid
dx = x(2) - x(1);          % Set Delta x on a uniform grid Set Delta x on a uniform grid Set Delta x on a uniform grid Set Delta x on a uniform grid

y = zeros(N,1);   % Pre-allocate the solution vector
y(1) = exp(-1);   % Set the initial condition

for i = 1:N-1  % Loop over each point in the grid
  xhalf = 0.5*(x(i) + x(i+1));
  yhalf = y(i) + 0.5*dx*y(i)*sin(x(i));
  y(i+1) = y(i) + dx*yhalf*sin(xhalf);
end
\end{lstlisting}

\end{document}