%%
%% UnBTeX: A class for bachelor, master, and doctoral thesis at the
%% University of Brasilia (UnB), Brazil
%% Version 1.6.3 2026/05/20
%% Copyright (C) 2021-2026 by Henrique C. Ferreira <hcferreira@unb.br>
%%
%% This class file may be distributed and/or modified under the conditions
%% of the LaTeX Project Public License, either version 1.3 of this license
%% or (at your option) any later version. The latest version of this
%% license is in:
%% 
%%   https://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%%
%% This distribution includes the class file unbtex.cls and the
%% bibliographic style package unbtexcite.sty
%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{unbtex}[2026/05/20 v1.6.3 Modelo da Universidade de Brasília baseado em abnTeX2]

% ------------------------------------------------------------------------
% Opções para a classe
% ------------------------------------------------------------------------

% ---
% Opção para definição de idioma principal
% ---
\newif\ifbrazilian
\braziliantrue % padrão
\DeclareOption{idioma=brazil}{\braziliantrue}
\DeclareOption{idioma=english}{\brazilianfalse}
% ---

% ---
% Opção para definição de estilo de referências bibliográficas
% ---
\newif\ifbibalf
\bibalftrue % padrão: autor-data (alf)
\DeclareOption{bib=alf}{\bibalftrue}
\DeclareOption{bib=num}{\bibalffalse}
% ---

% ---
% Opção para indicar as páginas que cada referência é citada
% ---
\newif\ifrefback
\refbackfalse % padrão: desabilitada
\DeclareOption{refback}{\refbacktrue}
% ---

% ---
% Opção para dividir o documento em seções ao invés de capítulos
% ---
\newif\ifchapnamesec
\chapnamesecfalse % padrão: desabilitada
\DeclareOption{chapnamesec}{\chapnamesectrue}
% ---

% ---
% Opção para definição de estilo de numeração de figuras, tabelas, etc
% ---
\newif\ifnumtradicional
\numtradicionaltrue % padrão: num=chap
\DeclareOption{num=tradicional}{\numtradicionaltrue}
\DeclareOption{num=abnt}{\numtradicionalfalse}
% ---

% ---
% Opções de diagramação de sumários da classe abntex2
% sumario=tradicional: Sumário tradicional do LaTeX/Memoir
% sumario=abnt       : Sumário conforme normas da ABNT
% ---
\newif\ifABNTEXsumariotradicional
\newif\ifABNTEXsumarioabnt
\ABNTEXsumarioabnttrue
\ABNTEXsumariotradicionalfalse
\DeclareOption{sumario=tradicional}{\ABNTEXsumariotradicionaltrue\ABNTEXsumarioabntfalse}
\DeclareOption{sumario=abnt}{\ABNTEXsumarioabnttrue\ABNTEXsumariotradicionalfalse}
% ---

% ---
% Opção para títulos de capítulos em letras maiúsculas
% ---
\newif\ifABNTEXupperchapter
\ABNTEXupperchapterfalse
\DeclareOption{chapter=TITLE}{\ABNTEXupperchaptertrue}
% ---

% ---
% Define as opções article e twocolumn da classe abntex2
% ---
% Opção article
\newif\ifABNTEXisarticle
\ABNTEXisarticlefalse % padrão: desabilitada
\DeclareOption{article}{%
  \ABNTEXisarticletrue
  \PassOptionsToClass{article}{memoir}%
}
% Opção twocolumn
\newif\ifABNTEXistwocolumn
\ABNTEXistwocolumnfalse % padrão: desabilitada
\DeclareOption{twocolumn}{%
  \ABNTEXistwocolumntrue
  \PassOptionsToClass{twocolumn}{memoir}
}
% ---

% ---
% Repassa demais opções à classe memoir
% ---
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{memoir}}
\ProcessOptions\relax
\newcommand{\abntex@fontsize}{12pt}
\ifABNTEXisarticle\ifABNTEXistwocolumn
  \renewcommand{\abntex@fontsize}{11pt}%
\fi\fi
\LoadClass[a4paper,\abntex@fontsize]{memoir}
% ---

% ------------------------------------------------------------------------
% Configurações básicas
% ------------------------------------------------------------------------

% ---
% Pacotes matemáticos
% ---
\RequirePackage{mathtools} % Melhoria nas equações
\RequirePackage{amsthm} % Para configuração de ambientes do tipo teorema
% ---

