%% -----------------------------------------------------------------------------
%% Major Revision & Modernization: Lamprinos Chatziioannou
%% Substantially refactored, restyled, and adapted for my engineering thesis.
%% NOTE: Don't forget to set \addbibresource
%%
%% Attribution & Lineage:
%% - Major overhaul & thesis adaptation: Lamprinos Chatziioannou
%% - Prior modifications: Sunil Patel (www.sunilpatel.co.uk)
%% - Original author: Steve R. Gunn (based on `ECSthesis.cls`, generated with docstrip)
%% -----------------------------------------------------------------------------
%% Available options: (preamble - They all need to be set)
%% \titlegreek
%% \authors
%% \university
%% \department
%% \faculty
%% \degree
%% \supervisor
%% \universitylogo
%% \universitygreek
%% \facultygreek
%% \departmentgreek
%% \authorsgreek
%% -----------------------------------------------------------------------------
%% Available environments (preamble)
%% abstract
%% abstractgreek
%% dedicatory (command, not environment)
%% -----------------------------------------------------------------------------

\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{Thesis} [2007/22/02 v1.0 LaTeX document class]


\def\baseclass{book}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\baseclass}}
\def\@checkoptions#1#2{
  \edef\@curroptions{\@ptionlist{\@currname.\@currext}}
  \@tempswafalse
  \@tfor\@this:=#2\do{
    \@expandtwoargs\in@{,\@this,}{,\@curroptions,}
    \ifin@ \@tempswatrue \@break@tfor \fi}
  \let\@this\@empty
  \if@tempswa \else \PassOptionsToClass{#1}{\baseclass}\fi
}

\@checkoptions{11pt}{{10pt}{11pt}{12pt}}
\PassOptionsToClass{a4paper}{\baseclass}
\ProcessOptions\relax
\LoadClass{\baseclass}
\newcommand\bhrule{\typeout{------------------------------------------------------------------------------}}

