\RequirePackage{ifluatex,ifpdf}
\documentclass[ngerman,a4paper]{report}
\usepackage[left=2.1cm,right=3.1cm,bottom=3cm,footskip=0.75cm,headsep=0.5cm]{geometry}
\usepackage[ngerman]{babel}
\ifpdf
\usepackage[utf8]{inputenc} %not recommended with lualatex
\usepackage[T1]{fontenc}
\fi

\usepackage{zref-base}
\usepackage{etoolbox}
\usepackage{xparse}%better macros
\usepackage{chngcntr}
\usepackage{calc}

\usepackage{scalerel,stackengine}
\usepackage{tocloft}

\ifluatex
\usepackage{fontspec}
%awesome package for debugging spacing issues
%\usepackage{lua-visual-debug}
%\usepackage{luacode}
\fi

\usepackage[texindy]{imakeidx}
\indexsetup{
	level=\chapter*
}
\makeindex[intoc]

\usepackage[xindy,acronym]{glossaries}
\makeglossaries

\usepackage[title,titletoc]{appendix}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{latexsym}
\usepackage{marvosym} %lighning
\usepackage{bbm} %unitary matrix 1
\usepackage{cancel}
\usepackage{xfrac}%sfrac -> fractions e.g. 3/4

\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{patterns,arrows,calc,decorations.pathmorphing}
\usetikzlibrary{matrix}
\usepackage{color}
\usepackage{wasysym}
\usepackage{tcolorbox}

\usepackage{enumerate}
\usepackage{enumitem} %customize label
\usepackage{stmaryrd} % Lightning symbol

\usepackage{tabularx}
\usepackage{multirow}
\usepackage{booktabs}

\usepackage{ulem} %better underlines

\usepackage{parskip}%split paragraphs by vspace instead of intendations
\usepackage{fancyhdr}
\usepackage{titlesec}%customize titles
\usepackage{marginnote}

\usepackage[amsmath,amsthm,thmmarks,hyperref]{ntheorem}%customize theorem-environments more effectively
\usepackage[ntheorem,framemethod=TikZ]{mdframed}

\usepackage[unicode,bookmarks=true]{hyperref}
\hypersetup{
	colorlinks,
	citecolor=green,
	filecolor=green,
	linkcolor=blue,
	urlcolor=green
}
\usepackage{cleveref}
\usepackage{bookmark}

