%==============================================================
%
%      Maintainted at
%      https://github.com/E2-PhD-Council/ThesisTemplate
%
%==============================================================
% document class <<<
%==============================================================
%
%
\documentclass[
  paper=16.9cm:23.9cm,
    %paper=a4,
  pagesize,
  twoside,
  10pt,
  chapterprefix,
  headsepline=on,
  footinclude=off,
  DIV=18,
  BCOR=7mm,
  bibliography=totoc,
  numbers=noenddot,
  open=right,
]{scrreprt}
\usepackage[paperwidth=16.9cm,paperheight=23.9cm]{geometry} % used in cover page
\input{TemplateFiles/Packages.tex}
\usepackage{TemplateFiles/AddMyPapers}
\input{YourThesis/Packages.tex}
\input{YourThesis/Config.tex}
\newcommand{\ThesisTypePhD}{phd}
\newcommand{\ThesisTypeLic}{lic}
\ifx \TheThesisType\ThesisTypeLic
    \newcommand{\TheThesisTypeLong}{Licentiate of Engineering}
\else
    \newcommand{\TheThesisTypeLong}{Doctor of Philosophy}
    \ifx \TheThesisType\ThesisTypePhD \else
        \PackageError {ThesisTemplate} {Incorrect value of ``ThesisType``, choose either ``phd`` or ``lic``} {The variable ``ThesisType`` decides on the type of thesis to produce, choose ``phd`` to generate a PhD thesis or ``lic`` to generate a licentiate thesis.}
    \fi
\fi
\ifdefined \TheCoverPageSubtitle \if \TheCoverPageSubtitle\empty\else
    \ifdefined \TheSubtitle \if \TheSubtitle\empty\else
        \def\ConsistentSubtitle{true}
    \fi\fi
    \ifdefined \ConsistentSubtitle \else
        \PackageError {ThesisTemplate} {Definition of ``TheCoverPageSubtitle`` and ``TheSubtitle`` is inconsistent} {The variable ``TheCoverPageSubtitle`` can not be non-empty when the variable ``TheSubtitle`` is empty or undefined.}
    \fi
\fi\fi
%==============================================================
% Load all the packages needed
%==============================================================
%
\usepackage[ % this must be after author info!
	pdfcreator={LaTeX},	
	pdfkeywords={}, 
	pdfpagemode=UseOutlines, 
	pdfdisplaydoctitle=true, 
	pdflang=en, 
	colorlinks=false,	
	linkcolor=LinkColor, 
	citecolor=LinkColor, 
	filecolor=LinkColor, 
	urlcolor=LinkColor,
	menucolor=LinkColor, 
  bookmarks=true,
  bookmarksnumbered=true
]{hyperref}
\pdfstringdefDisableCommands{%
	% If hard space is used in the title, hyperref will issue warnings.
	% Warnings from other LaTeX characters can be supressed similarily.
	% https://tex.stackexchange.com/questions/10555/hyperref-warning-token-not-allowed-in-a-pdf-string
	\def~{ }%
}
\hypersetup{
	pdftitle={Thesis for \TheThesisType}, 
	pdfauthor={\TheAuthor}, 
	pdfsubject={\TheTitle}
}
\addbibresource{\ReferenceFile} % Reference list for Kappa or Monograph.
\usepackage{TemplateFiles/ChalmersThesis}
\newcommand{\needref}{\textcolor{red}{(source)}}
\hyphenation{nit-ri-fic-at-ion de-nit-ri-fic-at-ion bio-de-grad-ab-le re-im-ple-men-ted eu-tro-phi-ca-ti-on LibRAS bio-fil-ter}
\begin{document}
%==============================================================
% Part 0
% Includes:
% * cover page (temporary)
% * Title Page
% * ISSN Information
% * Dedication page
% * Abstract
% * Publication list
% * Acknowledgement
% * Table of Contents
%==============================================================
\pagestyle{plain.scrheadings}
%
%==============================================================
% Cover page
%==============================================================
\eject\pdfpagewidth=34.4cm\newgeometry{margin=0pt}
\input{TemplateFiles/cover/Chalmers_Cover}
\eject
\pdfpagewidth=16.9cm
\restoregeometry
%==============================================================
% Title Page
%==============================================================
\thispagestyle{empty}
\noindent\begin{minipage}[t][3cm][t]{\textwidth}
    \begin{center}
    \textsc{thesis for the degree of \MakeLowercase\TheThesisTypeLong}
    \vspace{0.5cm}
    \hrule
    \end{center}
\end{minipage}
\noindent\begin{minipage}[t][4cm][t]{\textwidth}
    \begin{center}
    {\LARGE {\TitlePageTitle}\par}
    \ifdefined \ISSNPageSubitle \if \ISSNPageSubitle\empty\else
        \vspace{.2 cm}
        {\normalsize\textit{\TitlePageSubtitle}\par}
    \fi\fi
    \end{center}
