% bibtotoc[numbered] : Literaturv. wird in Inhaltsv. aufgenommen
% abstracton : Abstract mit Ueberschrift
\documentclass[
a4paper,				% default
$if(fontsize)$$fontsize$,$endif$ 					% default = 11pt
BCOR6mm,				% Bindungskorrektur bei Klebebindung 6mm, bei Lochen BCOR8.25mm
twoside,				% default, 2seitig
titlepage,
% pagesize=auto
% openany,				% Kapitel koennen auch auf geraden Seiten starten
% draft						% schneller compillieren, Bild-dummy
% appendixprefix,	% Anhang mit Bezeichner
bibtotocnumbered,
liststotocnumbered,
listof=totocnumbered,
index=totocnumbered,
xcolor=dvipsnames,
]{scrbook}

%%%%%%%%%%%%%%% Literaturverzeichnisstil %%%%%%%%%%%%%%%
% achtung, auch \bibstyle, unten, anpassen!
% \usepackage[square]{natbib} % fuer bibstyle natdin/ see ../natbib.pdf

%%%%%%%%%%%%%%% Packages %%%%%%%%%%%%%%%
\input{settings/packages}
\makeindex

%%%%%%%%%%%%%%% Graphics %%%%%%%%%%%%%%%
\graphicspath{{pics/}}

%%%%%%%%%%%%%%% Globale Einstellungen %%%%%%%%%%%%%%%
\input{settings/commands}
\input{settings/environments}
%\setlength{\parindent}{0pt} % kein einzug bei absaetzen
%\setlength{\lineskip}{1ex plus0.5ex minus0.5ex} % dafr abstand zwischen abs�zen (funktioniert noch nicht)
% \renewcommand{\familydefault}{\sfdefault}
\setstretch{1.44} % 1.5-facher zeilenabstand

%%%%%%%%%%%%%%% Header - Footer %%%%%%%%%%%%%%%
% ### Fr 2 Seitig (option twopage):
\usepackage{fancyhdr}%http://www.tug.org/tex-archive/info/german/fancyhdr
\pagestyle{fancy} % must be called before the following renewcommands !!!
\fancyhead{} % Alte Definition loeschen
\fancyfoot{} % dito
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter{}: #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection{}~~#1}}
% % um das hard codierte makeuppercase zu verhindern
\fancyhead[EL]{\textrm{\nouppercase\leftmark}}% Even=linke Seiten und dort links, also aussn das \leftmark
\fancyhead[OR]{\textrm{\nouppercase\rightmark}}% Odd=rechte Seiten und dort rechts, also aussen das \rightmark
\fancyfoot[RO,LE]{\thepage} % Seitenzahl : rechts ungerade, links gerade

% ###### Title ######

