% Hello and welcome to the LateX Template for thesis writing at the ITE. 
% This Template was designed by Stefanie Säfken in October 2019 in its first version.
% This is Version 1.0

% To use this template, please set your standard compiler to XeLaTeX or pdfLaTeX (if not using costumised fonts).
% Use utf8 coding for your TeX file.
% Here we use customised bibliography styles with Bibulous that follow the SPE guidelines. 
% How to install bibulous:
% First install Phyton 2.7.
% Move the folder "LaTeX" to your C:\ hard drive. 
% Set your compiler for bibliographies to BibTeX.
% Change the settings for BibTeX according to the instructions found on https://nzhagen.github.io/bibulous/index.html.
% If you put the LaTeX file on C:/ as described above, you can simply copy the path below (only works for TeXstudio, for other programs go to the https://nzhagen.github.io/bibulous/index.html)
% "C:\Python27\python.exe" "C:\LaTeX\bibulous-master\bibulous.py" %.aux
% How to compile the final document:
% XeLatTeX
% XeLatTeX
% BibTeX
% Makeindex
% Makeglossaries
% XeLatTeX
% XeLatTeX

\documentclass[%draft,  %activate draft for a fast run where images are just displayed as boxes to save time
12pt,a4paper,bibtotoc,numbers=noenddot]{scrreprt}

\usepackage[main=british,ngerman]{babel}

\usepackage[onehalfspacing]{setspace}

\usepackage[utf8]{inputenc}

\usepackage{textcomp}

\usepackage{notoccite}

\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\addtokomafont{disposition}{\rmfamily}
\setlength{\emergencystretch}{1em}
\PassOptionsToPackage{hyphens}{url}
%\urlstyle{rm}

\usepackage{pdflscape}

\usepackage[toc,page]{appendix}

\usepackage{hyphenat}

\usepackage[style=english]{csquotes}

\usepackage{totpages}

\usepackage[superscript]{cite}
\makeatletter
\renewcommand\@citess[1]{\textsuperscript{[#1]}}
\makeatother

%%%%% Definition of date and time formats %%%%

\usepackage{datetime}
%% Date with number and superscript ordinal, full monthname and year
\newdateformat{britishdate}{% %For thesis written in english
	\ordinal{DAY} \monthname[\THEMONTH] \THEYEAR}
%% Date with number, full monthname and year
\newdateformat{germandate}{%  %For thesis written in german or american english. Here you need to change the command "britishdate" to "germandate"
	\THEDAY.\,\monthname[\THEMONTH] \THEYEAR}

%%%%% Set caption options %%%%%

\usepackage[format=plain, justification=centering]{caption}

\usepackage[margin=10pt,font=small,labelfont=bf]{caption}

%%%% Inserting tables %%%%%

\usepackage{array,longtable,tabu,multirow}

\usepackage{tabularx}
%% For itemize list with inner table/structure; otherwise labeling environment works also fine: 
\newcommand{\leftrighttext}[3][10em]{% 
	\begin{tabularx}{\linewidth}[t]{@{}Xp{#1}@{}} 
		#2 & #3 
	\end{tabularx}% 
}
%% Example:
%\begin{itemize}
%	\item \leftrighttext{$\theta = 0$°:} {perfect wetting}
%	\item \leftrighttext{$0<\theta<90$° :} {high wettability}
%	\item \leftrighttext{$\theta>90$° :} {low wettability}
%	\item \leftrighttext{$\theta = 180$° :} {perfect non-wetting}
%\end{itemize}

%% For tables with footnotes:
\usepackage{threeparttable}
%% Example:
%\begin{table}[!h]
%	\renewcommand{\arraystretch}{1.25} %Changing line height, because space to upper line is to small
%	\taburulecolor{gray}
%	\vspace{.5em}
%	\caption{First table}
%	\label{tab:First}
%	\centering
%	\footnotesize
%	\begin{threeparttable}[b]
%		\begin{tabular}{lccL{5cm}}
%			\toprule
%			Number  & Value & Data & Description \\
%			\midrule
%			1 & Answer & 42 & Asked the question\tnote{1}\\
%			2 & None & --\tnote{2} & Help!\\
%			\bottomrule
%		\end{tabular}
%		\begin{tablenotes}
%			\item [1] What was the question?
%			\item [2] No data available. Sorry\dots
%		\end{tablenotes}
%	\end{threeparttable}
%\end{table}

%% New columtypes. Does the same as p{}, but with alignment
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}} % use p instead of m, if everything shall be aligned to the top instead of being centered
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{K}[1]{>{\raggedright\arraybackslash}p{#1}}

\usepackage{booktabs}

%%%%% Math environments %%%%%

\usepackage{mathtools,mathcomp,amsmath,amssymb,amsfonts,array}

\usepackage{upgreek}

\usepackage{extarrows}

\usepackage[shortcuts]{extdash}

\usepackage{xfrac}

%% Automated processing of numbers and units. Add new units.
\usepackage{nicefrac,siunitx,units}
\DeclareSIUnit\Darcy{D}
\DeclareSIUnit\wtpercent{\textsubscript{wt}\%}
\DeclareSIUnit\volpercent{\textsubscript{vol}\%}
\DeclareSIUnit\molpercent{\textsubscript{mol}\%}

%%%%% Inserting figures and schemes %%%%%    

\usepackage{graphics, graphicx, graphbox}

%\usepackage[]{subfig}

\usepackage{tikz}


\usepackage{blindtext,wrapfig}
\makeatletter
\newcommand\wrapfill{\par
	\ifx\parshape\WF@fudgeparshape
	\nobreak
	\vskip-\baselineskip
	\vskip\c@WF@wrappedlines\baselineskip
	\allowbreak
	\WFclear
	\fi
}
\makeatother % Workaround for issues with pictures embedded in a text, that are bigger than the paragraph. Insert \wrapfill\noindent drirectly behind and insert you wrapfigure into the text. Source: http://groups.google.com/group/de.c.....d/thread/36432cb44889fd39. Blindtext adds useless text. 

%%%%% Head and foot settings %%%%%

\usepackage{fancyhdr}

%% Control of length head
\newlength\FHoffset
\setlength\FHoffset{-0cm}
\addtolength\headwidth{2\FHoffset}
\fancyheadoffset{\FHoffset}

%% Control of length foot
\newlength\FFoffset
\setlength\FFoffset{-0cm}
\addtolength\headwidth{2\FFoffset}
\fancyfootoffset{\FFoffset}

%% Control of with and colour of head/foot
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\headrule}{\hbox to\headwidth{\color{gray}\leaders\hrule height \headrulewidth\hfill}}
\renewcommand{\footrule}{\hbox to\headwidth{\color{gray}\leaders\hrule height \footrulewidth\hfill}}

%% Set different pagestyles
\fancypagestyle{plain}{%
	\fancyhf{} % clear all header and footer fields
	\fancyfoot[R]{\thepage} % except the center
	\renewcommand{\headrulewidth}{0pt}
	\renewcommand{\footrulewidth}{0pt}}
%
\fancypagestyle{new}{
\fancyhf{} %clears plain style
\addtolength{\headheight}{\baselineskip}
\fancyhead[R]{\leftmark}
\fancyfoot[R]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}%
%define \leftmark style, add another "#" for debugging
%\renewcommand{\chaptermark}[1]{\markboth{##1}{}}
\renewcommand{\chaptermark}[1]{%
	\markboth{\MakeUppercase{%
			\chaptername}\ \thechapter.%
		\ ##1}{}}
}
%
\fancypagestyle{appendix}{
	\fancyhf{} %clears plain style
	\addtolength{\headheight}{\baselineskip}
	\fancyhead[R]{\appendixname}
	\fancyfoot[R]{\thepage}
	\renewcommand{\headrulewidth}{1pt}
	\renewcommand{\footrulewidth}{0pt}%
	%define \leftmark style, add another "#" for debugging
	%\renewcommand{\chaptermark}[1]{\markboth{##1}{}}
	\renewcommand{\chaptermark}[1]{%
		\markboth{\MakeUppercase{%
				\chaptername}\ \thechapter.%
			\ ##1}{}}
}
%
\renewcommand*\chapterpagestyle{plain} 

%%%%% Fonts %%%%%

%% With XeLaTeX and the following option it is possible to costumise the fonts and even use Windows fonts like Times New Roman or Arial. For ITE thesis it is best to stay with the default settings
\usepackage{lmodern}
\fontfamily{lmr}\selectfont

%%Times (Zweispaltige Dokumente/Zeitungen)
%\usepackage{mathptmx}
%\fontfamily{ptm}\selectfont
%\renewcommand*\familydefault{\lmr}

%%Latin Modern (Einspaltige Dokumente)
%\usepackage{lmodern}
%%\fontfamily{lmr}\selectfont
%\renewcommand*\familydefault{\rmdefault}

%%Palantino (Adobe Standartschrift, breiter)
%\usepackage{mathpazo}
%\fontfamily{pplx}\selectfont

%%Times New Roman und andere (nicht zu empfehlende) Windows und heruntergeladene Schriften
%\usepackage[T1]{fontenc}
%\usepackage{mathspec}
%\setmainfont{Times New Roman}
%\setmathsfont(Digits,Latin)[Numbers={Lining,Proportional}]{Times New Roman}
%\setmathsfont(Greek)[Numbers={Lining,Proportional}]{Times New Roman}

%%%% Add ons for Chemistry $$$$$

\usepackage[version=3]{mhchem}

%% Chemical reaction formulas without brackets if referenced and optional chapternumbering 
\makeatletter
\@definecounter{reaction}
\def\reaction{$$\refstepcounter{reaction}}
\def\endreaction{\eqno \hbox{\@reacnum}$$\@ignoretrue}
\def\@reacnum{{\normalfont \normalcolor (\thereaction)}}
\@addtoreset{reaction}{chapter}
\renewcommand\thereaction{\ifnum \c@chapter>\z@ \thechapter.\fi %-> hier könnte chapterzahl hinzugefügt werden
	\@Roman\c@reaction}
\makeatother

%% Add a new category besides figures and tables f.e. for schemes of reaction mechanisms in chemistry.
\DeclareCaptionType[fileext=los,placement=htb]{scheme}[Scheme][List of Schemata]
\setcapindent{1em}

%%%%% Chapter and section settings %%%%%

%% Set list of tables, figures and others in section style
\makeatletter
\renewcommand\listoftables{%
	\subsection*{\listtablename}%
	\@mkboth{\MakeUppercase\listtablename}%
	{\MakeUppercase\listtablename}%
	\@starttoc{lot}%
}
\renewcommand\listoffigures{%
	\subsection*{\listfigurename}%
	\@mkboth{\MakeUppercase\listfigurename}%
	{\MakeUppercase\listfigurename}%
	\@starttoc{lof}%
}
\makeatother

%% Remove chaptercounter for figure and table numbering
\usepackage{chngcntr}
%\counterwithout{figure}{chapter}
%\counterwithout{table}{chapter}

%% Optimises skip between chapter and header for Bachelor and Master Thesis. Can be diabled for Doctoral Thesis.
%\vspace*{2.3\baselineskip} = ORIGINAL 
\renewcommand*{\chapterheadstartvskip}{\vspace*{.5\baselineskip}}% Abstand einstellen

%% Set counters for sections/subsections/subsubsections to be displayed in the toc (table of contents)
%\setcounter{tocdepth}{1}
%\setcounter{secnumdepth}{1}

%%%Colours%%%
\definecolor{ITEgrey}{HTML}{58595b}
\definecolor{TUCgreen}{RGB}{0 140 79}
\definecolor{TUCred}{RGB}{140 28 0}
\definecolor{TUCdarkgrey}{RGB}{128 128 128}
\definecolor{TUClightgrey}{RGB}{230 230 230}
\definecolor{Word}{HTML}{2a579a}

%%%% Others %%%%%

%% Hyperref for references of chapters, sections, tables, figures etc. in text. Should be loaded as last package to not interfere with some other packages. If loaded before glossaries, entries are hyperlinked.
\usepackage[bookmarksnumbered=true]{hyperref}

%%%%% Glossaries an textreferences %%%%%    

\usepackage{fancyref}

\usepackage[nonumberlist,acronym,section=subsection]{glossaries}
\newglossarystyle{myglossarystyle}{%
	\renewenvironment{theglossary}{%
		\begin{labeling}{xxxxxxxxxx}}{\end{labeling}}%
	\renewcommand*{\glossaryentryfield}[5]{%
		\item[\glstarget{##1}{##2}]% Eintragsname:
		\ifthenelse{\equal{##4}{\relax}}{}{\space (##4)}% (Symbol)
		\space ##3% Beschreibung
		%\dotfill ##5% ...Seitenzahl
	}%
}

%% New glossary types to have extra glossaries for units etc.
\newglossary[slg]{symbols}{sym}{sbl}{Symbols}
\renewcommand*{\glspostdescription}{}

\newglossary[un]{units}{uni}{ut}{Units}
\renewcommand*{\glspostdescription}{}

\makeglossaries
\setglossarystyle{myglossarystyle}
%% In this files are your acronyms and other abbreviations. They have to be refferd to in the document (including the units!) to be listed in the glossaries.
\loadglsentries{Glossar_symbols.tex}
\loadglsentries{Glossar_units.tex}
\loadglsentries{Glossar_acronyms.tex}
%\glsdisablehyper %Disables hyperrefed glossary entries

\usepackage{tocstyle}
\newtocstyle[KOMAlike][leaders]{alldotted}{}
\usetocstyle{alldotted}

%%%%% Your data %%%%%
\author{First name and family name}
\newdate{birthday}{01}{01}{2019}
\title{Title of Master Thesis}
%\newdate{hand-in}{01}{01}{2019} %Set the date of your thesis hand in
\newdate{hand-in}{\day}{\month}{\year} %Uses todays date as hand-in date

\begin{document}
\pagenumbering{Roman}
\include{01Preamble}
\pagestyle{plain}
\include{01Summary}
\include{01Acknowledgements}
\thispagestyle{empty}
\tableofcontents
\newpage
\listoffigures
%\listofschemes
\listoftables	
\printglossary[title=Glossary]
%\addcontentsline{toc}{subsection}{Glossary}
\printglossary[type=\acronymtype,title={Abbreviations}]
%\addcontentsline{toc}{subsection}{Abbreviations}
\printglossary[type=symbols]
%\addcontentsline{toc}{subsection}{Symbols}
\printglossary[type=units]
%\addcontentsline{toc}{subsection}{Units}
\cleardoublepage
\pagenumbering{arabic}
\pagestyle{new}
\include{10Introduction}
%
%% Remove or comment the Styleguide file to be not included in your thesis!!!: 
\include{10Styleguide}
%
\include{11Chapter1}
\include{12Chapter2}
\include{13Chapter3}
%include more chapters depending on you scope
\include{21Conclusion}
\include{22Outlook}
\newpage
\renewcommand{\bibname}{References}
%% Chose one style for bibulous or create your own in an new .bst file 
%\bibliographystyle{TUen.bst}
\bibliographystyle{SPE.bst}
\bibliography{Literature.bib}
\include{30Appendix}
\end{document}
%Tipps und Tricks:
%\section[short title]{title}\label{key} für \nameref{label}, wenn Literaturstelle im Titel wird bei nameref der short title genutzt