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


%% 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{newtx} % Use Libertinus font for text and math
\usepackage{newtxmath}
\usepackage{microtype} % Micro-typography improvements (slightly more compact, better to read)
\usepackage{mathtools} % More math symbols

\linespread{1.15} % Set line spacing to 1.15


%% 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=Blue, xcolor=dvipsnames]{changes} % Track changes

\usepackage[inline]{enumitem} % Customise lists
\setitemize{noitemsep} % No space between items in itemize

\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         = {}
}

\usepackage{import}

\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

%% Tables
\usepackage{booktabs} % Better tables
\usepackage{makecell} % For multi-line cells in tables
\usepackage{multirow} % Multi-row cells in tables
\usepackage{tabularx} % For tables with fixed width


%% Custom commands
\input{utils/commands}

\renewcommand{\citeauthorcite}[1]{\citeauthor*{#1}~\parencite*{#1}}

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

\newcommand{\importchapter}[2]{% Load a chapter (#2) in a path (#1)
    \clearemptydoublepage% after a clear double page
    \graphicspath{{#1/figures/}}% with figures
    \includefrom{#1}{#2}% and relative paths \input in the chapter
}

\newcommand{\chaptertoc}{% 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}%
}

% Add chapter label as prefix to all other sub-labels
\NewCommandCopy{\oldlabel}{\label}
\newcommand{\labelprefix}{main}
\newcommand{\mainlabel}[1]{%
    \renewcommand{\labelprefix}{#1}%
    \oldlabel{\labelprefix}%
}
\renewcommand{\label}[1]{\oldlabel{\labelprefix:#1}}

% References
\newcommand{\chapref}[1]{Chapter~\ref{#1}}
\renewcommand{\eqref}[1]{Equation~\ref{\labelprefix:eq:#1}}
\renewcommand{\figref}[1]{Figure~\ref{\labelprefix:fig:#1}}
\newcommand{\partref}[1]{Part~\ref{#1}}
\renewcommand{\secref}[1]{Section~\ref{\labelprefix:sec:#1}}
\renewcommand{\tabref}[1]{Table~\ref{\labelprefix:tab:#1}}


%% Document
\begin{document}

\frontmatter
\selectlanguage{french}
\import{0-front/cover}{cover}
\selectlanguage{english}

\importchapter{0-front/content}{acknowledgement}
\importchapter{0-front/content}{toc}
\importchapter{0-front/content}{publications}
\importchapter{0-front/content}{acronyms}
\importchapter{0-front/content}{figures}
\importchapter{0-front/content}{tables}

\mainmatter
\import{1-introduction}{part}
\importchapter{1-introduction/introduction}{introduction}
\importchapter{1-introduction/related-work}{related-work}

\import{2-perception}{perception}
\importchapter{2-perception/xr-perception}{xr-perception}
\importchapter{2-perception/ar-textures}{ar-textures}

\import{3-manipulation}{manipulation}
\importchapter{3-manipulation/visual-hand}{visual-hand}
\importchapter{3-manipulation/visuo-haptic-hand}{visuo-haptic-hand}

\import{4-conclusion}{part}
\importchapter{4-conclusion}{conclusion}

\backmatter
\importchapter{4-conclusion}{bibliography}
\import{4-conclusion/backcover}{backcover}

\end{document}
