%% Template
\documentclass{thesis}
\geometry{inner=30mm, outer=25mm, top=30mm, bottom=25mm}

%% Content
\usepackage[backend=biber, backref=true, doi=false, style=authoryear]{biblatex} % Bibliography
\addbibresource{references.bib}
\AtEveryBibitem{% Remove some fields from bibliography
    \clearfield{day}%
    \clearfield{location}%
    \clearfield{month}%
    \clearfield{series}%
}
\AtEveryCite{% Use square brackets for citations
  \let\bibopenparen=\bibopenbracket%
  \let\bibcloseparen=\bibclosebracket%
}

\usepackage{bookmark} % Manage bookmarks

\usepackage[draft, defaultColor=BlueViolet, xcolor=dvipsnames]{changes} % Track changes

\usepackage{enumitem} % Customise lists

\usepackage{etoc} % Local table of contents

\hypersetup{ % Hyperlinks
    bookmarksnumbered=true, % Include section numbers in bookmarks
    bookmarksopen=true, % Auto-open bookmarks
    pdfauthor   = {Erwan NORMAND},
    pdftitle    = {Wearable Haptics and Augmented Reality},
    pdfsubject  = {Ph.D. Thesis of Erwan NORMAND},
    pdfkeywords = {},
    pdfversion=1.7 % Fix /includefigure warnings
}

\usepackage{siunitx} % For numbers with units
\sisetup{
    retain-explicit-plus=true, % Keep + in numbers
    uncertainty-mode=separate % Separate uncertainty with +- instead of ()
}

\usepackage[dvipsnames]{xcolor} % More colors

%% Typography
% babel, csquotes, fontenc, microtype, lmodern, textcomp are already loaded by the class
\usepackage[varqu, varl]{inconsolata} % Better monospace font (with alternative quote [varqu] and l [varl])
\usepackage[ebgaramond,semibold,textscale=0,vvarbb,subscriptcorrection,amsthm,alth]{newtx} % Use Garamond font for text and math
\usepackage{microtype} % Micro-typography improvements (slightly more compact, better to read)

\allsectionsfont{\sffamily} % Sans-serif for section titles
\chapterfont{\sffamily} % Sans-serif for chapter titles

%% Custom commands
\input{utils/commands}

\definechangesauthor[color=RawSienna]{CP}
\newcommand{\CP}[1]{\comment[id=CP]{#1}}

\newcommand{\inputchapter}[1]{\clearemptydoublepage\input{#1}} % Load a chapter after a clear double page

\newcommand{\mainchapter}[2]{%
    \chapter{#2}%
    \label{ch:#1}%
    %
    \graphicspath{{#1/figures/}}% Load figures from the chapter folder
    %
    % Print the table of contents for the chapter
    \vspace*{-1cm}%
    \localtableofcontents%
    \par\noindent\rule{\textwidth}{0.4pt}%
    \vspace*{0.5cm}%
}

\newcommand*{\resetparts}{% End the parts in TOC to set chapters at the root level
    \bookmarksetup{startatroot}%
}

%% Document
\begin{document}

\selectlanguage{french}
\input{00-cover/cover}
\selectlanguage{english}

\frontmatter
\inputchapter{01-front/acknowledgement}
\inputchapter{01-front/abstract}
\inputchapter{01-front/résumé}
\inputchapter{01-front/publications}
\inputchapter{01-front/contents}
\inputchapter{01-front/acronyms}
\inputchapter{01-front/figures}
\inputchapter{01-front/tables}

\mainmatter
\inputchapter{11-introduction/introduction}
\inputchapter{12-related-work/related-work}
\inputchapter{13-chapitre2/chapitre2}
\inputchapter{14-conclusion/conclusion}

\backmatter
\clearemptydoublepage
\printbibliography[heading=bibintoc]

\inputchapter{20-back/backcover}

\end{document}