\newcommand{\coloredRule}[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
\newlength{\blacktrianglewidth}
\settowidth{\blacktrianglewidth}{$\blacktriangleright$}

\definecolor{lightgrey}{gray}{0.91}
\definecolor{lightred}{rgb}{1,0.6,0.6}
\definecolor{darkgrey}{gray}{0.6}
\definecolor{darkgreen}{rgb}{0,0.6,0}

%numbered theorems
\theoremstyle{break}
\theorembodyfont{}

\mdfdefinestyle{boxedtheorem}{%
	outerlinewidth=3pt,%
	skipabove=5pt,%
	skipbelow=10pt,%
	frametitlefont=\normalfont\bfseries\color{black},%
	nobreak,%enforce no pagebrakes in the whole frame
}

\newmdtheoremenv[%
	style=boxedtheorem,%
	innertopmargin=\topskip,%
	innerbottommargin=\topskip,%
	linecolor=darkgrey,%
	backgroundcolor=lightgrey,%
]{theorem}{Theorem}[section]

\newmdtheoremenv[%
	style=boxedtheorem,%
	linecolor=darkgrey,%
	topline=false,%
	rightline=false,%
	bottomline=false,%
	innertopmargin=\topskip,%
	innerbottommargin=\topskip,%
	backgroundcolor=lightgrey,%
]{proposition}[theorem]{Satz}

\newmdtheoremenv[%
	style=boxedtheorem,%
	linecolor=darkgrey,%
	topline=false,%
	rightline=false,%
	bottomline=false,%
	backgroundcolor=lightgrey,%
	innertopmargin=\topskip,%
	innerbottommargin=\topskip,%
]{lemma}[theorem]{Lemma}

\newmdtheoremenv[%
	style=boxedtheorem,%
	linecolor=red,%
	topline=false,%
	rightline=false,%
	bottomline=false,%
	innertopmargin=0,%
	innerbottommargin=-3pt,%
]{definition}[theorem]{Definition}

\newmdtheoremenv[%
	outerlinewidth=3pt,%
	linecolor=black,%
	topline=false,%
	rightline=false,%
	bottomline=false,%
	innertopmargin=0pt,%
	innerbottommargin=-0pt,%
	frametitlefont=\normalfont\bfseries\color{black},%
	skipabove=5pt,%	
	skipbelow=10pt,%
]{conclusion}[theorem]{Folgerung}

\newmdtheoremenv[%
	hidealllines=true,%
	frametitlefont=\normalfont\bfseries\color{black},%
	innerleftmargin=0pt,%
	skipabove=5pt,%
	innerleftmargin=10pt,%
]{remark}[theorem]{\hspace*{-10pt}$\blacktriangleright$\hspace*{\dimexpr 10pt - \blacktrianglewidth\relax}Bemerkung}

\newmdtheoremenv[%
	hidealllines=true,%
	frametitlefont=\normalfont\bfseries\color{black},%
	innerleftmargin=10pt,%
]{example}[theorem]{\hspace*{-10pt}\rule{5pt}{5pt}\hspace*{5pt}Beispiel}

%unnumbered theorems
\theoremstyle{nonumberbreak}
\theoremindent0cm
\newmdtheoremenv[%
	style=boxedtheorem,%
	linecolor=red,%
	topline=false,%
	rightline=false,%
	bottomline=false,%
	innertopmargin=1pt,%
	innerbottommargin=1pt,%
]{*definition}{Definition}

\newmdtheoremenv[%
	hidealllines=true,%
	frametitlefont=\normalfont\bfseries\color{black},%
	skipabove=5pt,%
	innerleftmargin=10pt,%
]{*remark}{\hspace*{-10pt}$\blacktriangleright$\hspace*{\dimexpr 10pt - \blacktrianglewidth\relax}Bemerkung}

\newmdtheoremenv[%
	hidealllines=true,%
	innerleftmargin=10pt,%
]{*example}{\hspace*{-10pt}\rule{5pt}{5pt}\hspace*{5pt}Beispiel}
\newtheorem{overview}[theorem]{Überblick}

\newmdtheoremenv[%
	style=boxedtheorem,%
	topline=false,%
	rightline=false,%
	leftline=false,
	bottomline=false,%
	innertopmargin=\topskip,%
	innerbottommargin=\topskip,%
	backgroundcolor=lightgrey,%
]{*anmerkung}{Anmerkung}

%Hinweis-Theoremstyle and environment
%To get rid of the parentheses, a new theorem style is neccessary (definition of nonumberbreak from ntheorem.sty)
%to achieve the underlining, this needed to put in the theoremstyle definition
\theoremheaderfont{\mdseries}
\theoremseparator{:}
\theorempostskip{0pt}
\makeatletter
\newtheoremstyle{noparentheses}%
	{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
					\underline{##1}\theorem@separator}\hbox{\strut}}}]}%
	{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
					\underline{##1\ ##3\theorem@separator}}\hbox{\strut}}}]}
\newtheoremstyle{underlinedPlain}%
	{\item[\hskip\labelsep \uline{\theorem@headerfont ##1\theorem@separator}]}%
	{\item[\hskip\labelsep \uline{\theorem@headerfont ##1\ \theorem@headerfont(##3)\theorem@separator}]}
\newtheoremstyle{underlinedEnvironment}{}%
{\item[\hskip\labelsep \uline{##1\theorem@headerfont ##3\theorem@separator}]}
\newtheoremstyle{boldEnvironment}{}%
{\item[\hskip\labelsep \textbf{##1\theorem@headerfont ##3\theorem@separator}]}
\newtheoremstyle{proofstyle}%
{\item[\hskip\labelsep {\theorem@headerfont ##1}\theorem@separator]}%
{\item[\hskip\labelsep {\theorem@headerfont ##1}\ (##3)\theorem@separator]}
\makeatother

\theoremstyle{noparentheses}
\newmdtheoremenv[%
	hidealllines=true,%
	innerleftmargin=1em,%
	innerbottommargin=0pt,%
	innerrightmargin=0,%
	skipbelow=0pt,%
]{interpretation}{\hspace*{\dimexpr - \mdflength{innerleftmargin}\relax}Interpretation}
\theoremstyle{underlinedPlain}
\newmdtheoremenv[%
	hidealllines=true,%
	innerleftmargin=1em,%
	innerrightmargin=0,%
	skipbelow=0pt,%
]{hint}{\hspace*{\dimexpr - \mdflength{innerleftmargin}\relax}Hinweis}

\theoremstyle{underlinedEnvironment}
\newmdtheoremenv[%
	hidealllines=true,%
	innerleftmargin=1em,%
	innerrightmargin=0,%
	skipbelow=0pt,%
]{underlinedenvironment}{\hspace*{\dimexpr -\mdflength{innerleftmargin}\relax}}
\theoremheaderfont{\bfseries}
\theoremstyle{boldEnvironment}
\newmdtheoremenv[%
	hidealllines=true,%
	innerleftmargin=1em,%
	innerrightmargin=0,%
	skipbelow=0pt,%
]{boldenvironment}{\hspace*{\dimexpr -\mdflength{innerleftmargin}\relax}}

\theoremstyle{proofstyle}
\theoremheaderfont{\normalfont\normalsize\itshape}
\theorembodyfont{\normalfont\small}
\theoremseparator{.}
\theorempreskip{5pt}
\theorempostskip{5pt}
\theoremsymbol{$\square$}
\renewtheorem{proof}{Beweis}

%for \cref: printed environment names
\crefname{theorem}{Theorem}{Theoreme}
\crefname{proposition}{Satz}{Sätze}
\crefname{lemma}{Lemma}{Lemmata}
\crefname{conclusion}{Folgerung}{Folgerungen}
\crefname{definition}{Definition}{Definitionen}
\crefname{remark}{Bemerkung}{Bemerkungen}
\crefname{example}{Beispiel}{Beispiele}
\crefname{*definition}{Definition}{Definitionen}
\crefname{*remark}{Bemerkung}{Bemerkungen}
\crefname{*example}{Beispiel}{Beispiele}

\makeatletter
%output a number in upper roman letters
\newcommand*{\rom}[1]{\expandafter\@slowromancap\romannumeral #1@}
%declare a new label; store current chapter number
\newcommand*{\proplbl}[1]{%
	\@bsphack
	\begingroup
	\label{#1}%
	\zref@setcurrent{default}{\arabic{chapter}}%
%		\zref@wrapper@immediate{%
		\zref@labelbyprops{#1@chapter}{default}
%		}
	\endgroup
	\@esphack
}

%refer to a label set by proplbl.
%If the label is not defined (yet), question marks are output at the calling position. If the label is defined, the chapter number is prepended to the link output by \cref if the current chapter number and the one set when calling \proplbl differ.
%the macro handels both text and math mode. mbox is needed due to a feature concerning ulem / cleveref
\newcommand*{\propref}[1]{%
	\ifcsdef{r@#1}%in first compilation the label may not be defined yet
	{%
		\zref@refused{#1@chapter}%
		\ifnumcomp{\value{chapter}}{=}{\zref@extractdefault{#1@chapter}{default}{0}}%
		{%same chapter
			\ifmmode 
				\cref{#1}%
			\else
				\mbox{\cref{#1}}%
			\fi
		}%
		{%otherwise
			\def\propositionref@current@type{}%
			\cref@gettype{#1}{\propositionref@current@type}%get the environment's name
			%example for following line:
			%\crefformat{truetheorem}{\cref@truetheorem@name~##2\rom{\zref@extractdefault{#1}{#1chapter}{1}}.##1##3}
			%this changes the format used by \cref to <environtment name> <chapter-number>.<section-number>.<theorem number>
			\crefformat{\propositionref@current@type}{%
				\csname cref@\propositionref@current@type @name\endcsname ~##2\rom{\zref@extractdefault{#1@chapter}{default}{1}}.##1##3%
			}%
			\ifmmode 
				\cref{#1}%
			\else
				\mbox{\cref{#1}}%
			\fi
			\crefformat{\propositionref@current@type}{%
				\csname cref@\propositionref@current@type @name\endcsname~##2##1##3%
			}%
		}%
	}%
	{??}%similar to \ref\cref: question marks in case of undefined labels
}
\makeatother

%declare new term to the index, output if no star is given to call position
\NewDocumentCommand{\begriff}{s O{} m O{}}{%
	\IfBooleanTF{#1}%
	{\index{#2#3#4}}%
	{%
		\uline{#3}%
		\index{#2#3#4}%
	}%
}

%append a new mathsymbol to the index, output if no star is given at the call position
\NewDocumentCommand{\mathsymbol}{s O{} m m O{}}{%
	\IfBooleanTF{#1}%
	{\index[symbols]{#2#3@\detokenize{#4}#5}}%
	{#4\index[symbols]{#2#3@\detokenize{#4}#5}}%
}

%remove skip before / after amsmath-environments: default to 0pt. 1star: just before the environment, 2stars: just after the environment, no star: both
\NewDocumentCommand{\zeroAmsmathAlignVSpaces}{s s O{0 pt} O{0 pt}}{%
	\IfBooleanTF{#1}%
	{%
		\IfBooleanTF{#2}%
			{\setlength{\belowdisplayskip}{#4}}%
			{\setlength{\abovedisplayskip}{#3}}%
	}%
	{%
		\setlength{\abovedisplayskip}{#3}%
		\setlength{\belowdisplayskip}{#4}%
	}%
}

%general transpose-makro
\NewDocumentCommand{\transpose}{m}{\ensuremath{#1^\mathsf{T}}}

%unused
\NewDocumentCommand{\itemEq}{s m}{%
	\begingroup%
	\setlength{\abovedisplayskip}{\dimexpr -\parskip + 1pt\relax}%
	\setlength{\belowdisplayskip}{0pt}%
	\IfBooleanTF{#1}%
		{\parbox[c]{\linewidth}{\begin{flalign*}#2&&\end{flalign*}}}%}
		{\parbox[c]{\linewidth}{\begin{flalign}#2&&\end{flalign}}}%}
	\endgroup% 
}

%new macro for "equals" ^=
\newcommand\equalhat{\mathrel{\stackon[1.5pt]{=}{\stretchto{%
	\scalerel*[\widthof{=}]{\wedge}{\rule{1ex}{3ex}}}{0.5ex}}}}

%macro that defines the spacing between bracket and content of a matrix
\NewDocumentCommand{\matrixBracketSpacing}{}{\mspace{4.0mu plus 3.0mu minus 1.0mu}}
%macro width customized spacing between bracktes / content, lineheight and columnwidth
\newenvironment{henrysmatrix}{%
	\renewcommand*{\arraystretch}{1.2}
	\setlength\arraycolsep{5pt}
	\left(\matrixBracketSpacing
	\begin{matrix}
}{%
	\end{matrix}
	\matrixBracketSpacing\right)
}

\makeatletter
%redefine \overline to customize the space between text / line (currently 0.4mm + height of the content)
%ATTENTION: when changing the 0.4mm unfortunately, in \kringel the 0.4mm need to be changed accordingly
\let\@old@overline\overline
\renewcommand*{\overline}[1]{%
	\@old@overline{\raisebox{0pt}[\dimexpr\height+0.4mm\relax]{$#1$}}%
}

%encircle some content. Arguments: border color (optional), background color (mandatory), content (mandatory)
%two lengths to get width / height of content (important for width / height of the circle)
\newlength{\@kringel@contentheight}
\newlength{\@kringel@contentwidth}
\newlength{\@kringel@depth}
\NewDocumentCommand{\kringel}{O{blue} m m}{%
%as the macro should work for both text and math mode, add some macros for later use to distinguish
%in text mode, nothing happens (except discarding the 1st argument for the raisebox, that is permantently given), in math mode, the content needs to be enbraced by \ensuremath, the tcolorbox-environment by a raisebox
%ATTENTION: when changing the height-factor of tcolorbox, the depth correction needs to be changed as well
	\let\@kringel@inner\relax
	\let\@kringel@outer\@secondoftwo
	\ifmmode
		\let\@kringel@inner\ensuremath
		\let\@kringel@outer\raisebox
	\fi
%set the width and height
	\settoheight{\@kringel@contentheight}{\hbox{\@kringel@inner{#3}}}
	\settowidth{\@kringel@contentwidth}{\@kringel@inner{#3}}
	\settodepth{\@kringel@depth}{\@kringel@inner{#3}}
%change the depth correction dependend whethere there is a depth (e.g. y) or not (e.g. a)
	\ifdim \@kringel@depth > 0pt%
		\setlength{\@kringel@depth}{\dimexpr\@kringel@depth+0.5mm\relax}
	\else
		\settodepth{\@kringel@depth}{y}
		\setlength{\@kringel@depth}{\dimexpr\@kringel@depth+0.3mm\relax}
	\fi
%output the colorbox width given parameter: frame color, background color, computed width and height, and escaped content depending on math / text mode
	\@kringel@outer{\dimexpr-\@kringel@contentheight/2-\@kringel@depth\relax}{\begin{tcolorbox}[colframe=#1,halign=center,valign=center,width=\dimexpr1.5\@kringel@contentwidth+1mm\relax,height=2.5\@kringel@contentheight,left=0pt,right=0pt,bottom=0pt,top=0pt,boxrule=0.8pt,colback=#2,boxsep=0pt,bean arc]
		\@kringel@inner{#3}
	\end{tcolorbox}}
}

%switch numbering of equations (amsmath-environments)
\newcommand{\leqnos}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnos}{\tagsleft@false\let\veqno\@@eqno}
\reqnos

\pdfstringdefDisableCommands{%
	\def\\{}%
	\def\texttt#1{<#1>}%
	\def\mathbb#1{<#1>}%
}
\makeatother

%General newcommands!
\newcommand{\comp}{\mathbb{C}} % complex set C
\newcommand{\real}{\mathbb{R}} % real set R
\newcommand{\whole}{\mathbb{Z}} % whole number Symbol
\newcommand{\natur}{\mathbb{N}} % natural number Symbol
\newcommand{\ratio}{\mathbb{Q}} % rational number symbol
\newcommand{\field}{\mathbb{K}} % general field for the others above!
\newcommand{\diff}{\mathrm{d}} % differential d
\newcommand{\s}{\,\,}     % space after the function in the intergral
\newcommand{\cont}{\mathcal{C}} % Contour C
\newcommand{\fuk}{f(z) \s\diff z} % f(z) dz
\newcommand{\diffz}{\s\diff z}
\newcommand{\subint}{\int\limits} % lower boundaries for the integral
\newcommand{\poly}{\mathcal{P}} % special P - polygon
\newcommand{\defi}{\mathcal{D}} % D for the domain of a function
\newcommand{\cover}{\mathcal{U}} % cover for a set
\newcommand{\setsys}{\mathcal{M}} % set system M
\newcommand{\setnys}{\mathcal{N}} % set system N
\newcommand{\zetafunk}{f(\zeta)\s\diff \zeta} %f(zeta) d zeta
\newcommand{\ztfunk}{f(\zeta)} % f(zeta)
\newcommand{\bocirc}{S_r(z)}
\newcommand{\prop}{\,|\,}
\newcommand*{\QEDA}{\hfill\ensuremath{\blacksquare}} %tombstone
\newcommand{\emptybra}{\{\varnothing\}} % empty set with set-bracket
\newcommand{\realpos}{\real_{>0}}
\newcommand{\realposr}{\real_{\geq0}}
\newcommand{\naturpos}{\natur_{>0}}
\newcommand{\Imag}{\operatorname{Im}} % Imaginary symbol
\newcommand{\Realz}{\operatorname{Re}} % Real symbol
\newcommand{\norm}{\Vert \cdot \Vert}
\newcommand{\metric}{\vert \cdot \vert}
\newcommand{\foralln}{\forall n} %all n
\newcommand{\forallnset}{\forall n \in \natur} %all n € |N
\newcommand{\forallnz}{\forall n \geq _0} % all n >= n_0
\newcommand{\conjz}{\overline{z}} % conjugated z
\newcommand{\tildz}{\tilde{z}} % different z
\newcommand{\lproofar}{"`$ \Leftarrow $"'} % "`<="'
\newcommand{\rproofar}{"`$ \Rightarrow $"'} % "`=>"'
\newcommand{\beha}{\Rightarrow \text{ Behauptung}}
\newcommand{\powerset}{\mathcal{P}}
\newcommand{\person}[1]{\textsc{#1}}
\newcommand{\highlight}[1]{\emph{#1}}
\newcommand{\realz}{\mathfrak{Re}}
\newcommand{\imagz}{\mathfrak{Im}}
\renewcommand{\epsilon}{\varepsilon}
\renewcommand{\phi}{\varphi}
\newcommand{\lebesque}{\person{Lebesgue}}
\renewcommand{\Re}{\mathfrak{Re}}
\renewcommand{\Im}{\mathfrak{Im}}
\renewcommand*{\arraystretch}{1.4}
\newcommand{\skalar}[2]{\left\langle #1,#2\right\rangle}

% Math Operators
\DeclareMathOperator{\inn}{int} % Set of inner points
\DeclareMathOperator{\ext}{ext} % Set of outer points
\DeclareMathOperator{\cl}{cl} % Closure
\DeclareMathOperator{\grad}{grad}
\DeclareMathOperator{\D}{d}
\DeclareMathOperator{\id}{id}
\DeclareMathOperator{\graph}{graph}
\DeclareMathOperator{\Int}{int}
\DeclareMathOperator{\Ext}{ext}
\DeclareMathOperator{\diam}{diam}

\DeclareMathOperator{\End}{End}
\DeclareMathOperator{\Aut}{Aut}
\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\Eig}{Eig}
\DeclareMathOperator{\Mat}{Mat}
\DeclareMathOperator{\Ker}{Ker}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\GL}{GL}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\Span}{span}
\DeclareMathOperator{\Image}{Im}
\DeclareMathOperator{\Hau}{Hau}

%change headings:
\titlelabel{\thetitle.\quad}%. behind section/sub... (3. instead of 3)
\counterwithout{section}{chapter}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thepart}{\Alph{part}}
%italic chapters (due to titlesec package some more stuff)
%\titleformat{command}[shape]{format}{label}{sep}{before-code}[after-code]
\titleformat{\chapter}[display]{\bfseries}{\Large\chaptername\;\thechapter}{-5pt}{\huge\bfseries\itshape}
\titlespacing{\chapter}{0pt}{0pt}{10pt}
\titleformat{\section}[hang]{\bfseries\Large}{\thesection.}{8pt}{\Large\bfseries}
%\titlespacing{command}{left}{before-sep}{after-sep}
\titlespacing{\subsection}{0pt}{0pt}{5pt}

%change appearence of heading of toc: 0 space above, bold, italic huge toc-heading
\renewcommand{\cftbeforetoctitleskip}{0pt}
\renewcommand{\cfttoctitlefont}{\itshape\Huge\bfseries}
%change indentations due to width of capital roman numbers
\renewcommand{\cftchapnumwidth}{2.5em}
\renewcommand{\cftsecindent}{2.5em}
%\renewcommand{\cftsecnumwidth}{3.3em}
\renewcommand{\cftsubsecindent}{4.8em}
%\renewcommand{\cftsubsecnumwidth}{4.2em}

%change header:
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0.3pt}
\lhead{\rightmark}%left: section-number. section-title
\rhead{\leftmark}%right: chapter chapternumber: chapter-title

% Add new page-style (just footer), patch \chapter command to use this page style
\fancypagestyle{plainChapter}{%
	\fancyhf{}%
	\fancyfoot[C]{\thepage}%
	\renewcommand{\headrulewidth}{0pt}% Line at the header invisible
	\renewcommand{\footrulewidth}{0.4pt}% Line at the footer visible
}
%changes pagestyle; instead of empty page the normal footer is printed
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{plainChapter}}{}{}
%usually, after a new chapter the section counter needs to be reset manually. Instead, automatic reset
\pretocmd{\chapter}{\setcounter{section}{0}}{}{}

\pagestyle{fancy}
\pagenumbering{arabic}
%remember chapter-title in \leftmark and \rightmark
\renewcommand{\chaptermark}[1]{%
	\markboth{\chaptername
		\ \thechapter:\ #1}{}}
%remember section title in \leftmark
\renewcommand{\sectionmark}[1]{%
	\markright{\thesection.\ #1}{}}

%change numbering of equations to be section by section
\counterwithout{equation}{section}

\title{\textbf{Lineare Algebra SS2018}}
\author{Dozent: Prof. Dr. Arno Fehm}

%remove page number from part{}-pages
\makeatletter
\let\sv@endpart\@endpart
\def\@endpart{\thispagestyle{empty}\sv@endpart}
\makeatother

\begin{document}
\pagenumbering{roman}
\pagestyle{plain}

\maketitle

\hypertarget{tocpage}{}
\tableofcontents
\bookmark[dest=tocpage,level=1]{Inhaltsverzeichnis}

\pagebreak
\pagestyle{fancy}
\pagenumbering{arabic}
\pagestyle{fancy}

\chapter{Endomorphismen}
\input{./TeX_files/Eigenwerte}
\include{./TeX_files/Das_charakteristische_Polynom}
\include{./TeX_files/Diagonalisierbarkeit}
\include{./TeX_files/Trigonalisierbarkeit}
\include{./TeX_files/Das_Minimalpolynom}
\include{./TeX_files/Nilpotente_Endomorphismen}
\include{./TeX_files/Die_Jordan_Normalform}

\chapter{Skalarprodukte}
\input{./TeX_files/Das_Standardskalarprodukt}
\include{./TeX_files/Bilinearformen_und_Sesquilinearformen}
\include{./TeX_files/Euklidische_und_unitaere_VR}
\include{./TeX_files/Orthogonalitaet}

\chapter{Dualität}

\chapter{Moduln}

\part*{Anhang}
\addcontentsline{toc}{part}{Anhang}
\appendix
\patchcmd{\chapter}{\thispagestyle{plainChapter}}{\thispagestyle{fancy}}{}{}
%\titleformat{command}[shape]{format}{label}{sep}{before-code}[after-code]
%\titlespacing{command}{left}{before-sep}{after-sep}
\renewcommand{\chaptername}{Anhang}
\renewcommand{\thechapter}{\Alph{chapter}}
\titleformat{\chapter}[hang]{\bfseries}{\LARGE\chaptername\ \thechapter:}{0.5em}{\LARGE\bfseries}
\titlespacing{\chapter}{0pt}{-0.75cm}{0pt}
\renewcommand{\thesection}{\Alph{chapter}.\arabic{section}}

%from ntheorem.sty
%\def\thm@@thmline@name#1#2#3#4#5{%
%	\ifx\\#5\\%
%		\@dottedtocline{-2}{0em}{2.3em}%
%		{#1 \protect\numberline{#2}#3}%
%		{#4}
%	\else
%		\ifHy@linktocpage\relax\relax
%			\@dottedtocline{-2}{0em}{2.3em}%
%			{#1 \protect\numberline{#2}#3}%
%			{\hyper@linkstart{link}{#5}{#4}\hyper@linkend}%
%		\else
%			\@dottedtocline{-2}{0em}{2.3em}%
%			{\hyper@linkstart{link}{#5}%
%			{#1 \protect\numberline{#2}#3}\hyper@linkend}%
%			{#4}%
%		\fi
%	\fi
%}

\makeatletter
%update ntheorem macro to provide space between theorem numbers and any optional comment
\renewcommand{\thm@@thmline@name}[5]{%-       		
	\def\thm@@thmline@name@tmp{%
		\if\relax\detokenize{#3}\relax\else%
			{\hspace*{2.2ex}#3}%
		\fi%
	}%
	\ifx\\#5\\%
		\@dottedtocline{-2}{0em}{2.3em}%
		{#1 \protect\numberline{#2\thm@@thmline@name@tmp}{}}%
		{#4}
	\else
		\ifHy@linktocpage\relax\relax
			\@dottedtocline{-2}{0em}{1.3em}%
			{#1 \protect\numberline{#2:}\thm@@thmline@name@tmp}%
			{\hyper@linkstart{link}{#5}{#4}\hyper@linkend}%
		\else
			\@dottedtocline{-2}{0em}{1.3em}%
			{#1 \protect\numberline{#2:}\thm@@thmline@name@tmp}%
			{\hyper@linkstart{link}{#5}{#4}\hyper@linkend}%
		\fi
	\fi
}
\makeatother

\chapter{Listen}
\section{Liste der Theoreme}
\theoremlisttype{allname}
\listtheorems{theorem}

\pagebreak
\section{Liste der benannten Sätze}
\theoremlisttype{optname}
\listtheorems{proposition}

\printglossary[type=\acronymtype]
\addcontentsline{toc}{chapter}{Akronyme}

\printindex

\end{document}