% Original Author: Johannes Demel
% Modified: Andreas Tsouchlos
%
% Template for theses authored at the Communications Engineering Lab (CEL).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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}}
\newcommand{\thesisCC}[1]{\def \theThesisCC{#1}}
\newcommand{\thesisPythonWatermark}[1]{\def \theThesisPythonWatermark{#1}}

%
% Defaults
%

\thesisTitle{Random Thesis Title}
\thesisType{Master 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}
\thesisCC{FALSE}
\thesisPythonWatermark{FALSE}

\def\dictThesisLanguageGerman{ngerman}
\def\dictThesisLanguageEnglish{english}
\def\dictThesisFALSE{FALSE}
\def\dictThesisTRUE{TRUE}


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


\usepackage[T1]{fontenc}  % encoding for target files.
\usepackage[utf8]{inputenc} % UTF-8 encoding for source files
\usepackage{lmodern}

\usepackage{microtype}
\usepackage[printonlyused]{acronym} % use this package for abbreviations!
\def\setlanguage{
    \usepackage[\theThesisLanguage]{babel}
    \ifx\theThesisLanguage\dictThesisLanguageEnglish
        %\bibliographystyle{alpha} % American Style
        \bibliographystyle{cel-thesis/IEEEtranSA_own} % modified IEEE alpha style that allows underlining of own publications
        \def\theUniversity{Karlsruhe Institute of Technology}
        \sisetup{%
            binary-units = true,
            output-decimal-marker={.}
        }
    \else
        %\bibliographystyle{alphadin} % DIN norm
        \bibliographystyle{cel-thesis/IEEEtranSA_own} % modified IEEE alpha style that allows underlining of own publications
        \def\theUniversity{Karlsruher Institut für Technologie}
        \sisetup{%
            binary-units = true,
        output-decimal-marker={,}
        }
        \mathcode`,="013B % avoid space in comma decimal numbers
    \fi
}

% Math and Symbols %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{amssymb, amsfonts, latexsym}
\usepackage{amsmath}
\usepackage[right]{eurosym}
\usepackage{siunitx}

% make bibliography appear in table of contents %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[nottoc]{tocbibind}

%% Define always missing math symbols. 
\DeclareMathOperator*{\argmin}{\arg\!\min}
\DeclareMathOperator*{\argmax}{\arg\!\max}
\DeclareMathOperator\sign{sign}



% Graphics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ueberschriften fett
%\setkomafont{sectioning}{\normalcolor\bfseries}
% Bild- und Tabellen-Unterschriften formatieren
\renewcommand{\caplabelfont}{\bfseries}
\renewcommand{\capfont}{\small}
\newcommand{\figref}[1]{\figurename~\ref{#1}}

\usepackage{graphicx}
\usepackage{color}
\usepackage{pgf, tikz, pgfplots}
\usetikzlibrary{shapes,arrows}
\pgfplotsset{compat=1.9}

% Layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{marginnote}
\RequirePackage{ifthen}
\RequirePackage[hidelinks, final=true]{hyperref}
\RequirePackage[ddmmyyyy]{datetime}
\renewcommand{\dateseparator}{.}
\RequirePackage[export]{adjustbox}


\setlength{\parskip}{5pt}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title Page and Optional Parts (e.g. CC Statement) %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
% Header
%

\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
%

\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}
}

%
% Misc
%

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

