% !TeX encoding = UTF-8 Unicode
%% !TeX TS-program = make all
% !TeX TS-program = pdflatex
% !TeX root = report.tex
% !TeX spellcheck = en-GB
% !BIB program = bibtex
% MIT License - Copyright (c) 2021 Sergio Martínez-Losa
%
% IT IS MANDATORY TO HAVE TEX LIVE 2019 DISTRIBUTION INSTALLED TO COMPILE THIS TEMPLATE
%
%\documentclass[11pt,letterpaper,openright,spanish,english]{extbook}
\documentclass[11pt,a4paper,spanish,english]{book}
%\documentclass[11pt,a4paper,spanish,english]{book-unizar}
%\documentclass[11pt,a4paper,openright,spanish,english]{book}
\input{utils/super_macro}
%\SetInputPaths{%
% {./}%
% {./utils/}%
% {./utils/covers/}%
% {./chapters/}%
% {./packages/}%
%}
% Set whether twoside enable of not (true or false), by default twoside
%\twosidelayout[true] % select twoside layout
%\twosidelayout[false] % select oneside layout
\twosidelayout % default twoside layout active
%\onesidelayout % equivalent to \twosidelayout[false]
%\printunizartrue % margins READY to print by PRENSAS UNIZAR
\printunizarfalse % margins NOT READY to print by PRENSAS UNIZAR
\checkforceprintable
\input{utils/imports}
\input{utils/macros}
\input{utils/mute_warnings}
\showtodos{true}
%\setstretch{1.0}
% Show or hide watermark by calling \showwatermark{true} or \preliminary{true} both are equals
%\showwatermark{true}
%\preliminary{false}
% NECESSARY TITLE & AUTHOR
\title{\THETITLE}
\author{\THEAUTHOR}
\makeindex
\setglossarystyle{betterglossary}
\makeglossaries
\input{chapters/glossary}
\iffilepublications
\newcites{publications}{\listofpublicationsname\protect\thispagestyle{phdfancyempty}} % multibib bibliography section
\fi
\begin{document}
\thispagestyle{empty}
\pagenumbering{alph}
\setcounter{page}{-1}
% supress page numbering
%\pagenumbering{gobble}
% insert cover
% other fancy cover: https://tex.stackexchange.com/questions/475597/how-to-create-a-cover-page-like-this
% https://latexdraw.com/how-to-create-a-beautiful-cover-page-in-latex-using-tikz/
\begin{titlepage}
\pagestyle{empty}
\protect\thispagestyle{empty}
\ifx\printableimages\trueValue
\input{utils/cover_bw}
\else
% \input{utils/cover_colour}
\input{utils/cover_colour_alternative_rainbow}
% \input{utils/cover_colour_blue}
% \input{utils/cover_colour_blue_hexa}
% \input{utils/cover_colour_tschichold}
% \input{utils/cover_colour_tschichold_blue}
% \input{utils/cover_colour_blue_advanced}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \input{utils/cover_colour_red}
% \input{utils/cover_colour_red_advanced}
% \input{utils/cover_colour_red_advanced2}
\fi
\end{titlepage}
\frontmatter % apply TOC styles frontmatter
\pagenumbering{Roman}
\renewcommand{\contentsname}{Contents}
\SetHeaderTitle{\MakeUppercase{\contentsname}}
\protect\addtocontents{toc}{~\hfill\textbf{Page}\par\protect\thispagestyle{phdfancyempty}}
\protect\pagestyle{phdfancyspecialempty}
\ifexpandsubsublevel
\setcounter{secnumdepth}{4} % numbering depth for section levels
\else
\setcounter{secnumdepth}{2} % numbering depth for section levels
\fi
\tableofcontents
\clearpage
% https://tex.stackexchange.com/questions/48509/insert-list-of-figures-in-the-table-of-contents
\renewcommand{\listfigurename}{List of Figures}
\renewcommand{\figurename}{Figure}
\SetHeaderTitle{\MakeUppercase{\listfigurename}}
\protect\addtocontents{lof}{~\hfill\textbf{Page}\par\protect\thispagestyle{phdfancyempty}\vspace{0.4cm}}
\phantomsection\addcontentsline{toc}{chapter}{\listfigurename}
\protect\pagestyle{phdfancyspecialempty}\listoffigures
\clearpage
\renewcommand{\listtablename}{List of Tables}
\renewcommand{\tablename}{Table}
\SetHeaderTitle{\MakeUppercase{\listtablename}}
\protect\addtocontents{lot}{~\hfill\textbf{Page}\par\protect\thispagestyle{phdfancyempty}\vspace{0.4cm}}
\phantomsection\addcontentsline{toc}{chapter}{\listtablename}
\protect\pagestyle{phdfancyspecialempty}\listoftables
\clearpage
% Custom section - list of equations
\renewcommand{\listequationsname}{List of Equations}
\renewcommand{\equationname}{Equation}
\renewcommand{\equationpagetext}{Page}
\SetHeaderTitle{\MakeUppercase{\listequationsname}}
\protect\thispagestyle{phdfancyempty}
\phantomsection\addcontentsline{toc}{chapter}{\listequationsname}
\protect\pagestyle{phdfancyspecialempty}\listofequations
\clearpage
% show glossary items
\SetHeaderTitle{\MakeUppercase{\glossaryname}}
\phantomsection\addcontentsline{toc}{chapter}{\glossaryname}
\printglossary[title={\vspace{-1.5cm}\protect\raggedright\glossaryname}]\protect\pagestyle{phdfancyspecialempty}
\clearpage
% report declaration of authenticity
% #1 declaration without page numbers and without page number in TOC or declaration with page numers and page number in TOC
% #2 show or not to show in TOC
\inputdeclaration[true][true]
%% start abstract section
% #1 show page number or not
% #2 show or hide rule below title
% #3 show in TOC or not
% #4 input text file
\renewcommand{\abstractname}{Abstract}
\inputabstract[true][showrule]{true}{chapters/abstract}
%% end abstract section
% Acknowledgements and dedications
%\input{utils/dedications}
\mainmatter % apply TOC styles mainmatter
\begin{startpagenumbering}[1]
% \setstretch{1.5}
% \linespread{1.5}
\input{chapters/00_introduction}
%\input{chapters/01_first_chapter}
% \tocclearpage
\end{startpagenumbering}
\backmatter % apply TOC styles backmatter
%\forcestylebackmatter
% Check pagining with roman numerals
%\ContinuePaginingWithNumbering[Roman]
%% Custom section - Appendix I (OLD STYLE)
%\def\FirstAppendixTitle{Appendix I}
%%\SetHeaderTitle{\MakeUppercase{\FirstAppendixTitle}}
%\SetHeaderTitle{\FirstAppendixTitle}
%\phantomsection\addcontentsline{toc}{chapter}{\FirstAppendixTitle\itshape}
%\protect\pagestyle{phdfancyspecialappendix}
%%\protect\thispagestyle{phdfancyspecialappendixmain}
%%\protect\thispagestyle{phdfancyplain}
%\input{chapters/appendix_i}
%%\protect\thispagestyle{phdfancyspecialappendixmain}
%\clearpage
%
%% APPENDIX NEW STYLE
% https://tex.stackexchange.com/questions/183185/roman-numeral-of-defined-counter
\checkorcreatecounter{appendixcounter} % initialized to 0 by default
\newcommand{\Romanappendixcounter}{\Roman{appendixcounter}}
\newcommand{\stepappendixcounter}{\stepcounter{appendixcounter}}
%
%% Custom section - Appendix I - Script sample file
\stepappendixcounter
\def\FirstAppendixTitleTopLine{Appendix~\Romanappendixcounter}
\def\FirstAppendixTitleBottomLine{Title Appendix}
\def\FullAppendixFirstOneTitle{\FirstAppendixTitleTopLine~-~\FirstAppendixTitleBottomLine}
\SetHeaderTitle{\FullAppendixFirstOneTitle}
\phantomsection\addcontentsline{toc}{chapter}{\FullAppendixFirstOneTitle\itshape}
\protect\pagestyle{phdfancyspecialappendix}
%\protect\thispagestyle{phdfancyspecialappendixmain}
%\protect\thispagestyle{phdfancyplain}
\input{chapters/appendix_i}
%\protect\thispagestyle{phdfancyspecialappendixmain}
\clearpage
%
%% Custom section - Appendix II - Second Appendix
%\stepappendixcounter
%\def\SecondAppendixTitleTopLine{Appendix~\Romanappendixcounter}
%\def\SecondAppendixTitleBottomLine{Second Appendix}
%\def\FullAppendixSecondOneTitle{\SecondAppendixTitleTopLine~-~%\SecondAppendixTitleBottomLine}
%\SetHeaderTitle{\FullAppendixSecondOneTitle}
%\phantomsection\addcontentsline{toc}{chapter}{\FullAppendixSecondOneTitle\itshape}
%\protect\pagestyle{phdfancyspecialappendix}
%%\protect\thispagestyle{phdfancyspecialappendixmain}
%%\protect\thispagestyle{phdfancyplain}
%\input{chapters/appendix_ii}
%%\protect\thispagestyle{phdfancyspecialappendixmain}
%\clearpage
%
% Custom section - Epilogue
\def\epilogueTitle{Epilogue}
\SetHeaderTitle{\MakeUppercase{\epilogueTitle}}
\phantomsection\addcontentsline{toc}{chapter}{\epilogueTitle}
\protect\pagestyle{phdfancyspecialempty}\input{utils/epilogue}
\clearpage
% Bibliography
\SetTitleBibliography{Bibliography}
\SetHeaderTitle{\MakeUppercase{\bibname}}
%\protect\bibliographystyle{./packages/ieeetr-redux} % default bibliography style
\protect\bibliographystyle{unsrt}
\bibliography{./utils/report-bib}
\nocite{SergioTemplateLatex2021}
\protect\pagestyle{phdfancyspecialempty}
\addcontentsline{toc}{chapter}{\bibname}
\clearpage
% List of publications
\iffilepublications
\renewcommand{\listofpublicationsname}{List of Publications}
\SetHeaderTitle{\MakeUppercase{\listofpublicationsname}}
\phantomsection\addcontentsline{toc}{chapter}{\listofpublicationsname}
\protect\pagestyle{phdfancyspecialempty}
\nocitepublications{*}
% \protect\bibliographystylepublications{./packages/ieeetr-redux}
\protect\bibliographystylepublications{unsrt}
\bibliographypublications{./utils/publications}
\clearpage
\fi
\end{document}