% Original Author: Johannes Demel
% Modified: Andreas Tsouchlos
%
% Template for theses authored at the Communications Engineering Lab (CEL).
%
% ||========================================================||
% ||                        WARNING                         ||
% ||========================================================||
% ||                                                        ||
% || This template already includes the following packages: ||
% ||      siunitx                                           ||
% ||      tocbibind                                         ||
% ||      datetime                                          ||
% ||      adjustbox                                         ||
% ||      hyperref                                          ||
% ||      xcolor                                            ||
% ||========================================================||


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% New Doctype Declaration %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cel-thesis/cel-thesis}

\LoadClass[11pt,	% 11pt
	    titlepage,
	    twoside,		% Doppelseitige Ausgabe
	    a4paper,		% DIN A4
	    openright,		% Neue Kapitel auf rechter Seite
%	    draft,		% Overfull H-Boxen markieren
	    final,		% Engueltige Version mit Bildern
]{scrreprt}

\areaset[8mm]{150mm}{225mm}
\RedeclareSectionCommand[beforeskip=0pt,]{chapter}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Variables %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
% New Commands
%

\newcommand{\thesisTitle}           [1] {\def \theThesisTitle           {#1}}
\newcommand{\thesisType}            [1] {\def \theThesisType            {#1}}
\newcommand{\thesisAuthor}          [1] {\def \theThesisAuthor          {#1}}
\newcommand{\thesisAdvisor}         [1] {\def \theThesisAdvisor         {#1}}
\newcommand{\thesisSupervisor}      [1] {\def \theThesisSupervisor      {#1}}
\newcommand{\thesisHeadOfInstitute} [1] {\def \theThesisHeadOfInstitute {#1}}
\newcommand{\thesisStartDate}       [1] {\def \theThesisStartDate       {#1}}
\newcommand{\thesisEndDate}         [1] {\def \theThesisEndDate         {#1}}
\newcommand{\thesisSignatureDate}   [1] {\def \theThesisSignatureDate   {#1}}
\newcommand{\thesisLanguage}        [1] {\def \theThesisLanguage        {#1}}

%
% Defaults
%

\thesisTitle          {Thesis Title}
\thesisType           {Thesis Type}
\thesisAuthor         {John Doe}
\thesisAdvisor        {Dr.-Ing. Holger J\"akel}
\thesisHeadOfInstitute{Prof. Dr.-Ing. Laurent Schmalen}
\thesisSupervisor     {Super-Assi Deluxe M.Sc.}
\thesisStartDate      {dd.mm.yyyy}
\thesisEndDate        {dd.mm.yyyy}
\thesisSignatureDate  {dd.mm.yyyy}
\thesisLanguage       {english}

\def\dictThesisLanguageGerman{ngerman}
\def\dictThesisLanguageEnglish{english}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% General %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
% Language Specific
%

\RequirePackage[binary-units]{siunitx}
\def\setlanguage{
    % modified IEEE alpha style that allows underlining of own publications
    \bibliographystyle{cel-thesis/IEEEtranSA_own}

    \ifx\theThesisLanguage\dictThesisLanguageEnglish
        \def\theUniversity{Karlsruhe Institute of Technology}
        \sisetup{output-decimal-marker={.}}
    \else
        \def\theUniversity{Karlsruher Institut für Technologie}
        \sisetup{output-decimal-marker={,}}
        \mathcode`,="013B % avoid space in comma decimal numbers
    \fi
}

%
% Corporate Design Colors
%

\RequirePackage{xcolor}
\definecolor{KITgreen}{rgb}{0,.59,.51}
\definecolor{KITblack}{rgb}{0,0,0}
\definecolor{KITblue}{rgb}{.27,.39,.66}
\definecolor{KITred}{rgb}{.63,.13,.13}
\definecolor{KITpurple}{rgb}{.64,.06,.48}
\definecolor{KITcyan}{rgb}{.14,.63,.87}

\definecolor{KITyellow}{rgb}{.98,.89,0}
\definecolor{KITorange}{rgb}{.87,.60,.10}

%
% Misc
%

\RequirePackage[nottoc]{tocbibind} % Make bibliography appear in table of contents

\RequirePackage[ddmmyyyy]{datetime}
\renewcommand{\dateseparator}{.}

\setlength{\parskip}{5pt}

%\setkomafont{sectioning}{\normalcolor\bfseries}
\renewcommand{\caplabelfont}{\bfseries}
\renewcommand{\capfont}{\small}
\newcommand{\figref}[1]{\figurename~\ref{#1}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title Page and Optional Parts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
% Header
%

\RequirePackage[export]{adjustbox} % Needed for "valign" used below
\newcommand{\header}{%
    \begin{tabular*}{1.0\linewidth}[c]{lcr}
        \includegraphics[height=18mm,valign=c]{cel-thesis/logos/kitlogo_de_rgb}%
        &%
        \begin{minipage}{8cm}\centering%
            \textbf{\theUniversity}        \\
            Communications Engineering Lab \\
            \theThesisHeadOfInstitute%
        \end{minipage}%
        &% 
        \includegraphics[height=18mm,valign=c]{cel-thesis/logos/cel_logo}%
    \end{tabular*}
}

%
% Title
%

\RequirePackage[hidelinks, final=true]{hyperref} % Needed for "hypersetup" used below
\def\maketitle{
    \hypersetup{
        pdfauthor = \theThesisAuthor,
        pdftitle = {\theThesisType{ }\theThesisTitle{ } \theThesisAuthor},
        pdfsubject = {Institut für Nachrichtentechnik (CEL)},
    }

    \thispagestyle{empty}
    \header  % institute banner, etc.
    \vspace*{5.0cm}%
%
    \begin{center}
        {\Large \textbf{\theThesisTitle}} \\[1cm]
        {\large \theThesisType}           \\[2.5cm]
        {\textbf{\theThesisAuthor}}       \\[5cm]

        \begin{tabular}{lll}
            \ifx\theThesisLanguage\dictThesisLanguageEnglish
                Advisor       & : & \theThesisAdvisor    \\
                Supervisor 	  & : & \theThesisSupervisor \\[2cm]
                Start date 	  & : & \theThesisStartDate  \\
                End date      & : & \theThesisEndDate    \\
            \else
                Hauptreferent & : & \theThesisAdvisor    \\
                Betreuer      & : & \theThesisSupervisor \\[2cm]
                Beginn        & : & \theThesisStartDate  \\
                Abgabe        & : & \theThesisEndDate    \\
            \fi
        \end{tabular}
    \end{center}
    \hspace*{\fill}
}

%
% Statutory Declaration
%

\def\makestatutorydeclaration{
    \include{cel-thesis/eidesstattliche_erklaerung}
}

\def\makeCCdeclaration{
    \include{cel-thesis/creative_commons}
}

%
% Misc
%

\newcommand{\ssection}[1]{\vspace*{0.8em}{\textbf{#1}}\\}