\end{minipage}
\noindent\begin{minipage}{\textwidth}
    \begin{center}
    {\large\textsc{\TitlePageName}\par}
    \end{center}
\end{minipage}
\noindent\begin{minipage}[b][4cm][t]{\textwidth}
    \begin{center}
    \includegraphics[width=5cm]{TemplateFiles/logos/title_page.jpg}
    \vfill
    %\vspace{0.5 cm}
    Department of \TheDepartment \\
    Chalmers University of Technology \\
    Gothenburg, Sweden, \TheYear
    \end{center}
\end{minipage}
\newpage
%==============================================================
% ISSN Information
%==============================================================
\thispagestyle{empty}
\noindent\textbf{\ISSNPageTitle}\\
\ifdefined \ISSNPageSubitle \if \ISSNPageSubitle\empty\else
    \noindent\footnotesize\textit{\ISSNPageSubitle}\\
\fi\fi\\
{\textsc{\ISSNPageName}}
\vspace{4.0 cm}\\
Copyright \copyright~\TheYear~\textsc{\ISSNPageName}\\ All rights reserved.\\
\vspace{1.5 cm}\\
Technical Report No.~\TheReportNo \\
ISSN \TheISSN\\
\vspace{1 cm}%
This thesis has been prepared using \LaTeX.\\
Department of \TheDepartment \\
Chalmers University of Technology \\
SE-412 96 Gothenburg, Sweden \\
Phone: +46 (0)31 772 1000 \\
\texttt{www.chalmers.se} \\
\vfill
\noindent{Printed by \ThePrinter \\
Gothenburg, Sweden, \TheMonth \TheYear}
\newpage
%==============================================================
% Dedication page
%==============================================================
\thispagestyle{empty}
\centerline{ }
\vspace{1cm}
\centerline{{\small \emph{\TheDedication}}}
\thispagestyle{empty}
\EmptyPage % back side of dedication
%==============================================================
% Abstract
%==============================================================
% Now we start numbering the pages, so tell hyperref that pages
% might be referred to.
\hypersetup{pageanchor=true}
\pagenumbering{roman}
\setcounter{page}{1}
% Reset parindent to original value
\setlength{\parindent}{1em}
\section*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\input{YourThesis/Abstract.tex}
\bigskip % This needs to go in its own paragraph -- don't remove blank line above
% Keywords list, notice first one beigns with capital and the list ends with full stop
\noindent\textbf{Keywords:} \TheKeyword
\EmptyPageWithNumber % back side of abstract
%==============================================================
% Publication list
%==============================================================
\setlength{\parindent}{0pt}
%To get the proper list of publications:
% compile the publication in a random tex file (call it mypub.tex)
% open the bbl file (this is the mypub.bbl)
% copy the bibitem and paste here
\section*{List of Publications}
\addcontentsline{toc}{chapter}{List of Papers}
\includelistofpapers
\setlength{\parindent}{1em}
\EmptyPageWithNumber % back side of publication list
%==============================================================
% Acknowledgments
%==============================================================
\section*{Acknowledgments}
\addcontentsline{toc}{chapter}{Acknowledgements}
\input{YourThesis/Acknowledgement.tex}
%==============================================================
% Acronyms
%==============================================================
\section*{Acronyms}
\vspace{1cm}
\addcontentsline{toc}{chapter}{Acronyms}
\input{YourThesis/Acronyms.tex}
%\clearpage
%\section*{Mathematical symbols}
%\vspace{1cm}
%\addcontentsline{toc}{chapter}{Mathematical symbols}
%\input{parts/symbols}
%==============================================================
% Table of Contents
%==============================================================
\tableofcontents
\clearpage
\EmptyPage
\setcounter{page}{1}
\renewcommand{\thepage}{\arabic{page}}
%==============================================================
% Part 1 : The overview
%==============================================================
\setcounter{secnumdepth}{1}
% Use the scrheadings from KOMA-script. Set the even (left page)
% header to display the chapter title. Odd pages (right page)
% display the section title.
\pagestyle{scrheadings}
\automark[section]{chapter}
\begin{refsection} % Bibliography Marker DNR
\part{Overview}
\input{YourThesis/Content.tex}
\printbibliography[title=References]
\end{refsection}
%==============================================================
% Part 2 : The papers
%==============================================================
\part{Papers}
\setcounter{secnumdepth}{2}
\initpapers
\renewcommand\bibname{References}
% Set the KOMA-script page headers to display Paper A on even
% (left) pages and section title on odd (right) pages.
\automark{chapter}
\renewcommand\sectionmark[1]{\markright{\MakeMarkcase {\thesection\hskip .5em\relax#1}}}
\rohead{\rightmark}
\lehead{Paper \Alph{paper}}
\rofoot{\pagemark}
\lefoot{\pagemark}
%==============================================================
% ADD YOUR PAPERS HERE: <<<
%==============================================================
\includepapers
%\includepaper{PaperTemplate}
%\includepaper{PaperDummy}
%==============================================================
% Your Thesis is Done. Congratz!
%==============================================================
\end{document}