\usepackage[explicit]{titlesec}
\newcommand{\hsp}{\hspace{20pt}}
% \titleformat{\chapter}[hang]{\Huge\bfseries\ }{\textcolor{CadetBlue}{\thechapter} #1}{20pt}{\Huge\bfseries\ }
\titleformat{name=\chapter,numberless}[hang]{\Huge\bfseries\ }{#1}{20pt}{\Huge\bfseries\ }
\titleformat{\chapter}[hang]{\Huge\bfseries\ }{\color{CadetBlue}\thechapter}{20pt}{\begin{tabular}[t]{@{\color{CadetBlue}\vrule width 2pt}>{\hangindent=20pt\hsp}p{\dimexpr 1\textwidth -44pt}}#1\end{tabular}}

\titleformat{name=\section,numberless}[hang]{\Large\bfseries\ }{#1}{32pt}{\Large\bfseries\ }
\titleformat{\section}[hang]{\Large\bfseries\ }{\color{CadetBlue}\thesection}{32pt}{\begin{tabular}[t]{p{\dimexpr 1\textwidth -44pt}}#1\end{tabular}}
\titleformat{name=\subsection,numberless}[hang]{\large\bfseries\ }{#1}{27pt}{\large\bfseries\ }
\titleformat{\subsection}[hang]{\large\bfseries\ }{\color{CadetBlue}\thesubsection}{27pt}{\begin{tabular}[t]{p{\dimexpr 1\textwidth -44pt}}#1\end{tabular}}

% ### fr 1 seitig
%\usepackage{fancyhdr} %
%\lhead{\textsf{\noupercase\leftmark}}
%\chead{}
%\rhead{\textsf{\nouppercase\rightmark}}
%\lfoot{}
%\cfoot{\textsf{\thepage}}
%\rfoot{}

\setkomafont{sectioning}{\rmfamily\bfseries}
\setcounter{tocdepth}{3}
%\setcounter{secnumdepth}{3}
% \input{settings/hyphenation} %% Manchmal bricht latex nicht richtig um. hier trennregeln rein.
% \includeonly{%
% % 	files/0_titlepage.tex
% % 	files/1_0_introduction,%
% % 	files/2_0_knownDCJ,%
% % 	files/3_0_DCJIndels,%
% % 	files/4_0_DCJIndels_1comps,%
% 	files/5_0_DCJIndels_2comps,%
% % 	files/6_0_implementation,%
% % 	files/7_0_evaluation%
% % 	,files/8_0_conclusion%
% }

%%%%%%%%%%%%%%% PANDOC-nedded defs %%%%%%%%%%
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

%disable "Redefining ngerman shorthand"-Message
% \makeatletter
% \patchcmd{\pdfstringdef}
%   {\csname HyPsd@babel@}
%   {\let\bbl@info\@gobble\csname HyPsd@babel@}
%   {}{}
% \makeatother

%%%%%%%%%%%%%%% Hauptdokument %%%%%%%%%%%%%%%
\begin{document}


% ###### Autoref definitions (hyperref package)#####
\def\subtableautorefname{Table}
\def\algorithmautorefname{Algorithm}
\def\chapterautorefname{Chapter}
\def\sectionautorefname{Section}
\def\definitionautorefname{Definition}
\def\exampleautorefname{Example}
\def\observationautorefname{Observation}
\def\propositionautorefname{Proposition}
\def\lemmaautorefname{Lemma}
% in diesem Dokument nicht verwendet:
% \def\subsectionautorefname{Subsection}
% \def\Subsubsectionautorefname{Subsubsection}
% \def\subfigureautorefname{Figure}
% \def\claimautorefname{Claim}

%%%%%%%%%%%%%%% Deckblatt %%%%%%%%%%%%%%%
\extratitle{}
	\input{files/titlepage}
	%\input{files/titlepage.pdf}	% Rueckseite leer
% 	\input{files/0_deckblatt/title}
	\pagestyle{empty} 	% Rueckseite leer
%
%%%%%%%%%%%%%%% Verzeichnisse %%%%%%%%%%%%%%%
\frontmatter % Abstrakte Gliederungsebene: Anfang des Buches
\renewcommand{\autodot}{}
\tableofcontents		% Rueckseite leer
%\lstlistoflistings % fuer listingsverzeichnis mit package listings

%%%%%%%%%%%%%%% Hauptteil %%%%%%%%%%%%%%%
% Insgesamt ca. 60-100 Seiten Davon mindesten 50% Eigene Arbeit
\mainmatter %Abstrakte Gliederungsebene: Hauptteil des Buches
\pagestyle{fancy}
\pagenumbering{arabic}
$body$

% \backmatter
\cleardoublepage

\renewcommand\thechapter{\Alph{chapter}}
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{\protect\numberline{}Appendix}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\setcounter{chapter}{0} % reset section to 1 so its stars I, II, III,...
\pagenumbering{roman}
%%%%%%%%%%%%%%% Literaturverzeichnis %%%%%%%%%%%%%%%
    \bibliographystyle{unsrtdin} % 	\bibliographystyle{natdin}
    \bibliography{bibma}
    % \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}Bibliography} % Literaturverzeichnis in das Inhaltsverzeichnis aufnehmen
    % \addtocounter{chapter}{1}
    \newpage

%%%%%%%%%%%%%%% Anhang %%%%%%%%%%%%%%%
%    \clearpage					%spaeter alles wieder rein
% % 		\input{files/appendix}
    \input{settings/abkuerzungen}
    % \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}Abbreviations}
    % \addtocounter{chapter}{1}
    \newpage

    % \listofalgorithms
    % \addcontentsline{toc}{section}{\protect\numberline{\thesection}List of Algorithms}
    % \addtocounter{section}{1}
    % \newpage
	%
	\listoffigures
    % \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}List of Figures}
    % \addtocounter{chapter}{1}
    \newpage
	% \listoftables
	\listoftodos
    % \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}TODOs}
    % \addtocounter{chapter}{1}
    \newpage
% 	\printindex

%%%%%%%%%%%%%%% Erklaerung %%%%%%%%%%%%%%%
% 	*\input{settings/declaration}
	\include{files/erklaerung}
\end{document}
