% Title, Portuguese and English titles, and thesis year.
\newcommand{\authorname}{Rui Marcos\newline Brandão Antunes}
\newcommand{\englishtitle}{\LaTeX\ template for theses at University of Aveiro}
\newcommand{\portuguesetitle}{Template \LaTeX\ para teses na Universidade de Aveiro}
\newcommand{\thesisyear}{2021}

% To avoid wrong back references with the biblatex package.
\pagenumbering{alph}

% Cover page.
\TitlePage
  \HEADER{\BAR}{\thesisyear}
  \vspace*{14mm}
  \TITLE{\authorname}{\portuguesetitle}
  \vspace*{7mm}
  \TITLE{}{\englishtitle}
\EndTitlePage

% Empty page.
\titlepage\ \endtitlepage

% Initial thesis pages.
\TitlePage
  \HEADER{}{\thesisyear}
  \vspace*{14mm}
  \TITLE{\authorname}{\portuguesetitle}
  \vspace*{7mm}
  \TITLE{}{\englishtitle}
  \vspace*{15mm}
  \TEXT{}{Dissertação/Tese apresentada à Universidade de Aveiro para cumprimento dos requisitos necessários à obtenção do grau de Mestre/Doutor em X, realizada sob a orientação científica de Y, Professor do Departamento Z da Universidade de Aveiro.}
  \vspace*{\fill}
  \TEXT{}{Apoio financeiro (se aplicável)}
\EndTitlePage

% Empty page.
\titlepage\ \endtitlepage

\TitlePage
  \vspace*{55mm}
  \TEXT{\textbf{o júri~/~the jury\newline}}
       {}
  \TEXT{presidente~/~president}
       {\textbf{ABC}\newline {\small
        Professor Catedrático da Universidade de Aveiro (por delegação da Reitora da
        Universidade de Aveiro)}}
  \vspace*{5mm}
  \TEXT{vogais~/~examiners committee}
       {\textbf{DEF}\newline {\small
        Professor Catedrático da Universidade de Aveiro (orientador)}}
  \vspace*{5mm}
  \TEXT{}
       {\textbf{GHI}\newline {\small
        Professor associado da Universidade J (co-orientador)}}
  \vspace*{5mm}
  \TEXT{}
       {\textbf{KLM}\newline {\small
        Professor Catedrático da Universidade N}}
\EndTitlePage

% Empty page.
\titlepage\ \endtitlepage

\TitlePage
  \vspace*{55mm}
  \TEXT{\textbf{agradecimentos}}
       {...}
  \vspace*{5mm}
  \TEXT{\textbf{acknowledgments}}
       {...}
\EndTitlePage

% Empty page.
\titlepage\ \endtitlepage

\TitlePage
  \vspace*{55mm}
  \TEXT{\textbf{Palavras-chave}}{Chave, palavra.}
  \vspace*{5mm}
  \TEXT{\textbf{Resumo}}{Este é o primeiro parágrafo do resumo.\newline Segundo parágrafo.\newline Terceiro parágrafo.}
\EndTitlePage

% Empty page.
\titlepage\ \endtitlepage

\TitlePage
  \vspace*{55mm}
  \TEXT{\textbf{Keywords}}{Key, word.}
  \vspace*{5mm}
  \TEXT{\textbf{Abstract}}{This is the first paragraph of the abstract.\newline Second paragraph.\newline Third paragraph.}
\EndTitlePage

% Empty page.
\titlepage\ \endtitlepage

% Specifying header content. In this case it only shows chapter
% information: left position at even pages, right position at odd pages.
\setlength\headheight{16pt}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LO,RE]{\fontsize{12}{14.4}}
\fancyhead[LE,RO]{\fontsize{12}{14.4}\textsc{\nouppercase{\leftmark}}}

% To change the font size of the page numbering in all pages.
\fancyfoot[C]{\small\thepage}

% From the "fancyhdr" package documentation.
% "Some LATEX commands, like \chapter, use the \thispagestyle command to
% automatically switch to the plain page style, thus ignoring the page
% style currently in effect."

% The "fancyhdr" packages does not apply same header/footer on chapter
% and non-chapter pages.
% https://tex.stackexchange.com/questions/117328/fancyhdr-does-not-apply-same-header-footer-on-chapter-and-non-chapter-pages

\fancypagestyle{plain}{%
  % Clear all header and footer fields.
  \fancyhf{}
  % Except the center.
  \fancyfoot[C]{\small\thepage}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
}

% To specify 1x or 1.5x vertical spacing between lines.
% \singlespacing
\onehalfspacing

% Tables of contents, of figures, of tables.

% To count the following pages with roman numbering.
\pagenumbering{roman}

\tableofcontents
\cleardoublepage

\listoffigures
\cleardoublepage

\listoftables
\cleardoublepage

\begingroup
% To locally reduce vertical space between entries.
\setlist{itemsep=0pt,topsep=0pt,parsep=0pt,partopsep=0pt}
\printnoidxglossary
\endgroup
\cleardoublepage

% To specify 1x or 1.5x vertical spacing between lines.
% \singlespacing
\onehalfspacing

% The chapters.

% To count the following pages with arabic numerals.
\pagenumbering{arabic}