% ---
% Pacotes de fontes tipográficas
% ---
\RequirePackage{stickstootext} % Fonte principal (Stix2)
\RequirePackage[stickstoo,vvarbb]{newtxmath} % Fonte matemática (Stix2)
\RequirePackage{bm} % Negrito em fontes matemáticas
\RequirePackage[scale=0.90]{tgheros} % Fonte sans serif (TeX Gyre Heros)
\RequirePackage[scale=1]{inconsolata} % Fonte monoespaçada
% Tamanho das fontes
\newcommand{\ABNTEXfontereduzida}{\footnotesize}
\newcommand{\ABNTEXchapterfont}{\sffamily}
\newcommand{\ABNTEXchapterfontsize}{\Huge}
\newcommand{\ABNTEXpartfont}{\ABNTEXchapterfont}
\newcommand{\ABNTEXpartfontsize}{\ABNTEXchapterfontsize}
\newcommand{\ABNTEXsectionfont}{\ABNTEXchapterfont}
\newcommand{\ABNTEXsectionfontsize}{\Large}
\newcommand{\ABNTEXsubsectionfont}{\ABNTEXsectionfont}
\newcommand{\ABNTEXsubsectionfontsize}{\large}
\newcommand{\ABNTEXsubsubsectionfont}{\ABNTEXsubsectionfont}
\newcommand{\ABNTEXsubsubsectionfontsize}{\normalsize}
\newcommand{\ABNTEXsubsubsubsectionfont}{\ABNTEXsubsectionfont}
\newcommand{\ABNTEXsubsubsubsectionfontsize}{\normalsize}
% Comandos para controlar as opções de títulos com letras maiúsculas 
\newcommand{\ABNTEXchapterupperifneeded}[1]%
  {\ifABNTEXupperchapter\MakeTextUppercase{#1}\else#1\fi}
% ---

% ---
% Cores verde e azul UnB
% ---
% Define cores da UnB
\RequirePackage[dvipsnames]{xcolor}
\definecolor{verdeunb}{cmyk}{1,0,1,0.2}
\definecolor{azulunb}{cmyk}{1,0.65,0,0.35}
% ---

% ---
% Controla os bookmarks do pdf
% ---
\RequirePackage{bookmark}   			
% Comando para registro do bookmark interno
\newcounter{abntex@bookmarkcounter}
\setcounter{abntex@bookmarkcounter}{0}
\newcommand{\PRIVATEbookmarkthis}[1]{%
  \addtocounter{abntex@bookmarkcounter}{1}%
  \phantomsection\pdfbookmark[0]{#1}{chapterb\arabic{abntex@bookmarkcounter}}
}
% Comando que cria capítulos não numerados já com bookmark anotado
\newcommand{\pretextualchapter}[1]{%
  \addtocounter{abntex@bookmarkcounter}{1}%
  \PRIVATEbookmarkthis{#1}%
  \chapter*[#1]{#1}%
}
\newif\ifabntex@apendiceousecao
\abntex@apendiceousecaofalse
% cleardoublepage se este documento não for article
\newcommand{\PRIVATEclearpageifneeded}%
  {\ifABNTEXisarticle \else \cleardoublepage \fi}%
% ---

% ---
% Configurações do sumário
% ---
% nível de profundidade (implementa o quinto nível - subsubsubsection)
\setsecnumdepth{paragraph}
\settocdepth{paragraph}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\maxsecnumdepth{paragraph}
% redefine os comandos \paragraph para \subsubsubsection
\newcommand{\subsubsubsection}{\paragraph}
\newcommand{\cftbeforesubsubsubsectionskip}{\cftbeforeparagraphskip}
\newcommand{\cftsubsubsubsectionfont}{\cftparagraphfont}
\newcommand{\setsubsubsubsecheadstyle}{\setparaheadstyle}
\setparaheadstyle{\normalfont\sffamily\raggedright}%
\setafterparaskip{\aftersubsubsecskip}
% fonte das partes e dos capítulos no sumário
\renewcommand{\tocheadstart}{\ABNTEXchapterfont}
\renewcommand{\cftpartfont}{\bfseries\sffamily}
\renewcommand{\cftpartpagefont}{\cftpartfont}
\renewcommand{\cftchapterfont}{\bfseries\sffamily}
\renewcommand{\cftchapterpagefont}{\cftchapterfont}
\ifABNTEXupperchapter
  \let\oldcontentsline\contentsline
  \renewcommand{\contentsline}[4]{%
    \ifthenelse{%
      \equal{#1}{chapter} \OR \equal{#1}{part} \OR \equal{#1}{appendix} \OR \equal{#1}{annex}%
    }%
    {\oldcontentsline{#1}{\MakeTextUppercase{\texorpdfstring{#2}{#2}}}{#3}{#4}}%
    {\oldcontentsline{#1}{#2}{#3}{#4}}%
  }
\fi
% leaders para os capítulos
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
% suprime espaço entre os itens de listings de diferentes capítulos 
\setlength{\cftbeforechapterskip}{0pt plus 0pt}
\renewcommand*{\insertchapterspace}{}
% macros para configurar o sumário conforme abnt ou tradicional
\newlength{\cftlastnumwidth}
\setlength{\cftlastnumwidth}{\cftsubsubsectionnumwidth}
\addtolength{\cftlastnumwidth}{1em}
% No caso de sumário tradicional
\ifABNTEXsumariotradicional
  \settocdepth{subsection}
  \setlength{\cftbeforechapterskip}{5pt plus 1pt minus 1pt}
  \setlength{\cftbeforepartskip}{10pt plus 2pt minus 2pt}
  \newcommand{\tocprintchapter}{}
  \newcommand{\tocinnonumchapter}{}
  \newcommand{\tocprintchapternonum}{}
  \newcommand{\tocpartapendices}{%
    \addtocontents{toc}{\cftsetindents{chapter}{0em}{2em}
    \protect\renewcommand{\protect\cftchapteraftersnum}{\hfill\textendash\hfill}}}
  \newcommand{\tocpartanexos}{%
    \addtocontents{toc}{\cftsetindents{chapter}{0em}{2em}
    \protect\renewcommand{\protect\cftchapteraftersnum}{\hfill\textendash\hfill}}}
\fi
% No caso de sumário abnt
\ifABNTEXsumarioabnt
  % fontes seções (até o quinto nível) do sumário
  \renewcommand{\cftsectionfont}{\bfseries\sffamily}
  \renewcommand{\cftsectionpagefont}{\cftsectionfont}
  \renewcommand{\cftsubsectionfont}{\normalsize}
  \renewcommand{\cftsubsectionpagefont}{\cftsubsectionfont}
  \renewcommand{\cftsubsubsectionfont}{\small}
  \renewcommand{\cftsubsubsectionpagefont}{\cftsubsubsectionfont}
  \renewcommand{\cftparagraphfont}{\footnotesize}
  \renewcommand{\cftparagraphpagefont}{\cftparagraphfont}
  % recuo das entradas do sumário
  \cftsetindents{part}{0em}{\cftlastnumwidth}
  \cftsetindents{chapter}{0em}{\cftlastnumwidth}
  \cftsetindents{section}{0em}{\cftlastnumwidth}
  \cftsetindents{subsection}{0em}{\cftlastnumwidth}
  \cftsetindents{subsubsection}{0em}{\cftlastnumwidth}
  \cftsetindents{paragraph}{0em}{\cftlastnumwidth}
  \cftsetindents{subparagraph}{0em}{\cftlastnumwidth}
  \newcommand{\tocprintchapter}{%
    \addtocontents{toc}{\cftsetindents{chapter}{0em}{\cftlastnumwidth}}}
  \newcommand{\tocinnonumchapter}{%
    \addtocontents{toc}{\cftsetindents{chapter}{\cftlastnumwidth}{2em}
    \protect\renewcommand{\protect\cftchapteraftersnum}{\hfill\textendash\hfill}}}
  \newcommand{\tocprintchapternonum}{%
    \addtocontents{toc}{\cftsetindents{chapter}{\cftlastnumwidth}{2em}}}%
  \newcommand{\tocpartapendices}{%
    \addtocontents{toc}{\cftsetindents{part}{\cftlastnumwidth}{2em}
    \protect\renewcommand{\protect\cftchapteraftersnum}{\hfill\textendash\hfill}}}
  \newcommand{\tocpartanexos}{%
    \addtocontents{toc}{\cftsetindents{part}{\cftlastnumwidth}{2em}
    \protect\renewcommand{\protect\cftchapteraftersnum}{\hfill\textendash\hfill}}}
  \setlength{\cftbeforechapterskip}{1em}
  % Ajusta entrada Referências
  \renewcommand{\bibsection}{%
  \chapter*{\bibname}%
  \bibmark%
  \ifnobibintoc\else%
    \phantomsection%
    \addcontentsline{toc}{chapter}{\texorpdfstring{\ABNTEXchapterupperifneeded{\bibname}}{\bibname}}%
  \fi%
  \prebibhook%
  }
\fi
% Comando que simula a finalização de uma parte no bookmark e adiciona espaco de \part no sumário
\newcommand{\phantompart}{%
  \bookmarksetup{startatroot}%
  \phantomsection%
  \ifABNTEXsumarioabnt
    \addtocontents{toc}{\vspace{\cftbeforechapterskip}}%
  \else
    \addtocontents{toc}{\vspace{\cftbeforepartskip}}%
  \fi
}
% ---

% ---
% Definição do estilo abnt para títulos de capítulos
% ---
% Cores nos títulos
\renewcommand{\tocheadstart}{}
\renewcommand{\ABNTEXchapterfont}{\bfseries\color{verdeunb}\sffamily}
\renewcommand{\ABNTEXsubsectionfont}{}
% Novo estilo do memoir 
\newif\ifabntex@innonumchapter
\abntex@innonumchaptertrue
\makechapterstyle{abnt}{%
  \renewcommand{\chapterheadstart}{} 
  \ifx \chapternamenumlength \undefined
    \newlength{\chapternamenumlength}
  \fi
  % tamanhos de fontes de chapter e part	
  \ifABNTEXisarticle
    \setlength{\beforechapskip}{3.5ex \@plus 1ex \@minus 0.2ex}
    \renewcommand*{\chapterheadstart}{\addvspace{\beforechapskip}}
    \setlength{\afterchapskip}{2.3ex \@plus 0.2ex}
    \renewcommand{\chaptitlefont}{\ABNTEXsectionfont\ABNTEXsectionfontsize}
  \else
    \setlength{\beforechapskip}{0pt}
    \renewcommand{\chaptitlefont}{\ABNTEXchapterfont\ABNTEXchapterfontsize}
  \fi
  \renewcommand{\chapnumfont}{\chaptitlefont}
  \renewcommand{\parttitlefont}{\ABNTEXpartfont\ABNTEXpartfontsize\ABNTEXchapterupperifneeded}
  \renewcommand{\partnumfont}{\ABNTEXpartfont\ABNTEXpartfontsize}
  \renewcommand{\partnamefont}{\ABNTEXpartfont\ABNTEXpartfontsize\ABNTEXchapterupperifneeded}
  % tamanhos de fontes de section, subsection, subsubsection e subsubsubsection
  \setsecheadstyle{\ABNTEXsectionfont\ABNTEXsectionfontsize}
  \setsubsecheadstyle{\ABNTEXsubsectionfont\ABNTEXsubsectionfontsize}
  \setsubsubsecheadstyle{\ABNTEXsubsubsectionfont\ABNTEXsubsubsectionfontsize}
  \setsubsubsubsecheadstyle{\ABNTEXsubsubsubsectionfont\ABNTEXsubsubsubsectionfontsize}
  % impressão do número do capítulo
  \renewcommand{\chapternamenum}{}
  % impressão do nome do capítulo
  \renewcommand{\printchaptername}{%
    \chaptitlefont
    \ifABNTEXisarticle\else
      \ifabntex@apendiceousecao\ABNTEXchapterupperifneeded\appendixname\space\fi
    \fi
  }
  % impressão do título do capítulo
  \def\printchaptertitle##1{%
    \chaptitlefont%
    \settowidth{\chapternamenumlength}{\printchaptername\printchapternum\afterchapternum}%
    \ifabntex@innonumchapter%
      \centering\ABNTEXchapterupperifneeded{##1}%
    \else%
      \ifabntex@apendiceousecao%
        \centering\ABNTEXchapterupperifneeded{##1}%
      \else%
        \parbox[t]{\dimexpr\columnwidth-\chapternamenumlength\relax}%
          {\ABNTEXchapterupperifneeded{##1}}%
      \fi%
    \fi%
  }
  % impressão do número do capítulo     	
  \renewcommand{\printchapternum}{%
    \tocprintchapter%
    \abntex@innonumchapterfalse%
    \chapnumfont\thechapter\space%
    \ifabntex@apendiceousecao%
      \tocinnonumchapter\space\textendash\space%
    \fi%
    \space%
  }
  \renewcommand{\afterchapternum}{}
  % impressão do capítulo não numerado
  \renewcommand\printchapternonum{%
    \tocprintchapternonum%
    \abntex@innonumchaptertrue%
  }
}
\chapterstyle{abnt}
% ---

% ---
% Configurações gerais de layout
% ---
\OnehalfSpacing
\setlength{\parindent}{1cm}
\ifABNTEXistwocolumn \ABNTEXisarticletrue \fi
\ifABNTEXisarticle
  \chapnamesectrue
  \setlength{\droptitle}{-2em}
  %\addtolength{\droptitle}{-1.5\baselineskip}
  \renewcommand{\maketitlehookb}{\LARGE\center\textit{\theforeigntitle}}
  \renewcommand{\maketitlehookb}{\vskip -1.5\topsep\vskip -1.5\partopsep}
  \renewcommand{\maketitlehookd}{\vskip -0.8em}
  \pretitle{\begin{center}\color{verdeunb}\LARGE\sffamily\bfseries}
  \posttitle{\par\end{center}\vskip 0.5em}
  \renewcommand{\and}{\unskip, }
  \renewcommand{\abstracttextfont}{\normalfont\normalsize}
  \setlength\absleftindent{0cm}
  \setlength\absrightindent{0cm}
  \renewcommand{\chapternamenum}[1]
    {\ifanappendix \chaptitlefont\ABNTEXchapterupperifneeded\appendixname~#1\else #1\fi}
  \renewcommand{\chaptitlefont}{\bfseries\sffamily\Large\color{verdeunb}}
  \setsecheadstyle{\large\bfseries\sffamily\color{verdeunb}}
  \setsubsecheadstyle{\normalfont\bfseries\sffamily}
  \ifABNTEXistwocolumn
    \SingleSpacing
    \setlength{\parindent}{0.75cm} % Tamanho da indentação da primeira linha do parágrafo
    \setlength{\columnsep}{0.75cm}
    \def\@mathmargin{0pt}
    \setlrmarginsandblock{1.5cm}{1.5cm}{*} % Margens esquerda e direita
    \setulmarginsandblock{2.5cm}{2cm}{*} % Margens superior e inferior
    \checkandfixthelayout[nearest]
  \else
    \setlength{\parskip}{2pt plus 1pt minus 1pt} % Espaço entre parágrafos
    \setlrmarginsandblock{2.5cm}{2.5cm}{*}
    \setulmarginsandblock{3cm}{2cm}{*}
    \checkandfixthelayout[nearest]
  \fi
\else% Opção article não utilizada
  \setlength{\parskip}{2pt plus 1pt minus 1pt}
  \setlrmarginsandblock{3cm}{2cm}{*}
  \setulmarginsandblock{3cm}{2cm}{*}
  \checkandfixthelayout[nearest]
\fi
% ---

% ---
% Configurações de estilo e de cabeçalho das páginas
% ---
% Cabeçalho padrão abntex2
\makepagestyle{abntheadings}
\makeevenhead{abntheadings}{\ABNTEXfontereduzida\thepage}{}{\ABNTEXfontereduzida\textit\leftmark}
\makeoddhead{abntheadings}{\ABNTEXfontereduzida\textit\rightmark}{}{\ABNTEXfontereduzida\thepage}
\makeheadrule{abntheadings}{\textwidth}{\normalrulethickness}
% Cabeçalho padrão unbtex
\makepagestyle{simple} % Cabeçalho com número de página e linha horizontal
\makeevenhead{simple}{\footnotesize\thepage}{}{}
\makeoddhead{simple}{}{}{\footnotesize\thepage}
\makeheadrule{simple}{\textwidth}{\normalrulethickness}
\makepagestyle{plain} % Cabeçalho com número de página e sem linha horizontal
\makeevenhead{plain}{\footnotesize\thepage}{}{}
\makeoddhead{plain}{}{}{\footnotesize\thepage}
% Cabecalho da primeira página do capitulo
\makepagestyle{abntchapfirst}
\makeoddhead{abntchapfirst}{}{}{\ABNTEXfontereduzida\thepage}
% Configura layout para elementos pre-textuais
\newcommand{\pretextual}{%
  \aliaspagestyle{chapter}{empty}
  \pagestyle{empty}
  \aliaspagestyle{cleared}{empty}
  \aliaspagestyle{part}{empty}
}
\renewcommand{\frontmatter}{\pretextual} 
% Configura layout para elementos textuais
\newcommand{\textualabntex}{% cabeçalho padrão abntex2
  \ifABNTEXisarticle%
    \pagestyle{plain}%
  \else
    \pagestyle{abntheadings}%
    \aliaspagestyle{chapter}{abntchapfirst}
  \fi 
  \nouppercaseheads%
  \bookmarksetup{startatroot}% 
}
\newcommand{\textual}{%
  \ifABNTEXisarticle
    \pagestyle{plain}
  \else 
    \pagestyle{simple}
    \aliaspagestyle{chapter}{abntchapfirst}
  \fi 
}
\renewcommand{\mainmatter}{\textual}
% Configura layout para elementos pos-textuais
\newcommand{\postextual}{\phantompart}
\renewcommand{\backmatter}{\postextual}
% ---

% ---
% Configurações do texto
% ---
\RequirePackage{indentfirst} % Indenta o primeiro parágrafo de cada seção.
\RequirePackage[disable=ifdraft,protrusion=false]{microtype} % Para melhorias de justificação
\RequirePackage{icomma} % Configura casas decimais separadas por vírgula
\frenchspacing % Retira espaço extra entre as frases (após o ponto final)
% Espaçamento para notas de rodapé
\setlength{\footmarkwidth}{1.2em} % largura do footnotemark
\setlength{\footmarksep}{0em}
\footmarkstyle{\footnotesize{\textsuperscript{#1}}\hfill}
\renewcommand{\foottextfont}{\ABNTEXfontereduzida} % tamanho da fonte do footnote
\setlength{\skip\footins}{20pt plus 2pt minus 2pt} % Espaço entre o texto e as notas de rodapé
\addtolength{\footnotesep}{2pt} % Espaço entre as notas de rodapé
\renewcommand*{\footnoterule}{\kern-3pt \hrule width 5cm \kern 2.6pt} % Tamanho do traço superior (5cm)
% Ajusta espaço entre texto e figuras/tabelas
\setlength{\textfloatsep}{14pt plus 2pt minus 2pt} % Espaçamento entre texto e floats no topo/base da página
\setlength{\floatsep}{12pt plus 2pt minus 2pt} % Espaçamento entre floats
\setlength{\intextsep}{14pt plus 2pt minus 2pt} % Espaçamento entre texto e floats no meio da página
% Ambiente para alineas, subalineas e incisos
\RequirePackage{enumitem}
\newlist{alineas}{enumerate}{2}
\setlist[alineas,1]{label={\alph*)},topsep=1pt,itemsep=0pt,parsep=1pt,partopsep=1pt,leftmargin=\parindent}
\setlist[alineas,2]{label={--},topsep=0pt,itemsep=0pt,leftmargin=*}
\newlist{subalineas}{enumerate}{1}
\setlist[subalineas,1]{label={--},topsep=0pt,itemsep=0pt,leftmargin=*}%
\newlist{incisos}{enumerate}{1}
\setlist[incisos,1]{label={--},topsep=0pt,itemsep=0pt,leftmargin=*}%
% Ajusta espaçamento nos ambientes itemize, enumerate e description
\setlist[itemize,enumerate,description]{topsep=1pt,itemsep=0pt,parsep=1pt,partopsep=1pt,leftmargin=\parindent}
% Numeração de figuras, tabelas, etc. por capítulo ou para o documento inteiro
\AddToHook{begindocument/end}{% Estilo de numeração de figuras, tabelas, etc.
\ifnumtradicional
  \numberwithin{equation}{chapter}
  \numberwithin{figure}{chapter}
  \numberwithin{table}{chapter}
\else% Numeração para o documento inteiro (padrão ABNT)
  \counterwithout{equation}{chapter}
  \counterwithout{figure}{chapter}
  \counterwithout{table}{chapter}
  \counterwithout{quadro}{chapter}
  \counterwithout{lstlisting}{chapter}
  \counterwithout{algocf}{chapter}
  \counterwithout{theorem}{chapter}
  \counterwithout{lemma}{chapter}
  \counterwithout{proposition}{chapter}
  \counterwithout{corollary}{chapter}
  \counterwithout{definition}{chapter}
  \counterwithout{assumption}{chapter}
  \counterwithout{example}{chapter}
  \counterwithout{remark}{chapter}
\fi
}
% Modifica o tamanho da fonte e espaçamento entre linhas no ambiente verbatim
\RequirePackage{fvextra}
\renewenvironment{verbatim}{\VerbatimEnvironment
  \begin{Verbatim}[fontsize=\footnotesize,baselinestretch=1.08]}
  {\end{Verbatim}}%
\fvset{listparameters=\setlength{\topsep}{4pt}\setlength{\partopsep}{0pt}}
% Citação direta com mais de 3 linhas - ABNT NBR 10520
\newlength{\ABNTEXcitacaorecuo}
\ifABNTEXistwocolumn \setlength{\ABNTEXcitacaorecuo}{1.8cm} 
\else \setlength{\ABNTEXcitacaorecuo}{4cm} \fi
\newenvironment*{citacao}[1][]{%
  \begin{adjustwidth}{\ABNTEXcitacaorecuo}{0cm}%
  \ABNTEXfontereduzida\vspace{4pt}%
  \begin{SingleSpace}%
  \if\relax\detokenize{#1}\relax
  \else
    \itshape\foreignlanguage{#1}%
  \fi
}{%
  \end{SingleSpace}\vspace{4pt}%
  \end{adjustwidth}
}
% ---

% ---
% Definições compartilhadas entre Apêndices e Anexos
% ---
\newcommand\@switch[1]{\@writefile{toc}{\renewcommand*{\cftappendixname}{#1\space}}}
\newcommand{\switchchapname}[1]{\protected@write\@auxout{}{\string\@switch{#1}}}
\newcommand{\PRIVATEapendiceconfig}[2]{%
  \abntex@apendiceousecaotrue%
  \renewcommand{\appendixname}{#1}
  \renewcommand{\appendixpagename}{#2}
  \renewcommand{\appendixtocname}{\texorpdfstring{\ABNTEXchapterupperifneeded{#2}}{#2}}%
  \switchchapname{\texorpdfstring{\ABNTEXchapterupperifneeded{#1}}{#1}}%
  \renewcommand*{\cftappendixname}{#1\space}
}
% Apêndices
\newcommand{\apendices}{%
  \PRIVATEapendiceconfig{\Apendicename}{\Apendicesname}
  \appendix
}
\newenvironment{apendicesenv}{%
  \PRIVATEapendiceconfig{\Apendicename}{\Apendicesname}
  \crefalias{chapter}{appendix} % Adicionado
  \begin{appendix}
}{
  \end{appendix}
  \abntex@apendiceousecaofalse
  \bookmarksetup{startatroot}
}
% Anexos
\newcommand{\anexos}{%
  \PRIVATEapendiceconfig{\Anexoname}{\Anexosname}
  \appendix
  \renewcommand\theHchapter{anexochapback.\arabic{chapter}}
}
\newenvironment{anexosenv}{%
  \PRIVATEapendiceconfig{\Anexoname}{\Anexosname}
  \crefalias{chapter}{annex}%
  \begin{appendix}
  \renewcommand\theHchapter{anexochapback.\arabic{chapter}}
}{%
  \end{appendix}
  \abntex@apendiceousecaofalse
  \bookmarksetup{startatroot}
}
% Imprime uma página de divisão no estilo parte
\newcommand{\partpage}{%
  \cleardoublepage
  \phantomsection
  \addcontentsline{toc}{part}{\appendixtocname}%
  \appendixpage*
}
% Atalhos para \partpage ou \appendixpage* 
\newcommand{\partapendices}{%
  \tocpartapendices%
  \@ifstar{\appendixpage*}{\partpage}
}
\newcommand{\partanexos}{%
  \tocpartanexos%
  \@ifstar{\appendixpage*}{\partpage}
}
% ---

% ---
% Configurações das legendas de figuras e tabelas
% ---
\RequirePackage{subcaption} % Permite fazer subfiguras
\captionsetup{font=small,format=hang,labelsep=endash,aboveskip=6pt,belowskip=6pt}
\subcaptionsetup{position=top,aboveskip=8pt,belowskip=4pt}
% Define o comando \IBGEtab{}{}{} com caption e legenda da largura do conteúdo tabular, tabular*, etc
\newsavebox{\myptabbox}
\newlength{\myptabboxwidth}
\newcommand{\IBGEtab}[3]{%
  \savebox{\myptabbox}{\ABNTEXfontereduzida #2}%
  \settowidth{\myptabboxwidth}{\usebox{\myptabbox}}%
  \parbox{\myptabboxwidth}{%
    #1\par%
    {\captionsetup{justification=justified,singlelinecheck=false}%
    \ABNTEXfontereduzida #2\par%
    #3}%
  }%
}
% Espaçamento vertical do comando \legend
\renewcommand{\legend}[2][]{%
  \par
  \begingroup
    \captionsetup{position=bottom,font=footnotesize,labelsep=space,aboveskip=6pt,belowskip=0pt}%
    \@makecaption{#1}{#2}%
    \par
  \endgroup
}
% Espaçamento vertical do comando \fonte (e de \nota)
\newcommand{\fonte}[2][\fontename]{%
  \M@gettitle{#2}%
  \memlegendinfo{#2}%
  \par
  \begingroup
    \captionsetup{position=bottom,font=footnotesize,labelsep=colon,aboveskip=6pt,belowskip=0pt}%
    \@makecaption{#1}{#2}%
  \endgroup
}
% Define o comando \notas que respeita as configurações de caption do memoir ou do caption
\newcommand{\nota}[2][\notaname]{\fonte[#1]{#2}}
% ---

% ---
% Configurações para tabelas e quadros
% ---
\RequirePackage{longtable}% Para tabelas com quebra de página
\RequirePackage{multirow} % Para combinar linhas nas tabelas
\RequirePackage{colortbl} % Permite alterar cores de linhas e células das tabelas
\arrayrulecolor{verdeunb} % Define a cor das linhas das tabelas
\setlength\arrayrulewidth{0.6pt} % Define a espessura das linhas das tabelas
% Alinhamento em colunas com especificação de largura
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
% Criação dos ambientes flutuantes para quadros
\newfloat[chapter]{quadro}{loq}{\Quadroname}
\newlistof{listofquadros}{loq}{\listquadroname}
\newlistentry{quadro}{loq}{0}
\renewcommand{\cftquadroname}{\Quadroname\space}
\ifnumtradicional
  \cftsetindents{quadro}{0em}{2.4em}
\else
  \cftsetindents{quadro}{0em}{1.6em}
\fi
\renewcommand{\thequadro}{\thechapter.\arabic{quadro}}
\def\QT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@quadro{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
    {\let\\\space
    \addcontentsline{\ext@quadro}{quadro}{\protect\numberline{\thequadro}{#2}}}%
  \fi
}
\newenvironment{longquadro}
  {\let\LT@c@ption\QT@c@ption\let\c@table\c@quadro\crefalias{table}{quadro}
  \renewcommand{\theHtable}{quadro\thechapter.\arabic{quadro}}\longtable}
  {\endlongtable}
% ---

% ---
% Pacotes para algoritmos
% ---
\ifbrazilian% \RequirePackage dá erro de compilação
  \usepackage[algochapter,linesnumbered,boxed,portuguese,onelanguage]{algorithm2e}
  \SetAlgorithmName{Algoritmo}{algoritmo}{Lista de algoritmos}
\else
  \usepackage[algochapter,linesnumbered,boxed,english,onelanguage]{algorithm2e}
  \SetAlgorithmName{Algorithm}{algorithm}{List of algorithms}
\fi
\renewcommand{\AlCapFnt}{\normalfont\small}
\renewcommand{\@algocf@capt@boxed}{above}
\DontPrintSemicolon
\setlength{\algomargin}{1.8em}
\newlength{\algcaptionwidth}
\newlength{\algcaptiontwidth}
\renewcommand{\algocf@makecaption}[2]{%
  \settowidth{\algcaptionwidth}{#1 -- }%
  \settowidth{\algcaptiontwidth}{\small #1 -- #2}%
  \ifdim\algcaptiontwidth<\columnwidth
    \hspace*{\dimexpr(\columnwidth-\algcaptiontwidth)/2\relax}%
  \fi
  \makebox[\algcaptionwidth][l]{#1 -- }%
  \parbox[t]{\dimexpr\columnwidth-\algcaptionwidth\relax}%
    {\small #2\par\vspace{6pt}}%
}
\SetAlgoInsideSkip{smallskip}
\renewcommand*\listofalgorithms{\listoftoc[\listalgorithmcfname]{loa}}
\newcommand*{\noaddvspace}{\renewcommand*{\addvspace}[1]{}}
\addtocontents{loa}{\protect\noaddvspace}
% ---

% ---
% Pacote para códigos de programação
% ---
\RequirePackage{listings}
% Julia (Linguagem não reconhecida automaticamente pelo pacote listings)
\lstdefinelanguage{Julia}%
  {morekeywords={abstract,break,case,catch,const,continue,do,else,elseif,%
  end,export,false,for,function,immutable,import,importall,if,in,%
  macro,module,otherwise,quote,return,switch,true,try,type,typealias,%
  using,while},%
  sensitive=true,%
  alsoother={\$},%
  morecomment=[l]\#,%
  morecomment=[n]{\#=}{=\#},%
  morestring=[s]{"}{"},%
  morestring=[m]{'}{'},%
}[keywords,comments,strings]%
% Configurações gerais
\definecolor{mygreen}{RGB}{28,172,0} % Color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\lstset{%
  basicstyle=\linespread{1.08}\ttfamily\footnotesize,
  numbers=left,%
  numberstyle={\tiny \color{black}}, % Size of the numbers
  numbersep=9pt, % This defines how far the numbers are from the text
  backgroundcolor=\color{gray!10},
  tabsize=2,
  frame=single,
  rulecolor=\color{black!30},
  captionpos=t,
  belowcaptionskip=10pt,
  escapeinside={\%*}{*)},
  breaklines=true,%
  breakatwhitespace=true,
  framextopmargin=2pt,
  framexbottommargin=2pt,
  keywordstyle=\color{blue},%
  morekeywords=[2]{1}, keywordstyle=[2]{\color{black}},
  identifierstyle=\color{black},%
  stringstyle=\color{mylilas},
  commentstyle=\color{mygreen},%
  extendedchars=true,
  inputencoding=utf8,
  showstringspaces=false,% Without this there will be a symbol in the places where there is a space
  literate={á}{{\'a}}1 {ã}{{\~a}}1 {é}{{\'e}}1 {ç}{{\c{c}}}1 {â}{{\^a}}1 {õ}{{\~o}}1 {ú}{{\'u}}1 {ó}{{\'o}}1 {í}{{\'i}}1 {Í}{{\'I}}1 
}
% Configura lista de códigos
\newlength{\lstnumwidth}
\AtBeginDocument{%
  \renewcommand\lstlistoflistings{%
  \begingroup
  \settowidth{\lstnumwidth}{\lstlistingname}
    \ifnumtradicional
      \addtolength{\lstnumwidth}{2.7em}
    \else
      \addtolength{\lstnumwidth}{1.9em}
    \fi
    \let\contentsname\lstlistlistingname
    \let\oldnumberline\numberline
    \def\numberline##1{%
      \makebox[\lstnumwidth][l]{\lstlistingname~##1}}
    \def\l@lstlisting##1##2{\@dottedtocline{1}{0em}{\lstnumwidth}{##1}{##2}}
    \let\lst@temp\@starttoc
    \def\@starttoc##1{\lst@temp{lol}}%
    \tableofcontents
    \let\numberline\oldnumberline
  \endgroup
  }
}
% ---

% ---
% Configurações para remissões internas
% ---
\RequirePackage{hyperref}
\pdfstringdefDisableCommands{\def\\{, }\def\and{; }}
\hypersetup{pdfstartview=FitH,breaklinks=true,colorlinks=true,
   allcolors=azulunb,linktocpage,bookmarksdepth=4,draft=false}
\ifbrazilian
  \RequirePackage[nameinlink,noabbrev,brazilian]{cleveref}
\else
  \RequirePackage[nameinlink,noabbrev,english]{cleveref}
\fi
\crefname{annex}{\anexoname}{\anexosname}
\Crefname{annex}{\Anexoname}{\Anexosname}
\crefname{listing}{\codigoname}{\codigosname}
\Crefname{listing}{\Codigoname}{\Codigosname}
\ifchapnamesec \crefname{chapter}{\chaptercrefname}{\chapterscrefname}
\Crefname{chapter}{\Chaptercrefname}{\Chapterscrefname} \fi
\crefname{paragraph}{\paragraphname}{\paragraphsname}
\Crefname{paragraph}{\Paragraphname}{\Paragraphsname}
\crefname{quadro}{\quadroname}{\quadrosname}
\Crefname{quadro}{\Quadroname}{\Quadrosname}
\crefname{assumption}{\aptname}{\aptsname}
\Crefname{assumption}{\Aptname}{\Aptsname}
% ---

% ---
% Definição de ambientes teorema, exemplo, demonstração, etc.
% ---
\RequirePackage{mdframed}

\theoremstyle{definition}
\mdfdefinestyle{plainSty}{hidealllines=true,backgroundcolor=verdeunb!10,innertopmargin=0pt}
\newmdtheoremenv[style=plainSty]{theorem}{\thname}[chapter] % Teorema
\newmdtheoremenv[style=plainSty]{lemma}{\lmname}[chapter] % Lema
\newmdtheoremenv[style=plainSty]{proposition}{\prname}[chapter] % Proposição
\newmdtheoremenv[style=plainSty]{corollary}{\crname}[chapter] % Corolário

\theoremstyle{definition}
\mdfdefinestyle{defnSty}{hidealllines=true,backgroundcolor=azulunb!10,innertopmargin=0pt}
\newmdtheoremenv[style=defnSty]{definition}{\dfname}[chapter] % Definição
\newmdtheoremenv[style=defnSty]{assumption}{\Aptname}[chapter] % Hipótese
\newmdtheoremenv[style=defnSty]{example}{\expname}[chapter] % Exemplo

\theoremstyle{remark}
\let\proof\relax\let\endproof\relax
\newmdtheoremenv[linecolor=azulunb,linewidth=1pt,hidealllines=false,innertopmargin=4pt]{remark}{\rmname}[chapter] % Observação

\newtheoremstyle{myproof}{\topsep}{\topsep}{}{}{\bfseries}{}{ }{\thmname{#1} \thmnote{#3}}
\theoremstyle{myproof}
\let\proof\relax\let\endproof\relax
\newmdtheoremenv[linecolor=verdeunb,linewidth=1pt,hidealllines=false,innertopmargin=0pt]{proof}{\proofname.} % Prova
\AtEndEnvironment{proof}{\hfill$\square$}
% ---

% ---
% Listas de abreviaturas/siglas/símbolos
% ---
\ifbrazilian
  \RequirePackage[portuguese]{nomencl}
\else
  \RequirePackage[english]{nomencl}
\fi
%\RequirePackage[refpage]{nomencl} % Para imprimir página onde o símbolo foi registrado
%\def\pagedeclaration#1{\dotfill\hyperlink{page.#1}{\nobreakspace#1}\par}
\renewcommand{\nomname}{\listadesiglasname} % Nome da lista de siglas
\setlength{\nomitemsep}{-\parsep} % Espaço entre os itens das listas
% Imprime os títulos das listas e dos grupos
\newcommand{\nomenclheader}[1]{\section*{\hspace*{-\leftmargin}\large#1}}
\renewcommand\nomgroup[1]{%
  \IfStrEqCase{#1}{%
    {A}{\vspace{-38pt}\nomenclheader{}} % Lista de abreviaturas e siglas
    {B}{\PRIVATEclearpageifneeded % Quebra de página
        \pretextualchapter{\hspace{-\leftmargin}\listadesimbolosname} % Lista de símbolos
        \vspace{-10pt}\nomenclheader{\nomBname}} % Símbolos romanos
    {C}{\nomenclheader{\nomCname}} % Símbolos gregos
    %{Letra}{\nomenclheader{Nome do grupo}} % Acrescente, se necessário, outros grupos
    {X}{\nomenclheader{\nomXname}} % Sobrescritos
    {Z}{\nomenclheader{\nomZname}} % Subscritos
    % Grupos podem ser alterados ou adicionados
  }%
}
% Ajusta a largura do rótulo nas listas de abreviaturas/siglas/símbolos
\xapptocmd\thenomenclature{\let\@item\nomencl@item\def\nomencl@width{0pt}}{}{}
\let\nomencl@item\@item
\xpretocmd\nomencl@item{\nomencl@measure{#1}}{}{}
\def\nomencl@measure#1{%
  \sbox0{#1}%
  \ifdim\wd0>\nomencl@width\relax
    \edef\nomencl@width{\the\wd0}%
  \fi
}
\xapptocmd\endthenomenclature{%
  \immediate\write\@mainaux{\global\nomlabelwidth\nomencl@width\relax}%
}{}{}
% ---

% ---
% Referências bibliográficas
% ---
% Espaçamento entre linhas da lista de referências
\edef\mybaselinestretch{\baselinestretch}
\AtBeginEnvironment{thebibliography}{\linespread{\mybaselinestretch}\selectfont}%
% Lista na bibliografia o número das páginas em que cada referência é citada
\ifrefback
  \ifbrazilian
    \RequirePackage[hyperpageref,brazilian]{backref}
  \else
    \RequirePackage[hyperpageref,english]{backref}
  \fi
  \renewcommand*{\backref}[1]{}
  \renewcommand*{\backrefalt}[4]{\ifcase#1\nocitation\or\citedp~#2.\else\citedpp~#2.\fi}
\fi
% Gera as referências bibliográficas de acordo com as normas da ABNT
\newcommand{\bibhang}[1]{\setlength{\bibindent}{#1}}
\ifbibalf% Estilo autor-data
  \RequirePackage[alf,abnt-etal-list=0,abnt-etal-cite=3,
     abnt-emphasize=bf,abnt-missing-year=sd,bibjustif]{unbtexcite}
  \ifbrazilian% Seleciona o arquivo de estilo de citação
    \bibliographystyle{unbtex-alf-pt}
  \else%
    \bibliographystyle{unbtex-alf-en}
  \fi%
\else% Estilo numérico
  \RequirePackage[num,abnt-etal-list=0,abnt-emphasize=bf,
     abnt-missing-year=sd,bibjustif]{unbtexcite}
  \RequirePackage{cite} % Para comprimir e colocar entre colchetes os números nas citações
  \renewcommand{\citeonline}[2][]{%
  \if\relax\detokenize{#1}\relax
    \cite{#2}%
  \else
    \cite[#1]{#2}%
  \fi
  }
  \ifbrazilian% Seleciona o arquivo de estilo de citação
    \bibliographystyle{unbtex-num-pt}
  \else%
    \bibliographystyle{unbtex-num-en}
  \fi%
\fi%
% ---

% ---
% Ajusta a indentação das listas de figuras, de tabelas e de algoritmos
% ---
\DeclareTOCStyleEntry[
  indent=0pt,
  entrynumberformat=\entrynumberwithprefix{\figurename},
  dynnumwidth,
]{tocline}{figure}
\DeclareTOCStyleEntry[
  indent=0pt,
  entrynumberformat=\entrynumberwithprefix{\tablename},
  dynnumwidth,
]{tocline}{table}
\DeclareTOCStyleEntry[
  level:=figure,
  numwidth:=figure,
  indent=0pt,
  entrynumberformat=\entrynumberwithprefix{\algorithmname},
  dynnumwidth,
]{tocline}{algocf}
\newcommand\entrynumberwithprefix[2]{#1~#2\thinspace\hfill}
% ---

% ---
% Define o texto dos rótulos de acordo com o idioma principal selecionado
% ---
\ifbrazilian
  \RequirePackage[english,brazilian]{babel}
\else
  \RequirePackage[brazilian,english]{babel}
\fi
% Nomes constantes do unbtex em português (definições padrões)
\newcommand{\folhaderostoname}{Folha de rosto}
\newcommand{\epigraphname}{Epígrafe}
\newcommand{\dedicatorianame}{Dedicatória}
\newcommand{\errataname}{Errata}
\newcommand{\agradecimentosname}{Agradecimentos}
\newcommand{\apendicename}{apêndice}\newcommand{\apendicesname}{apêndices}
\newcommand{\Apendicename}{Apêndice}\newcommand{\Apendicesname}{Apêndices}
\newcommand{\anexoname}{anexo}\newcommand{\anexosname}{anexos}
\newcommand{\Anexoname}{Anexo}\newcommand{\Anexosname}{Anexos}
\newcommand{\folhadeaprovacaoname}{Folha de aprovação}
\newcommand{\resumoname}{Resumo} 
\newcommand{\listadesiglasname}{Lista de abreviaturas e siglas}
\newcommand{\listadesimbolosname}{Lista de símbolos}
\newcommand{\fontename}{Fonte}
\newcommand{\notaname}{Nota}
\ifchapnamesec \newcommand{\chaptercrefname}{seção}\newcommand{\chapterscrefname}{seções}
\newcommand{\Chaptercrefname}{Seção}\newcommand{\Chapterscrefname}{Seções} \fi
\newcommand{\subsectionname}{seção}
\newcommand{\paragraphname}{seção}\newcommand{\paragraphsname}{seções}
\newcommand{\Paragraphname}{Seção}\newcommand{\Paragraphsname}{Seções}
\newcommand{\codigoname}{código}\newcommand{\codigosname}{códigos}
\newcommand{\Codigoname}{Código}\newcommand{\Codigosname}{Códigos}
\newcommand{\algorithmname}{Algoritmo}
\newcommand{\listquadroname}{Lista de quadros}
\newcommand{\quadroname}{quadro}\newcommand{\quadrosname}{quadros}
\newcommand{\Quadroname}{Quadro}\newcommand{\Quadrosname}{Quadros}
\newcommand{\thname}{Teorema}
\newcommand{\lmname}{Lema}
\newcommand{\prname}{Proposição}
\newcommand{\crname}{Corolário}
\newcommand{\aptname}{hipótese}\newcommand{\aptsname}{hipóteses}
\newcommand{\Aptname}{Hipótese}\newcommand{\Aptsname}{Hipóteses}
\newcommand{\dfname}{Definição}
\newcommand{\expname}{Exemplo}
\newcommand{\rmname}{Observação}
\newcommand{\nocitation}{Nenhuma citação no texto.}
\newcommand{\citedp}{Citado na p.}
\newcommand{\citedpp}{Citado nas pp.}
\newcommand{\nomBname}{Símbolos romanos}
\newcommand{\nomCname}{Símbolos gregos}
% adiciona/altera textos padrão dependentes do idioma
\addto\captionsbrazilian{% português-brasil
  \ifchapnamesec \renewcommand{\chaptername}{Seção} \fi
  \renewcommand{\bibname}{Referências}
  \renewcommand{\indexname}{Índice}
  \renewcommand{\listtablename}{Lista de tabelas}
  \renewcommand{\listfigurename}{Lista de figuras}
  \renewcommand{\lstlistingname}{Código}
  \renewcommand{\lstlistlistingname}{Lista de códigos}
  \renewcommand{\proofname}{Demonstração}
}
\addto\captionsenglish{% inglês
  \renewcommand{\folhaderostoname}{Title page}
  \renewcommand{\epigraphname}{Epigraph}
  \renewcommand{\dedicatorianame}{Dedication}
  \renewcommand{\errataname}{Errata sheet}
  \renewcommand{\agradecimentosname}{Acknowledgements}
  \renewcommand{\folhadeaprovacaoname}{Approval}
  \renewcommand{\resumoname}{Abstract} 
  \renewcommand{\listadesiglasname}{List of abbreviations and acronyms}
  \renewcommand{\listadesimbolosname}{List of symbols}
  \renewcommand{\fontename}{Source}
  \renewcommand{\notaname}{Note}
  \ifchapnamesec \renewcommand{\chaptername}{Section}
  \renewcommand{\chaptercrefname}{section}\renewcommand{\chapterscrefname}{sections}
  \renewcommand{\Chaptercrefname}{Section}\renewcommand{\Chapterscrefname}{Sections} \fi
  \renewcommand{\bibname}{References}
  \renewcommand{\listfigurename}{List of figures}
  \renewcommand{\listtablename}{List of tables}
  \renewcommand{\apendicename}{appendix}\renewcommand{\apendicesname}{appendices}
  \renewcommand{\Apendicename}{Appendix}\renewcommand{\Apendicesname}{Appendices}
  \renewcommand{\anexoname}{annex}\renewcommand{\anexosname}{annexes}
  \renewcommand{\Anexoname}{Annex}\renewcommand{\Anexosname}{Annexes}
  \renewcommand{\subsectionname}{section}
  \renewcommand{\paragraphname}{section}\renewcommand{\paragraphsname}{sections}
  \renewcommand{\Paragraphname}{Section}\renewcommand{\Paragraphsname}{Sections}
  \renewcommand{\lstlistingname}{Code}
  \renewcommand{\lstlistlistingname}{List of codes}
  \renewcommand{\codigoname}{code}\renewcommand{\codigosname}{codes}
  \renewcommand{\Codigoname}{Code}\renewcommand{\Codigosname}{Codes}
  \renewcommand{\algorithmname}{Algorithm}
  \renewcommand{\listquadroname}{List of charts}
  \renewcommand{\quadroname}{chart}\renewcommand{\quadrosname}{charts}
  \renewcommand{\Quadroname}{Chart}\renewcommand{\Quadrosname}{Charts}
  \renewcommand{\thname}{Theorem}
  \renewcommand{\lmname}{Lemma}
  \renewcommand{\prname}{Proposition}
  \renewcommand{\crname}{Corollary}
  \renewcommand{\aptname}{assumption}\renewcommand{\aptsname}{assumptions}
  \renewcommand{\Aptname}{Assumption}\renewcommand{\Aptsname}{Assumptions}
  \renewcommand{\dfname}{Definition}
  \renewcommand{\expname}{Example}
  \renewcommand{\rmname}{Remark}
  \renewcommand{\proofname}{Proof}
  \renewcommand{\nocitation}{No citations.}
  \renewcommand{\citedp}{Cit. on p.}
  \renewcommand{\citedpp}{Cit. on pp.}
  \renewcommand{\nomBname}{Roman letters}
  \renewcommand{\nomCname}{Greek letters}
}
\AtBeginDocument{
  \ifbrazilian \selectlanguage{brazilian} \else \selectlanguage{english} \fi
  \pretextual
}
% ---

% ------------------------------------------------------------------------
% Informações do trabalho
% ------------------------------------------------------------------------
% Titulo do documento
\newcommand{\titulo}[1]{\title{#1}}
\newcommand{\imprimirtitulo}{\thetitle}
\newcommand{\tituloestrangeiro}[1]{\providecommand{\theforeigntitle}{#1}}
\newcommand{\imprimirtituloestrangeiro}{\theforeigntitle}
% Autores
\newcommand{\autor}[1]{\author{#1}}
\newcommand{\imprimirautor}{\theauthor}
\newcommand{\autori}[3][]{\def\autorinome{#2}\def\autorisobrenome{#3}}
\newcommand{\autorii}[3][]{\def\autoriinome{#2}\def\autoriisobrenome{#3}}
% Código Cutter
\newcommand{\numerocutter}[1]{\def\imprimircutter{#1}}
% Orientadores
\newcommand{\orientador}[4][]{\def\orientname{#1}\def\orienttitulo{#2}\def\orientnome{#3}\def\orientsobrenome{#4}}
\newcommand{\coorientador}[4][]{\def\coorientname{#1}\def\coorienttitulo{#2}\def\coorientnome{#3}\def\coorientsobrenome{#4}}
% Tipo de trabalho/curso
\newcommand{\tipotrabalho}[1]{\newcommand{\imprimirtipotrabalho}{#1}}
\newcommand{\tipocurso}[1]{\def\imprimircurso{#1}}
% Informação adicional do trabalho
\newcommand{\publicacao}[1]{\def\imprimirpublicacao{#1}}
% Instituição
\newcommand{\instituicao}[3][]{\def\instituicaoi{#1}\def\instituicaoii{#2}\def\instituicaoiii{#3}}
% Local
\newcommand{\local}[1]{\newcommand{\imprimirlocal}{#1}}
% Preâmbulo
\newcommand{\preambulo}[1]{\newcommand{\imprimirpreambulo}{#1}}
% Data
\let\olddate\date
\renewcommand{\date}[1]{\AtBeginDocument{\olddate{#1}}}
\newcommand{\data}[1]{\date{#1}}
\newcommand{\imprimirdata}{\thedate}
\newcommand{\dia}[1]{\def\imprimirdia{#1}}
\newcommand{\mes}[1]{\def\imprimirmes{#1}}
\newcommand{\ano}[1]{\def\imprimirano{#1}}
% Membros da banca
\newcommand{\membrodabancai}[1]{\def\membrodabancainome{#1}}
\newcommand{\membrodabancaii}[1]{\def\membrodabancaiinome{#1}}
\newcommand{\membrodabancaiii}[1]{\def\membrodabancaiiinome{#1}}
\newcommand{\membrodabancaiv}[1]{\def\membrodabancaivnome{#1}}
\newcommand{\membrodabancav}[1]{\def\membrodabancavnome{#1}}
\newcommand{\membrodabancaifuncao}[1]{\def\membrodabancaifuncaonome{#1}}
\newcommand{\membrodabancaiifuncao}[1]{\def\membrodabancaiifuncaonome{#1}}
\newcommand{\membrodabancaiiifuncao}[1]{\def\membrodabancaiiifuncaonome{#1}}
\newcommand{\membrodabancaivfuncao}[1]{\def\membrodabancaivfuncaonome{#1}}
\newcommand{\membrodabancavfuncao}[1]{\def\membrodabancavfuncaonome{#1}}
% Palavras-chave
\newcommand{\pchavei}[1]{\def\pchaveinome{#1}}
\newcommand{\kwordi}[1]{\def\kwordinome{#1}}
\newcommand{\pchaveii}[1]{\def\pchaveiinome{#1}}
\newcommand{\kwordii}[1]{\def\kwordiinome{#1}}
\newcommand{\pchaveiii}[1]{\def\pchaveiiinome{#1}}
\newcommand{\kwordiii}[1]{\def\kwordiiinome{#1}}
\newcommand{\pchaveiv}[1]{\def\pchaveivnome{#1}}
\newcommand{\kwordiv}[1]{\def\kwordivnome{#1}}
\newcommand{\pchavev}[1]{\def\pchavevnome{#1}}
\newcommand{\kwordv}[1]{\def\kwordvnome{#1}}
% ---

% ---
% Imprime capa e contracapa
% ---
\RequirePackage{pdfpages}
\newenvironment{capa}{\begin{titlingpage}}{\end{titlingpage}\cleardoublepage}
% Imprime capa
\newcommand{\imprimircapa}{%
\IfFileExists{unbtexcover-front.pdf}{%
\hypersetup{pageanchor=false}
\begin{capa}%
  \begin{adjustwidth}{0cm}{\dimexpr\spinemargin-\foremargin\relax}
    \begin{center}
      \AddToShipoutPictureBG*{%
        \includegraphics[height=\paperheight]{unbtexcover-front.pdf}}
      \vspace*{\dimexpr 7.5cm + 3cm - \uppermargin\relax}
      {\LARGE\sffamily\bfseries
      \instituicaoi\par 
      \ifdefempty{\instituicaoii}{}{\instituicaoii\par}
      \ifdefempty{\instituicaoiii}{}{\instituicaoiii\par}}
      \vfill
      {\autotitle[4]{\bfseries\imprimirtitulo}
      \titleformat\bfseries\imprimirtitulo\par}
      \normalfont
      \vfill
      {\Large\autorinome\ \autorisobrenome \\
      \ifdefempty{\autoriinome}{}{\autoriinome\ \autoriisobrenome}\par}
      \vfill\vfill
      {\color{white}\sffamily\large
      \MakeUppercase\imprimirtipotrabalho \\[2pt]
      \MakeUppercase\imprimircurso \\
      \autotitle[1]{\MakeUppercase\imprimircurso}
      \ifdefined\decvspace
        \vspace{2pt}
      \else
        \vspace{20pt}
      \fi
      \imprimirlocal \\ \imprimirano\par}
    \end{center}
  \end{adjustwidth}
\end{capa}
\hypersetup{pageanchor=true}
\AtEndDocument{\imprimircontracapa}
}{}%
}
% Imprime contracapa
\newcommand{\imprimircontracapa}{%
\IfFileExists{unbtexcover-back.pdf}{%
  \cleardoublepage
  \pagestyle{empty}
  \if@twoside
    \addtocounter{page}{-2}
    \ifoddpage\else\ \fi
  \else
    \addtocounter{page}{-1}
  \fi
  \hypersetup{pageanchor=false}
  \newpage
  \includepdf[height=\paperheight]{unbtexcover-back.pdf}
  \hypersetup{pageanchor=true}
}{}%
}
% ---

% ---
% Imprime folha de rosto 
% ---
\newenvironment{folhaderosto}[1][\folhaderostoname]
  {\clearpage\PRIVATEbookmarkthis{#1}}{\cleardoublepage}
\newenvironment{folhaderosto*}[1][\folhaderostoname]
  {\clearpage\PRIVATEbookmarkthis{#1}}{\newpage}%
\newcommand{\folhaderostocontent}{%
\begin{center}
  {\LARGE\sffamily\bfseries\instituicaoi\par
  \ifdefempty{\instituicaoii}{}{\instituicaoii\par}
  \ifdefempty{\instituicaoiii}{}{\instituicaoiii\par}}
  \vfill\vfill
  \begin{center}
    % Define o tamanho da fonte do título
    \ifdefempty{\theforeigntitle}
    {\autotitle[4]{\bfseries\imprimirtitulo}
    {\color{verdeunb}\titleformat\bfseries\imprimirtitulo\par}}
    {\autotitle[4]{\bfseries\imprimirtituloestrangeiro}
    {\color{verdeunb}\titleformat\bfseries\imprimirtituloestrangeiro\par}}
  \end{center}
  \vfill
  {\Large\autorinome\ \autorisobrenome \\
  \ifdefempty{\autoriinome}{}{\autoriinome\ \autoriisobrenome}\par}
  \vfill
  \ifdefempty{\imprimirpreambulo}{}{%
    \begin{flushright}
      \begin{minipage}{0.5\textwidth}
        {\SingleSpacing
        \begin{otherlanguage*}{brazilian}
          \imprimirpreambulo
        \end{otherlanguage*}}
      \end{minipage}%
    \end{flushright}
    \vfill}%
  {\ifdefempty{\orientnome}{}{\large \orientname: \orienttitulo\ \orientnome\ \orientsobrenome \\
  \ifdefempty{\coorientnome}{}{\coorientname: \coorienttitulo\ \coorientnome\ \coorientsobrenome}\par}}
  \vfill
  {\sffamily\large\ifdefempty{\imprimirpublicacao}{}{\imprimirpublicacao \\ \vfill} \imprimirlocal \\ \imprimirano\par}
\end{center}
}
\newcommand{\imprimirfolhaderostostar}[1]{%
  \begin{folhaderosto*}{#1}
    \folhaderostocontent
  \end{folhaderosto*}
}
\newcommand{\imprimirfolhaderostonostar}[1]{%
  \begin{folhaderosto}{#1}
    \folhaderostocontent
  \end{folhaderosto}
}
\newcommand{\imprimirfolhaderosto}[1][\folhaderostoname]{%
  \@ifstar
    \imprimirfolhaderostostar
    \imprimirfolhaderostonostar
}
% ---

% ---
% Imprime ficha catalográfica
% ---
% https://bce.unb.br/elaboracao-de-fichas-catalograficas/
\newcommand{\cutter}{\IfInteger{\imprimircutter}{&}{}}
\newenvironment{fichacatalografica}
  {\thispagestyle{empty}\ABNTEXfontereduzida\begin{SingleSpacing}}
  {\end{SingleSpacing}\newpage}%
\newcommand{\imprimirfichacatalografica}{
\begin{fichacatalografica}
\ifdefempty{\imprimirpublicacao}{}{%
\begin{OnehalfSpace}
{\noindent\sffamily\large REFERÊNCIA BIBLIOGRÁFICA}\par
\noindent\MakeUppercase\autorisobrenome, \autorinome%
\ifdefempty{\autoriinome}{.}{;~\MakeUppercase\autoriisobrenome, \autoriinome.} %
{\bfseries\StrDel{\imprimirtitulo}{\\}}. %
\begin{otherlanguage*}{brazilian}%
\imprimirtipotrabalho\ (\imprimircurso)%
\ifdefempty{\imprimirpublicacao}{}{,~\imprimirpublicacao} -- %
\ifdefempty{\instituicaoiii}{}{\instituicaoiii,~}%
\ifdefempty{\instituicaoii}{}{\instituicaoii,~}%
\instituicaoi, \imprimirlocal, \imprimirano. \thelastpage~\if@twoside p. \else f. \fi%
\end{otherlanguage*}
\end{OnehalfSpace}}
\IfInteger{\imprimircutter}{\setlength{\fboxsep}{10pt}}{\setlength{\fboxsep}{18pt}}
\vspace*{\fill}
\begin{center}
{\sffamily\large FICHA CATALOGRÁFICA} \\[18pt]
\fbox{%\ttfamily%
\begin{minipage}[t][7.5cm]{12.5cm}\raggedright
\IfInteger{\imprimircutter}
{\begin{tabular}{p{1cm} >{\raggedright\arraybackslash}p{10.5cm}}}{}
\cutter \autorisobrenome, \autorinome.~\\
\IfInteger{\imprimircutter}{\StrChar{\autorisobrenome}{1}%
\imprimircutter\StrChar{\imprimirtitulo}{1}[\SUBtemp]\MakeLowercase{\SUBtemp}}{}
\cutter \hspace*{0.5cm}\noindent \StrDel{\imprimirtitulo}{\\}~/%
\begin{otherlanguage*}{brazilian}
\autorinome\ \autorisobrenome; %
\ifdefempty{\autoriinome}{}{\autoriinome\ \autoriisobrenome; }%
\orientname:\ \orientnome\ \orientsobrenome%
\ifdefempty{\coorientnome}{.}{;~\coorientname:\ \coorientnome\ \coorientsobrenome.}
-- \imprimirlocal, \imprimirano.%
\end{otherlanguage*}
~\\ \cutter \hspace*{0.5cm}\noindent \thelastpage~\if@twoside p. \else f. \fi
~\\ \cutter~\\ \cutter \hspace*{0.5cm}\noindent%
\begin{otherlanguage*}{brazilian}%
\imprimirtipotrabalho\ (\imprimircurso)\ -- \instituicaoi, \imprimirano.%
\end{otherlanguage*}
~\\ \cutter~\\ \cutter \hspace*{0.5cm}\noindent%
\ifbrazilian{%
1. \expandafter\MakeUppercase\pchaveinome. %
2. \expandafter\MakeUppercase\pchaveiinome. %
3. \expandafter\MakeUppercase\pchaveiiinome. %
\ifdefempty{\pchaveivnome}{}{%
4. \expandafter\MakeUppercase\pchaveivnome. %
\ifdefempty{\pchavevnome}{}{%
5. \expandafter\MakeUppercase\pchavevnome.~}}%
}%
\else{%
1. \expandafter\MakeUppercase\kwordinome. %
2. \expandafter\MakeUppercase\kwordiinome. %
3. \expandafter\MakeUppercase\kwordiiinome. %
\ifdefempty{\kwordivnome}{}{%
4. \expandafter\MakeUppercase\kwordivnome. %
\ifdefempty{\kwordvnome}{}{%
5. \expandafter\MakeUppercase\kwordvnome.~}}%
}%
\fi
\begin{otherlanguage*}{brazilian}%
\ifdefempty{\autoriinome}{%
  \ifdefempty{\coorientnome}{%
    I. \orientsobrenome, \orientnome, orient. II. Título.%
  }{%
    I. \orientsobrenome, \orientnome, orient. %
    II. \coorientsobrenome, \coorientnome, coorient. %
    III. Título.%
  }%
}{%
  \ifdefempty{\coorientnome}{%
    I. \autoriisobrenome, \autoriinome. %
    II. \orientsobrenome, \orientnome, orient. %
    III. Título.%
  }{%
    I. \autoriisobrenome, \autoriinome. %
    II. \orientsobrenome, \orientnome, orient. %
    III. \coorientsobrenome, \coorientnome, coorient. %
    IV. Título.%
  }%
}%
\end{otherlanguage*}
\IfInteger{\imprimircutter}
{\end{tabular}}{}
\end{minipage}}
\end{center}
\end{fichacatalografica}
}
% ---

% ---
% Errata
% ---
\newenvironment{errata}[1][\errataname]{\pretextualchapter{#1}}{\PRIVATEclearpageifneeded}
% ---

% ---
% Imprime folha de aprovação
% ---
\newenvironment{folhadeaprovacao}[1][\folhadeaprovacaoname]
  {\clearpage\PRIVATEbookmarkthis{#1}\begin{SingleSpace}}
  {\end{SingleSpace}\PRIVATEclearpageifneeded}
% Define comando \assinatura
\newlength{\ABNTEXsignwidth}
\setlength{\ABNTEXsignwidth}{8cm}
\newlength{\ABNTEXsignthickness}
\setlength{\ABNTEXsignthickness}{1pt}
\newlength{\ABNTEXsignskip}
\setlength{\ABNTEXsignskip}{0.7cm}
\newcommand{\assinatura}{\@ifstar{\ABNTEXsign}{\ABNTEXcsign}}
\newcommand{\ABNTEXsign}[1]{%
  \parbox[t]{\ABNTEXsignwidth}{\SingleSpacing\vspace*{\ABNTEXsignskip}\centering%
  \rule{\ABNTEXsignwidth}{\ABNTEXsignthickness}\\\nopagebreak #1\par}%
}
\newcommand{\ABNTEXcsign}[1]{\begingroup\par\centering\ABNTEXsign{#1}\par\endgroup}  
\newcommand{\signlinewidth}[1]{\setlength{\ABNTEXsignwidth}{#1}}
\newcommand{\imprimirfolhadeaprovacao}{%
\begin{folhadeaprovacao}
\begin{center}
  {\Large\sffamily\bfseries\instituicaoi\par
  \ifdefempty{\instituicaoii}{}{\instituicaoii\par}
  \ifdefempty{\instituicaoiii}{}{\instituicaoiii\par}}
  \vfill
  \begin{center}
    % Define o tamanho da fonte do título
    \autotitle[1]{\bfseries\StrDel{\imprimirtitulo}{\\}}
    \ifdefstring{\titleformat}{\large}
    {\color{verdeunb}\Large\bfseries\StrDel{\imprimirtitulo}{\\}\par}
    {\color{verdeunb}\titleformat\bfseries\StrDel{\imprimirtitulo}{\\}\par}%
  \end{center}
  \vfill
  {\large\autorinome\ \autorisobrenome \\[2pt]
  \ifdefempty{\autoriinome}{}{\autoriinome\ \autoriisobrenome}\par}
  \vfill
  \ifdefempty{\imprimirpreambulo}{}{%
    \begin{flushright}
    \begin{minipage}{0.5\textwidth}
    {\SingleSpacing
    \begin{otherlanguage*}{brazilian}
    \imprimirpreambulo
    \end{otherlanguage*}}
    \end{minipage}%
    \end{flushright}
  }%
  \vspace{24pt}
  \raggedright{Trabalho aprovado. \imprimirlocal, \imprimirdia\ de \imprimirmes\ de \imprimirano:}{%
    \assinatura{\textbf{\membrodabancainome} \\ \membrodabancaifuncaonome} 
    \assinatura{\textbf{\membrodabancaiinome} \\ \membrodabancaiifuncaonome} 
    \assinatura{\textbf{\membrodabancaiiinome} \\ \membrodabancaiiifuncaonome} 
    \ifdefempty{\membrodabancaivnome}{}{\assinatura{\textbf{\membrodabancaivnome} \\ \membrodabancaivfuncaonome}}
    \ifdefempty{\membrodabancavnome}{}{\assinatura{\textbf{\membrodabancavnome} \\ \membrodabancavfuncaonome}}
  }
\end{center}
\end{folhadeaprovacao}
}
% ---

\RequirePackage{scontents}
% ---
% Imprime dedicatória
% ---
\newenvsc{DedicatoriaAutorI}[store-env=dedicatoriaautori]
\newenvsc{DedicatoriaAutorII}[store-env=dedicatoriaautorii]
\newcommand{\imprimirdedicatoria}{%
\begin{dedicatoria}
  \centering
  \vspace*{\fill}
  % Primeiro autor
  {\itshape\getstored{dedicatoriaautori}}\par
  \ifdefempty{\autoriinome}{}{%
  \vspace{\baselineskip}
  \autorinome\ \autorisobrenome\par
  \vspace*{\fill}
  % Segundo autor (dedicatória)
  {\itshape\getstored{dedicatoriaautorii}}\par
  \vspace{\baselineskip}
  \autoriinome\ \autoriisobrenome
  }%
  \vspace*{\fill}
  \end{dedicatoria}
\cleardoublepage
}
\newenvironment{dedicatoria}[1][]{%
  \if\relax\detokenize{#1}\relax
    \PRIVATEbookmarkthis{\dedicatorianame}%
  \else
    \pretextualchapter{#1}%
  \fi
}{%
  \PRIVATEclearpageifneeded%
}%
% ---

% ---
% Imprime agradecimentos
% ---
\newenvsc{AgradecimentosAutorI}[store-env=agradecimentosautori]
\newenvsc{AgradecimentosAutorII}[store-env=agradecimentosautorii]
% Define o idioma do título da seção de agradecimentos
\newcommand{\idiomaagradecimentos}[1]{\def\acklang{#1}}
\newcommand{\imprimiragradecimentos}{%
\ifdefstring{\acklang}{brazilian}
  {\renewcommand{\agradecimentosname}{Agradecimentos}}
  {\renewcommand{\agradecimentosname}{Acknowledgements}}
\begin{agradecimentos}
  \begin{otherlanguage*}{\acklang}
  % Primeiro autor
  \getstored{agradecimentosautori}\par
  \vspace{\baselineskip}
  \ifdefempty{\autoriinome}{}{%
  \hfill \autorinome\ \autorisobrenome\par
  \vspace{2\baselineskip}
  % Segundo autor
  \getstored{agradecimentosautorii}\par
  \vspace{\baselineskip}
  \hfill \autoriinome\ \autoriisobrenome
  }%
  \end{otherlanguage*}
\end{agradecimentos}
\cleardoublepage
}
\newenvironment{agradecimentos}[1][\agradecimentosname]
  {\pretextualchapter{#1}}{\PRIVATEclearpageifneeded}
% ---

% ---
% Imprime epígrafe
% ---
\newenvironment{epigrafe}[1][]{%
  \if\relax\detokenize{#1}\relax
    \PRIVATEbookmarkthis{\epigraphname}%
  \else
    \pretextualchapter{#1}%
  \fi
}{%
  \PRIVATEclearpageifneeded%
}%
\newenvsc{Epigrafe}[store-env=epigrafe]
\newcommand{\imprimirepigrafe}{%
  \begin{epigrafe}
    \getstored{epigrafe}\par
  \end{epigrafe}
\PRIVATEclearpageifneeded
}
% ---

% ---
% Imprime resumo e abstract
% ---
\setlength\absleftindent{0cm}
\setlength\absrightindent{0cm}
\renewcommand{\abstracttextfont}{\normalfont\normalsize}
\setlength{\absparsep}{\parsep}
\ifABNTEXisarticle \setlength{\abstitleskip}{-0.5\baselineskip}
\else \setlength{\abstitleskip}{\baselineskip} \fi
% Resumo
\newenvsc{Resumo}[store-env=resumo]
\newcommand{\imprimirresumo}{%
  \begin{resumo}[Resumo]
  \begin{otherlanguage*}{brazilian}
    \getstored{resumo}\par
    \vspace{\baselineskip}
    {\sffamily\bfseries Palavras-chave:} \pchaveinome; \pchaveiinome; \pchaveiiinome%
    \ifdefempty{\pchaveivnome}{.}
    {;~\pchaveivnome\ifdefempty{\pchavevnome}{.}{;~\pchavevnome.}}%
  \end{otherlanguage*}
  \end{resumo}
  \PRIVATEclearpageifneeded
}
% Abstract
\newenvsc{Abstract}[store-env=abstract]
\newcommand{\imprimirabstract}{%
  \begin{resumo}[Abstract]
  \begin{otherlanguage*}{english}
    \getstored{abstract}\par
    \vspace{\baselineskip}
    {\sffamily\bfseries Keywords:} \kwordinome; \kwordiinome; \kwordiiinome%
    \ifdefempty{\kwordivnome}{.}
    {;~\kwordivnome\ifdefempty{\kwordvnome}{.}{;~\kwordvnome.}}%
  \end{otherlanguage*}
\end{resumo}
\PRIVATEclearpageifneeded
}
% Insere resumo e abstract
\newcommand{\imprimirresumos}{%
\ifbrazilian
  \imprimirresumo
  \imprimirabstract
\else
  \imprimirabstract
  \imprimirresumo
\fi
}
\AtBeginDocument{\setlength{\absparindent}{0pt}}
\newenvironment{resumo}[1][\resumoname]{%
  \PRIVATEbookmarkthis{#1}
  \renewcommand{\abstractnamefont}{\chaptitlefont}
  \renewcommand{\abstractname}{\ABNTEXchapterupperifneeded{#1}}
  \begin{abstract}
 }{\end{abstract}\PRIVATEclearpageifneeded}
\newenvironment{resumoumacoluna}[1][\resumoname]{%
  \PRIVATEbookmarkthis{#1}
  \renewcommand{\abstractnamefont}{\chaptitlefont}
  \renewcommand{\abstractname}{\ABNTEXchapterupperifneeded{#1}}
  \begin{onecolabstract}
 }{\end{onecolabstract}\PRIVATEclearpageifneeded}
% ---

% ---
% Imprime lista de figuras
% ---
\newcommand{\imprimirlistadefiguras}{%
  \pdfbookmark[0]{\listfigurename}{lof}
  \listoffigures*
  \PRIVATEclearpageifneeded
}
% ---

% ---
% Imprime lista de quadros
% ---
\newcommand{\imprimirlistadequadros}{%
  \pdfbookmark[0]{\listquadroname}{loq}
  \listofquadros*
  \PRIVATEclearpageifneeded
}
% ---

% ---
% Imprime lista de tabelas
% ---
\newcommand{\imprimirlistadetabelas}{%
  \pdfbookmark[0]{\listtablename}{lot}
  \listoftables*
  \PRIVATEclearpageifneeded
}
% ---

% ---
% Imprime lista de algoritmos
% ---
\newcommand{\imprimirlistadealgoritmos}{%
  \pdfbookmark[0]{\listalgorithmcfname}{loa}
  \listofalgorithms
  \PRIVATEclearpageifneeded
}
% ---

% ---
% Imprime lista de códigos
% ---
\newcommand{\imprimirlistadecodigos}{%
  \pdfbookmark[0]{\lstlistlistingname}{lol}
  \begin{KeepFromToc} % Não inclui a lista de códigos no sumário
    \lstlistoflistings
  \end{KeepFromToc}
\PRIVATEclearpageifneeded
}
% ---

% ---
% Imprime lista de abreviaturas e siglas e lista de símbolos
% ---
\newcommand{\imprimirlistadesiglasesimbolos}{%
  \PRIVATEbookmarkthis{\listadesiglasname}
  \printnomenclature
  \PRIVATEclearpageifneeded
}
% Lista de abreviaturas e siglas
\newenvironment{siglas}
  {\pretextualchapter{\listadesiglasname}\begin{symbols}}
  {\end{symbols}\cleardoublepage}
% Lista de simbolos
\newenvironment{simbolos}
  {\pretextualchapter{\listadesimbolosname}\begin{symbols}}
  {\end{symbols}\cleardoublepage}
% ---

% ---
% Imprime sumário
% ---
\newcommand{\imprimirsumario}{%
  \pdfbookmark[0]{\contentsname}{toc}
  \tableofcontents*
  \PRIVATEclearpageifneeded
}
% ---

% ---
% Define o tamanho da fonte tipográfica do título
% ---
\newbox\testbox
\newdimen\testblskip
\newcommand*{\testlines}[1]{%
  \setbox\testbox\hbox to\textwidth{\vbox{\centering\testfontsize #1\global\testblskip\baselineskip\par}}%
}
% \autotitle{número de linhas}{texto do título}
\newcommand*{\autotitle}[2][]{%
  \let\testfontsize\huge\sffamily\testlines{#2}% \huge
  \ifdim\ht\testbox>#1\testblskip
    \let\testfontsize\LARGE\sffamily\testlines{#2}% \LARGE
    \ifdim\ht\testbox>#1\testblskip
      \let\testfontsize\Large\sffamily\testlines{#2}% \Large
      \ifdim\ht\testbox>#1\testblskip
        \let\testfontsize\large\sffamily\testlines{#2}% \large
        \ifdim\ht\testbox>#1\testblskip
          \newcommand{\decvspace}{}
        \fi
      \fi
    \fi
  \fi
  \newcommand{\titleformat}{\testfontsize}
}
% ---