\usepackage{setspace}
\usepackage{graphicx}
\usepackage[table,xcdraw]{xcolor} % addition was made for tables (?)
\definecolor{coolblue}{RGB}{19,64,140}
\usepackage{xurl} % break down links
\usepackage[ bookmarks=true, colorlinks, linkcolor={coolblue}, citecolor={coolblue},
urlcolor={coolblue}, breaklinks=true]{hyperref}
\newcommand\btypeout[1]{\bhrule\typeout{\space #1}\bhrule}

\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}

\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\dbltopfraction}{.85}
\renewcommand{\floatpagefraction}{0.75}
\renewcommand{\dblfloatpagefraction}{.75}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Thesis variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand*{\examiner}[1]{\def\examname{#1}\def\EXAMNAME{\uppercase{#1}}}
\newcommand*{\degree}[1]{\def\degreename{#1}\def\DEGREENAME{\uppercase{#1}}}
\newcommand*{\authors}[1]{\def\authornames{#1}\def\AUTHORNAMES{\uppercase{#1}}}
\newcommand*{\addresses}[1]{\def\addressnames{#1}\def\ADDRESSNAMES{\uppercase{#1}}}
\newcommand*{\university}[1]{\def\univname{#1}\def\UNIVNAME{\uppercase{#1}}}
\newcommand*{\department}[1]{\def\deptname{#1}\def\DEPTNAME{\uppercase{#1}}}
\newcommand*{\group}[1]{\def\groupname{#1}\def\GROUPNAME{\uppercase{#1}}}
\newcommand*{\faculty}[1]{\def\facname{#1}\def\FACNAME{\uppercase{#1}}}
\newcommand*{\subject}[1]{\def\subjectname{#1}\def\SUBJECTNAME{\uppercase{#1}}}
\newcommand*{\keywords}[1]{\def\keywordnames{#1}\def\KEYWORDNAMES{\uppercase{#1}}}
\newcommand*{\supervisor}[1]{\def\supname{#1}\def\SUPNAME{\uppercase{#1}}}
\newcommand*{\universitylogo}[1]{\def\unilogo{#1}}

\newcommand*{\universitygreek}[1]{\def\univnamegreek{#1}}
\newcommand*{\facultygreek}[1]{\def\facnamegreek{#1}}
\newcommand*{\departmentgreek}[1]{\def\deptnamegreek{#1}}
\newcommand*{\degreegreek}[1]{\def\degreenamegreek{#1}}
\newcommand*{\authorsgreek}[1]{\def\authornamesgreek{#1}}
\newcommand*{\titlegreek}[1]{\def\titlegreekname{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Thesis variables - setting values
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\addresses   {}
\subject     {}
\keywords    {}
\examiner    {}
\degree      {}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Thesis Environments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\Declaration[1]{
\btypeout{Declaration of Authorship}
\addtotoc{Declaration of Authorship}
\thispagestyle{plain}
\null\vfil
\vskip 60\p@
\begin{center}{\huge\bf Declaration of Authorship\par}\end{center}
\vskip 60\p@
{\normalsize #1}
\vfil\vfil\null
\cleardoublepage
}

\renewcommand\maketitle{
  \btypeout{Title Page}
  \hypersetup{pdftitle={\@title}}
  \hypersetup{pdfsubject=\subjectname}
  \hypersetup{pdfauthor=\authornames}
  \hypersetup{pdfkeywords=\keywordnames}
  \thispagestyle{empty}
  \begin{titlepage}
  \singlespacing
    \phantomsection
    \addcontentsline{toc}{chapter}{Title Page}
    \let\footnotesize\small
    \let\footnoterule\relax
    \let \footnote \thanks
    \setcounter{footnote}{0}
    \null\vfil
    \vskip 60\p@
    \begin{center}
        \begin{center}
        \includegraphics[scale=0.5]{\unilogo}
        \end{center}
      \bigskip
      {\large\textbf{\UNIVNAME}\par}
      \smallskip
      {\huge \bf \@title \par}
      \vfill
     {\LARGE by \par}
     \smallskip
     {\LARGE \authornames \par}
     \vfill
     {\large A thesis submitted in partial fulfillment for the \par}
     {\large Undergraduate degree \par}
     \bigskip
     \bigskip
     {\large in the \par}
     {\large \facname \par}
     {\large \deptname \par}
     \bigskip
     \bigskip
     {\large \supname \par}
      \bigskip
      \bigskip
      \bigskip
      \bigskip
      {\Large \@date \par}
    \end{center}
    \par
    \@thanks
    \vfil\null
  \end{titlepage}
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
  \cleardoublepage
}
\newenvironment{abstract}[1]
{
  \cleardoublepage
  \thispagestyle{empty}
  \phantomsection
  \addcontentsline{toc}{chapter}{#1}
  \btypeout{Abstract Page}
  \begin{center}
    {\normalsize \UNIVNAME \par}
    \bigskip
    {\huge{\textit{#1}} \par}
    \bigskip
    {\normalsize \facname \par}
    {\normalsize \deptname \par}
    \bigskip
    % {\normalsize \degreename\par}
    % \bigskip
    {\normalsize\bf \@title \par}
    \medskip
    {\normalsize by \authornames \par}
    \bigskip
  \end{center}
  \par\nobreak
}
{
  \vfil\null
  \cleardoublepage
}

\newenvironment{abstractgreek}[1]
{
  \cleardoublepage
  \thispagestyle{empty}
  \phantomsection
  \addcontentsline{toc}{chapter}{#1}
  \btypeout{Abstract Page}
  \begin{center}
    {\normalsize \univnamegreek \par}
    \bigskip
    {\huge{\textit{#1}} \par}
    \bigskip
    {\normalsize \facnamegreek \par}
    {\normalsize \deptnamegreek \par}
    % \bigskip
    % {\normalsize \degreenamegreek \par}
    \bigskip
    {\normalsize\bf \titlegreekname \par}
    \medskip
    % {\normalsize από τον \authornamesgreek \par}
    % \bigskip
  \end{center}
  \par\nobreak
}
{
  \vfil\null
  \cleardoublepage
}
\newcommand*{\acknowledgements}[1]{%
  \cleardoublepage
  \thispagestyle{plain}%
  \typeout{Acknowledgements}%
  \phantomsection%
  \addcontentsline{toc}{chapter}{Acknowledgements}%
  \begin{center}\huge\itshape Acknowledgements\par\end{center}%
  \normalsize #1\par
  \vfill
}

\newcommand*{\dedicatory}[1]{%
  \cleardoublepage
  \thispagestyle{plain}%
  \null\vfill
  \begin{center}\slshape #1\end{center}%
  \vfill\null
  \cleardoublepage
}

% Now this is possibly redundant
\renewcommand\backmatter{
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \@mainmatterfalse}

%% PREAMBLE
\usepackage{amsmath,amssymb}
\usepackage[centerlast,small,sc]{caption}
\setlength{\captionmargin}{10pt}

\usepackage{fontspec}
\setmainfont{Tinos}
\setmonofont{RobotoMono Nerd Font}[Scale = 0.85]
\newfontfamily\greekfont{Tinos}
\newfontfamily\greekfonttt{RobotoMono Nerd Font}

\usepackage{geometry}
\geometry{
  left=2.5cm,
  right=2.5cm,
  top=1.75cm,
  bottom=1.75cm,
  includeheadfoot
}

\onehalfspacing

\usepackage{fancyhdr}
\setlength{\headheight}{15pt}
\lhead[\thepage]{\rightmark}
\rhead[\leftmark]{\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}

\usepackage[backend=biber, style=numeric, sorting=ynt]{biblatex}

\usepackage[toc,acronym]{glossaries}
\makeglossaries

\endinput
%%
%% End of file `Thesis.cls'.
