% !TeX root = ./Thesis.tex

\graphicspath{{./Graphics/}}

% need to pass languages explicitly
\PassOptionsToPackage{capitalize, noabbrev, ngerman, english}{cleveref}
\usepackage{cleveref}
\usepackage{datetime} % for formating submission date
\usepackage{lipsum}   % for template text


% include Git commit hash when drafting
\makeatletter
\ifthenelse{\boolean{ct@drafting}}{
	\usepackage{gitinfo2}
	\renewcommand{\PrelimText}{\footnotesize[\,\today\ at \thistime\ -- version \myVersion{} -- git \gitAbbrevHash\,]}
}{}
\makeatother


% nice cv style for PhD theses
\iftoggle{phd}{
	\usepackage[LabelsAligned]{currvita}
}{}


% to enable wide text/floats taking the space of margin notes (435pt instead of 336pt)
% note that this changes the \linewidth (not \textwidth), so follow this example
% to include a wide figure:
%  \begin{figure}
%  \begin{wide}
%  	 \includegraphics[width=\linewidth]{logos/tud-logo}
%  	 \caption{Athene logo of TU Darmstadt.}
%  \end{wide}
%  \end{figure}
\usepackage[strict]{changepage}
\newlength{\fullwidthlen}
\setlength{\fullwidthlen}{\marginparwidth}
\addtolength{\fullwidthlen}{\marginparsep}
\newenvironment{wide}{%
  \begin{adjustwidth*}{}{-\fullwidthlen}\hsize=\linewidth%
}{%
  \end{adjustwidth*}%
}


% TikZ/PGFPlots/Diagrams
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{pgf-umlsd}
\usetikzlibrary{
  chains,
  positioning,
  quotes,
  arrows.meta, 
  shapes.geometric, 
  fit
}

\def\StripPrefix#1>{}
\def\isOverleaf{\fi
    \def\overleafJobname{output}% overleaf defaults to 'output' as \jobname
    \edef\overleafJobname{\expandafter\StripPrefix\meaning\overleafJobname}%
    \edef\job{\jobname}%
    \ifx\job\overleafJobname
}

% To cache tikz pictures you have to run pdflatex with -shell-escape or --enable-write18
\ifnum\pdfshellescape=1
	\usepgfplotslibrary{external}
  \if\isOverleaf
  \tikzexternaldisable
  \else
  \tikzexternalize[prefix=GraphicsCache/]
  \fi
\fi


% Lengths for matlab2tikz
\newlength\figureheight
\newlength\figurewidth 

% SVGs
\usepackage{svg}
\usepackage{float}
\usepackage{graphicx}

% lstlistings
\definecolor{eclipseStrings}{RGB}{42,0.0,255}
\definecolor{eclipseKeywords}{RGB}{127,0,85}
\colorlet{numb}{magenta!60!black}

\lstdefinelanguage{json}{
    basicstyle=\normalfont\ttfamily,
    commentstyle=\color{eclipseStrings}, % style of comment
    stringstyle=\color{eclipseKeywords}, % style of strings
    numbers=left,
    numberstyle=\scriptsize,
    stepnumber=1,
    numbersep=8pt,
    showstringspaces=false,
    breaklines=true,
    frame=lines,
    backgroundcolor=\color{white}, %only if you like
    string=[s]{"}{"},
    comment=[l]{:\ "},
    morecomment=[l]{:"},
    literate=
        *{0}{{{\color{numb}0}}}{1}
         {1}{{{\color{numb}1}}}{1}
         {2}{{{\color{numb}2}}}{1}
         {3}{{{\color{numb}3}}}{1}
         {4}{{{\color{numb}4}}}{1}
         {5}{{{\color{numb}5}}}{1}
         {6}{{{\color{numb}6}}}{1}
         {7}{{{\color{numb}7}}}{1}
         {8}{{{\color{numb}8}}}{1}
         {9}{{{\color{numb}9}}}{1}
}

\lstdefinelanguage{Log}{
  morekeywords={INFO, WARNING, ERROR},
  sensitive=false,
  morecomment=[l]{//},
  morestring=[b]",
}

\lstdefinestyle{logstyle}{
  language=Log,
  basicstyle=\ttfamily\footnotesize,
  keywordstyle=\color{blue}\bfseries,
  commentstyle=\color{gray},
  stringstyle=\color{orange},
  showstringspaces=false,
  columns=fullflexible,
  keepspaces=true,
  breaklines=true,
  frame=single,
  backgroundcolor=\color{gray!5},
}

% tables
\usepackage{booktabs}
\usepackage{pifont}

\newcommand{\cmark}{\ding{51}} % checkmark
\newcommand{\xmark}{\ding{55}} % xmark

% forest
\usepackage[edges]{forest}

% TODO
\usepackage{todonotes}

% Acronyms
\newcommand{\glsposs}[1]{%
  \ifglsused{#1}{%
    \glslink{#1}{\glsentryshort{#1}'s}%
  }{%
    \glslink{#1}{\glsentrylong{#1}'s (\glsentryshort{#1})}%
  }%
  \glsadd{#1}%
}

% plots
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

% Allow linebreaks in texttt
\newcommand*\justify{%
  \fontdimen2\font=0.4em% interword space
  \fontdimen3\font=0.2em% interword stretch
  \fontdimen4\font=0.1em% interword shrink
  \fontdimen7\font=0.1em% extra space
  \hyphenchar\font=`\-% allowing hyphenation
}
