%define new document type

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

% Define Roa Logic Colour Scheme
\usepackage[table]{xcolor}
\newcommand{\headlinecolor}{\normalcolor}
\definecolor{rlchapter}{HTML}{3D5986}
\definecolor{rlsection}{HTML}{5B80B8}
\definecolor{rltable}{HTML}{D5DFED}

% Load packages
\usepackage{graphicx,grffile} % Graphics support
\usepackage{geometry}
\usepackage{array}
\usepackage{xcolor}
\usepackage{placeins}
\usepackage{multirow}
\usepackage{float}
\usepackage[shadow]{todonotes}
\usepackage{lmodern} % Font Library
\usepackage{amssymb,amsmath} % Math Fonts
\usepackage{ifxetex,ifluatex}
\usepackage{longtable} % Long table supprot
\usepackage{vmargin} % Margin control
\usepackage{tabularx} % Table support
\usepackage{booktabs} % For \toprule, \midrule and \bottomrule
\usepackage{csvsimple} % Import CSV files
\usepackage{layout} % Show summary of page layout
\usepackage{hyperref} % Hyperlink support
\usepackage{titlesec} %Headings Styliser
\usepackage{fancyhdr} % Header & Footer control
\usepackage{comment}
\usepackage[olditem,oldenum]{paralist}
\usepackage{titling}

% Setup margins & page style

%\setlength{\topmargin}{-0.5in}
%\setlength{\textheight}{9in}
%\setlength{\oddsidemargin}{0in}
%\setlength{\evensidemargin}{0in}
%\setlength{\textwidth}{6.5in}

% Page Layout Control

% Hyperlink formatting
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=blue,
}

\urlstyle{same}

% Font & Colour control
\renewcommand{\familydefault}{\rmdefault}
\renewcommand{\headlinecolor}{\color{rlcolor}}


% Heading Formats
\titleformat{\chapter}
   {\normalfont\Huge\bfseries\color{rlchapter}\sffamily}{\thechapter.}{1em}{}[{\titlerule[0.8pt]}]

\titleformat{\section}
  {\color{rlsection}\sffamily\LARGE\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}
  {\color{rlsection}\sffamily\large\bfseries}{\thesubsection}{1em}{}

\titleformat{\subsubsection}
  {\color{rlsection}\sffamily\large\bfseries}{\thesubsubsection}{1em}{}

%\titlespacing*{\chapter}     {0pt}{1.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\chapter}      {0pt}{-50pt}{20pt}
\titlespacing*{\section}      {0pt}{1.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection}   {0pt}{1.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{1.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\paragraph}    {0pt}{1.25ex plus 1ex minus .2ex}{0.5em}
\titlespacing*{\subparagraph} {\parindent}{3.25ex plus 1ex minus .2ex}{0.5em}

\setlength{\headheight}{13.6pt} % Fix spurious build warnings

% Paragraph formatting
%\setlength{\parindent}{1em}
\setlength{\parskip}{0.5em}

% Long table formatting
% \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
% \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
% \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\usepackage{subfig}
\captionsetup{belowskip=0pt,aboveskip=7pt}

% Pad All Table Rows
% \renewcommand{\arraystretch}{1.2}


% Center all Floats (Figs & Tables)
\makeatletter
\g@addto@macro\@floatboxreset\centering
\makeatother

%
% Custom Commands
%

% Define ToDo Colours
\presetkeys{todonotes}{color=blue!30, backgroundcolor=white, bordercolor=black, figcolor=white}{}

% Commands for register format figures.

% New column types to use in tabular environment for instruction formats.
% Allocate 0.18in per bit.
\newcolumntype{I}{>{\centering\arraybackslash}p{0.18in}}
% Two-bit centered column.
\newcolumntype{W}{>{\centering\arraybackslash}p{0.36in}}
% Three-bit centered column.
\newcolumntype{F}{>{\centering\arraybackslash}p{0.54in}}
% Four-bit centered column.
\newcolumntype{Y}{>{\centering\arraybackslash}p{0.72in}}
% Five-bit centered column.
\newcolumntype{R}{>{\centering\arraybackslash}p{0.9in}}
% Six-bit centered column.
\newcolumntype{S}{>{\centering\arraybackslash}p{1.08in}}
% Seven-bit centered column.
\newcolumntype{O}{>{\centering\arraybackslash}p{1.26in}}
% Eight-bit centered column.
\newcolumntype{E}{>{\centering\arraybackslash}p{1.44in}}
% Ten-bit centered column.
\newcolumntype{T}{>{\centering\arraybackslash}p{1.8in}}
% Twelve-bit centered column.
\newcolumntype{M}{>{\centering\arraybackslash}p{2.2in}}
% Sixteen-bit centered column.
\newcolumntype{K}{>{\centering\arraybackslash}p{2.88in}}
% Twenty-bit centered column.
\newcolumntype{U}{>{\centering\arraybackslash}p{3.6in}}
% Twenty-bit centered column.
\newcolumntype{L}{>{\centering\arraybackslash}p{3.6in}}
% Twenty-five-bit centered column.
\newcolumntype{J}{>{\centering\arraybackslash}p{4in}} % RL Change

\newcommand{\instbit}[1]{\mbox{\scriptsize #1}}
\newcommand{\instbitrange}[2]{~\instbit{#1} \hfill \instbit{#2}~}
\newcommand{\reglabel}[1]{\hfill \texttt{#1}\hfill\ }

\newcommand{\wiri}{\textbf{WIRI}}
\newcommand{\wpri}{\textbf{WPRI}}
\newcommand{\wlrl}{\textbf{WLRL}}
\newcommand{\warl}{\textbf{WARL}}


