\NeedsTeXFormat{LaTeX2e} % specify required latex format
\ProvidesPackage{masterthesis}[2019/01/03 Masterthesis Package]

% define licence option to include a licence statement
\newif\if@uselicence\@uselicencefalse
\DeclareOption{licence}{%
    \@uselicencetrue
}

% define acknowledge option to include an acknowledgement
\newif\if@acknowledge\@acknowledgefalse
\DeclareOption{acknowledge}{%
    \@acknowledgetrue
}

% define abstract option to include an acknowledgement
\newif\if@abstract\@abstractfalse
\DeclareOption{abstract}{%
    \@abstracttrue
}

\newif\if@library\@libraryfalse
\DeclareOption{library}{%
    \@librarytrue
}

\ProcessOptions\relax

% load packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % euro quality fonts [T1] (togeth. w/ textcomp)
\usepackage{textcomp, amssymb}  % additional symbols (there are more packages)
\usepackage[all]{xy} % creating figures within latex
\usepackage[tight]{subfigure} % figures within figures
\usepackage{ifpdf}

% load biblatex
\usepackage[
    backend=biber,
    bibstyle=ieee,
    citestyle=ieee,
    backref=true,
    minnames=1,
    maxnames=2,
]{biblatex}

% check if pdflatex is used
\ifpdf
    \usepackage[pdftex]{graphicx}
    \usepackage[pdftex]{color}
    \usepackage[pdftex]{thumbpdf}
    \usepackage[pdftex,
		hidelinks = true,
		colorlinks = false,%
              %pagebackref=true, % bibliography -> text
              linktocpage=true, % toc etc: make page number active (not name)
              plainpages=false, % distinguish roman and arabic pagenumbers
              bookmarksopen=true,%
              bookmarksnumbered=true,%
              pdfauthor={\@author},%
              pdftitle={\@title},%
              pdfsubject={\@subject},%
              pdfkeywords={\keywords},%
             ]{hyperref}       % clickabe references
\else
    \usepackage[hypertex,
          plainpages=false, % distinguish roman and arabic pagenumbers
          linktocpage=true, % toc etc: make page number active (not name)
         ]{hyperref}        % clickabe references in .dvi
                            % purposely included before color package
    \usepackage[dvips]{color}     % color package, required by xy
    \usepackage[dvips]{graphicx}  % graphics package
\fi

\usepackage{xcolor}

%%% load further packages
\usepackage{listings}

% simplify quoting
\usepackage{csquotes}
\MakeOuterQuote{"}

% support both german and english
\usepackage[ngerman,english]{babel}
\selectlanguage{english}

\KOMAoption{toc}{bibliography, index, listof}

\usepackage{makeidx}
\makeindex

\usepackage[xindy]{glossaries} % for \printglossary
\makeglossaries

%%% define commands
\newcommand{\start}{%
    \maketitle

    \if@uselicence
        \input{licence.tex}
    \else\fi

    \if@acknowledge
        \input{acknowledge.tex}
    \else\fi

    \if@abstract
        \input{abstract.tex}
    \else\fi

    \tableofcontents
}


\newcommand{\finish}{%
    %\clearpage
    \printbibliography[heading=bibintoc]

    %\clearpage
    \printglossary

    %\clearpage
    \printindex

    \clearpage
    \input{declaration.tex}

    \if@library
        \clearpage
        \input{library.tex}
    \else\fi
}
