% ------------------------------------------------------------------------------------
% ----Präambel/Preamble---------------------------------------------------------------
% ------------------------------------------------------------------------------------

\documentclass[a4paper,
11pt,
DIV=11,
headings=big,
index=totoc,
listof=totoc,
bibliography=totoc,
parskip=half,
cleardoublepage=empty,
oneside,
openright]{scrartcl}
% ------------------------------------------------------------------------------------

\usepackage[UKenglish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{kpfonts}
\usepackage[font=footnotesize]{caption}
\usepackage[outputdir=auto]{minted}
\usepackage[framemethod=tikz]{mdframed}

\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}
\newcommand{\xmark}{\ding{55}}

\BeforeBeginEnvironment{minted}{\begin{mdframed}}
  \AfterEndEnvironment{minted}{\end{mdframed}}
\usepackage{booktabs}
% \usepackage{tabularx}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\usepackage{array}
\newcolumntype{?}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}
\newcommand{\centered}[1]{\begin{tabular}{@{}c@{\hskip 0.13cm}l@{}} #1 \end{tabular}}
% \usepackage{mathpazo}

% verbesserter Randausgleich
\usepackage{microtype}

\usepackage{graphicx}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{subfigure}

\usepackage{geometry}						% Für newgeometry in Titelseite
\geometry{a4paper,left=30mm,right=20mm}

% Hyperref loads url internally therefore we pass the option hyphens to url without loading it manually
\PassOptionsToPackage{hyphens}{url}
\usepackage[pdfborder={0 0 0},
colorlinks=true,
linkcolor=black,
citecolor=red,
]{hyperref}

% Citation
\usepackage[style=numeric, natbib=true]{biblatex}
\addbibresource{ref_shelf.bib}

\usepackage{pdfpages}

\usepackage{xcolor}

\usepackage{setspace}

\usepackage{longtable}
\usepackage{multirow}
\usepackage{colortbl}

\usepackage{mathtools}

% ----Kopfzeile-----------------------------------------------------------------------
\usepackage{scrlayer-scrpage} 							% Aufruf KOMA-Skript für Kopfzeilen
% ----Separator Header/Footer---------------------------------------------------------
\KOMAoptions{headsepline=true, footsepline=true}

\pagestyle{scrheadings}						% Definition der Eigenen Headerformatierung
\clearscrheadfoot 								% alle Standard-Werte und Formatierungen raus
% \automark[chapter]{section}						% Kapitel und Section als Inhalt der Variablen leftmark und rightmark
\ohead{\pagemark}								% Seitenzahl auf äußerem Rand
% \ihead{\Ifthispageodd{\leftmark}{\rightmark}} 	% Innere Überschrift mit Kapitel bei linker Seite und Section bei rechter Seite -> geht nur in Verbindung mit
% zweiseitigem Text wirklich sinnvoll
\setkomafont{pagehead}{\scshape}				% Schriftart in Kopfzeile, \scshape = Kapitelchen
% ----Fußzeile------------------------------------------------------------------------
\setkomafont{pagefoot}{\scshape}				% Schriftart in Fußfzeile, \scshape = Kapitelchen
\ifoot{\footnotesize{Philip Gaber}}
\ofoot{\footnotesize{Bachelor Thesis}}
% ------------------------------------------------------------------------------------


% ----Farbdefinition--THI-Blau--------------------------------------------------------
\definecolor{thi_blue}{RGB}{2,91,156}
\addtokomafont{section}{\color{thi_blue} \rmfamily \scshape}
\addtokomafont{subsection}{\color{thi_blue} \rmfamily}
\addtokomafont{subsubsection}{\color{thi_blue} \rmfamily}
\addtokomafont{paragraph}{\color{thi_blue} \rmfamily}
\addtokomafont{subparagraph}{\rmfamily}
% ------------------------------------------------------------------------------------

\definecolor{tab_2}{RGB}{230,230,230}
\definecolor{tab_1}{RGB}{85,128,214}

% ------Längenanpassung---------------------------------------------------------------
\setlength{\headsep}{10mm}						% Textabstand zur Kopfzeile
\setlength{\footskip}{15mm}						% Abstand zur Fußzeile
\setlength{\textheight}{235mm}					% Texthöhe
% ------------------------------------------------------------------------------------

% Fix for mdtheorem separator: https://tex.stackexchange.com/a/179794/226500
\makeatletter
\DeclareDocumentCommand{\mdtheorem}{ O{} m o m o }%
{\ifcsdef{#2}%
  {\mdf@PackageWarning{Environment #2 already exits\MessageBreak}}%
  {%
    \IfNoValueTF {#3}%
    {%#3 not given -- number relationship
      \IfNoValueTF {#5}%
      {%#3+#5 not given
        \@definecounter{#2}%
        \expandafter\xdef\csname the#2\endcsname{\@thmcounter{#2}}%
        \newenvironment{#2}[1][]{%
          \refstepcounter{#2}%
          \ifstrempty{##1}%
          {\let\@temptitle\relax}%
          {%
            \def\@temptitle{\mdf@theoremseparator%
              \mdf@theoremspace%
              \mdf@theoremtitlefont%
              ##1}%
            \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
          }%
          \begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
              \@temptitle}]}%
          {\end{mdframed}}%
        \newenvironment{#2*}[1][]{%
          \ifstrempty{##1}{\let\@temptitle\relax}{\def\@temptitle{\mdf@theoremseparator\ ##1}}% <- the problem was here
          \begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
          {\end{mdframed}}%
      }%
      {%#5 given -- reset counter
        \@definecounter{#2}\@newctr{#2}[#5]%
        \expandafter\xdef\csname the#2\endcsname{\@thmcounter{#2}}%
        \expandafter\xdef\csname the#2\endcsname{%
          \expandafter\noexpand\csname the#5\endcsname \@thmcountersep%
          \@thmcounter{#2}}%
        \newenvironment{#2}[1][]{%
          \refstepcounter{#2}%
          \ifstrempty{##1}%
          {\let\@temptitle\relax}%
          {%
            \def\@temptitle{\mdf@theoremseparator%
              \mdf@theoremspace%
              \mdf@theoremtitlefont%
              ##1}%
            \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
          }
          \begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
              \@temptitle}]}%
          {\end{mdframed}}%
        \newenvironment{#2*}[1][]{%
          \ifstrempty{##1}%
          {\let\@temptitle\relax}%
          {%
            \def\@temptitle{\mdf@theoremseparator%
              \mdf@theoremspace%
              \mdf@theoremtitlefont%
              ##1}%
            \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
          }%
          \begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
          {\end{mdframed}}%
      }%
    }%
    {%#3 given -- number relationship
      \global\@namedef{the#2}{\@nameuse{the#3}}%
      \newenvironment{#2}[1][]{%
        \refstepcounter{#3}%
        \ifstrempty{##1}%
        {\let\@temptitle\relax}%
        {%
          \def\@temptitle{\mdf@theoremseparator%
            \mdf@theoremspace%
            \mdf@theoremtitlefont%
            ##1}%
          \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
        }
        \begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
            \@temptitle}]}%
        {\end{mdframed}}%
      \newenvironment{#2*}[1][]{%
        \ifstrempty{##1}{\let\@temptitle\relax}{\def\@temptitle{:\ ##1}}%
        \begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
        {\end{mdframed}}%
    }%
  }%
}
\makeanother

\mdfdefinestyle{phga_sum}{
  skipabove = 20pt,
  skipbelow = 20pt,
  linecolor=thi_blue,
  frametitlebackgroundcolor=thi_blue!8,
  backgroundcolor=thi_blue!8,
  linewidth=1.9pt,
  leftline=false,
  rightline=false,
  bottomline=false,
}
\mdtheorem[style=phga_sum]{phga_sum}{Relevance for this Thesis}


\mdfdefinestyle{phga_hyp}{
  skipabove = 20pt,
  skipbelow = 20pt,
  linecolor=thi_blue,
  frametitlebackgroundcolor=thi_blue!8,
  backgroundcolor=thi_blue!8,
  backgroud=thi_blue!8,
  linewidth=1.9pt,
  leftline=false,
  rightline=false,
  bottomline=false,
  theoremseparator={ },
}

\mdtheorem[style=phga_hyp]{phga_hyp}{Hypothesis}

% ----Glossar-------------------------------------------------------------------------
\usepackage[toc,acronym,nonumberlist,nogroupskip]{glossaries}
\makeglossaries
\include{glossary}
% ------------------------------------------------------------------------------------

% \includeonly{
% glossary,
% mainpart,
% 	% fazit,
% appendices
% }


%   ------------------------------------------------------------------------------------
%   ----------------DOKUMENT-BEGINN-----------------------------------------------------
%   ------------------------------------------------------------------------------------

\begin{document}

% ----Vermeidung von Hurenkindern und Schusterjungen---------------------
\widowpenalty=10000
\clubpenalty=10000
\displaywidowpenalty=10000
% -----------------------------------------------------------------------

% Titelseite/title page
\include{titlepage}					% include erzeugt immer eine neue Seite bei jedem Einbinden
\cleardoublepage						% include always creates a new page

\pagenumbering{Roman} 			% Römische Nummerierung der Kapitel/roman page numbering

% Erklärung
\include{affidavit}
\cleardoublepage

% Danksagung
\include{acknowledgments}
\cleardoublepage

% Kurfassung/Abstract German (only for thesis written in German)
\include{abstractDE}
\cleardoublepage

% Kurzfassung/Abstract Englisch (for every thesis)
\include{abstractEN}
\cleardoublepage

% Sperrvermerk/Confidentiality clause (if any)
% \include{confidentialityClause}
% \cleardoublepage

% Inhaltsverzeichnis
\renewcommand{\contentsname}{Table of contents} % Remove for German thesis
\tableofcontents
\cleardoublepage
\singlespacing

% --------------------------------------------------------------------------------
% ------Ausarbeitung--------------------------------------------------------------
% --------------------------------------------------------------------------------
% Arabische Nummerierung der Kapitel/Arabic page numbering
\pagenumbering{arabic}
\include{mainpart}

% --------------------------------------------------------------------------------
% -----Anhang---------------------------------------------------------------------
% --------------------------------------------------------------------------------

\pagenumbering{Roman} % Römische Nummerierung der Kapitel/Roman page numbering
\setcounter{page}{1}  % Beginn bei Seitenzahl X (hier: 6) um bei oberer Nummerierung aufzuschließen/Adapt page numbering

% Glossar/Glossary
\glssetwidest{A D A S}	% gleicher Abstand zur 2. Spalte (längstes Wort)
% \setglossarystyle{alttree}
% \glsaddall
\printglossaries
\cleardoublepage

% Abbildungsverzeichnis/List of figures
\renewcommand*\listfigurename{List of figures} % Remove for German thesis
\listoffigures
\cleardoublepage

% Tabellenverzeichnis/List of tables
\renewcommand*\listtablename{List of tables} % Remove for German thesis
\listoftables
\cleardoublepage

% Literaturliste/Literature references
% \bibliographystyle{abbrvdin}			% DIN-Norm für Literaturdarstellung  plaindin
\renewcommand{\refname}{Literature references} % Remove for German thesis
\printbibliography
\cleardoublepage

% Anhänge/Appendices
\include{appendices}
\cleardoublepage

% ------------------------------------------------------------------------------------
% ----------------DOKUMENTENENDE - END OF DOCUMENT------------------------------------
% ------------------------------------------------------------------------------------

\end{document}