%%
%% This is file `ucsmonograph.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ucsmonograph.dtx  (with options: `class')
%% 
%% Copyright 2018 Henrique Baron
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Henrique Baron.
%% 
%% This work consists of the files ucsmonograph.dtx and ucsmonograph.ins
%% and the derived file ucsmonograph.cls.
%% 
%% Classe ucsmonograph
%% Formata um documento da classe abnTeX2 para o padrao exigido pela Universidade de Caxias do Sul para monografias.
%% 
%% DUVIDAS E SUGESTOES: Abra uma issue na pagina do projeto
%% https://github.com/HenriqueBaron/ucsmonograph
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ucsmonograph}
[2018/08/16 v1.1.0 Padrao de monografias da UCS]


\RequirePackage{ifthen}

\newboolean{@lmodernAtivo}
\setboolean{@lmodernAtivo}{false}

\newboolean{@siglasAtivo}
\setboolean{@siglasAtivo}{false}

\newboolean{@simbolosAtivo}
\setboolean{@simbolosAtivo}{false}

\RequirePackage{kvoptions}
\DeclareStringOption[alf]{cite}
\ProcessKeyvalOptions*
\DeclareOption{lmodern}{%
\setboolean{@lmodernAtivo}{true}%
}

\DeclareOption{siglas}{%
\setboolean{@siglasAtivo}{true}%
}

\DeclareOption{simbolos}{%
\setboolean{@simbolosAtivo}{true}%
}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{abntex2}}
\ProcessOptions\relax
\LoadClass[openright,a4paper,chapter=TITLE,section=TITLE]{abntex2}%

\RequirePackage{ifluatex}
\ifluatex
\RequirePackage[math-style=upright]{unicode-math}
\setboolean{@lmodernAtivo}{true}
\fi

\RequirePackage[\ucsmonograph@cite,abnt-etal-list=3,abnt-etal-text=it,%
abnt-full-initials=no]{abntex2cite}

\ifthenelse{\equal{\ucsmonograph@cite}{num}}{%
\citebrackets[]%
\RequirePackage{cite}%
}{}

\let\su@ExpandTwoArgs\relax
\let\IfSubStringInString\relax
\let\su@IfSubStringInString\relax

\hypersetup{%
unicode=true,
pdfcreator={LaTeX with ucsmonograph},
colorlinks=true,
linkcolor=black,
citecolor=black,
}

\ifthenelse{\boolean{@lmodernAtivo}}{%
\RequirePackage{lmodern}
}{}

\RequirePackage{caption}

\RequirePackage[top=3cm,left=3cm,bottom=2cm,right=2cm]{geometry}
\flushbottom

\RequirePackage{etoolbox}
\RequirePackage{indentfirst}
\RequirePackage[absolute]{textpos}
\RequirePackage{calc}

\RequirePackage{amsmath}
\allowdisplaybreaks

\RequirePackage{xparse}
\RequirePackage{graphicx}
\RequirePackage{float}

\RequirePackage{adjustbox}
\newlength\larguraimagem

\RequirePackage{chngcntr}
\counterwithout{equation}{chapter}

\RequirePackage{suffix}

\ifthenelse{\boolean{@siglasAtivo}}{%
\PassOptionsToPackage{acronyms}{glossaries-extra}%
}

\ifthenelse{\boolean{@simbolosAtivo}}{%
\PassOptionsToPackage{symbols}{glossaries-extra}%
}

\ifthenelse{\boolean{@siglasAtivo} \OR \boolean{@simbolosAtivo}}{%
\PassOptionsToPackage{record,toc=false,nonumberlist,style=long}{glossaries-extra}%
}{}

\RequirePackage{glossaries-extra}
\setlength\glsdescwidth\linewidth%

\ifthenelse{\boolean{@siglasAtivo}}{%
\setabbreviationstyle[acronym]{long-short}%
\setabbreviationstyle[foreignabbreviation]{long-short-user}%
}{}

\newcommand{\quadroname}{Quadro}
\newcommand{\listquadroname}{Lista de quadros}

\newfloat{quadro}{\quadroname}{loq}[chapter]
\restylefloat*{quadro}
\setfloatadjustment{quadro}{\centering}
\setfloatlocations{quadro}{hbtp}

\newlistof{listofquadros}{loq}{\listquadroname}
\newlistentry{quadro}{loq}{0}
\renewcommand{\cftquadroname}{\quadroname\space}
\renewcommand*{\cftquadroaftersnum}{\hfill\textendash\hfill}

\renewcommand{\fnum@quadro}{\quadroname\ \thequadro}

\counterwithout{quadro}{chapter}

\let\@oldlistofquadros\listofquadros
\def\listofquadros{%
\pdfbookmark[0]{\listquadroname}{loq}
\@oldlistofquadros
}

\makepagestyle{abntheadings}
\makeevenhead{abntheadings}{\ABNTEXfontereduzida\thepage}{}{}
\makeoddhead{abntheadings}{}{}{\ABNTEXfontereduzida\thepage}

\addto\captionsbrazil{%
\renewcommand{\listfigurename}{Lista de figuras}%
\renewcommand{\listadesimbolosname}{Lista de símbolos}%
}

\renewcommand{\ABNTEXchapterfont}{\bfseries}
\renewcommand{\ABNTEXchapterfontsize}{\normalsize}

\renewcommand{\ABNTEXsectionfont}{\ABNTEXchapterfont\mdseries}
\renewcommand{\ABNTEXsectionfontsize}{\normalsize}

\renewcommand{\ABNTEXsubsectionfont}{\ABNTEXsectionfont\bfseries}
\renewcommand{\ABNTEXsubsectionfontsize}{\normalsize}

\renewcommand{\ABNTEXsubsubsectionfont}{\ABNTEXsubsectionfont\mdseries}
\renewcommand{\ABNTEXsubsubsectionfontsize}{\normalsize}

\renewcommand{\ABNTEXsubsubsubsectionfont}{\ABNTEXsubsubsectionfont\itshape}
\renewcommand{\ABNTEXsubsubsubsectionfontsize}{\normalsize}

\AtBeginDocument{\setlength{\afterchapskip}{20pt}}
\renewcommand{\cftchapterfont}{\ABNTEXchapterfont}
\renewcommand{\cftsectionfont}{\ABNTEXsectionfont}
\renewcommand{\cftsubsectionfont}{\ABNTEXsubsectionfont}
\renewcommand{\cftsubsubsectionfont}{\ABNTEXsubsubsectionfont}
\renewcommand{\cftparagraphfont}{\ABNTEXsubsubsubsectionfont}

\renewcommand{\imprimircapa}{%
\pdfbookmark[0]{Capa}{Capa}%
\begin{capa}%
\centering%
\expandafter\uppercase\expandafter{\imprimirinstituicao}%
\vfill
\begin{textblock*}{160mm}(30mm, 297mm/4+15mm)%
\expandafter\uppercase\expandafter{\theauthor}%
\end{textblock*}%
\begin{textblock*}{160mm}(30mm, 297mm/2)%
\expandafter\uppercase\expandafter{\thetitle}%
\end{textblock*}%
\vfill
\expandafter\uppercase\expandafter{\imprimirlocal}\\
\expandafter\uppercase\expandafter{\thedate}%
\end{capa}%
}

\renewcommand{\folhaderostocontent}{%
\centering%
\expandafter\uppercase\expandafter{\theauthor}%
\vfill
\vfill
\begin{textblock*}{160mm}(30mm, 297mm/2)%
\expandafter\uppercase\expandafter{\thetitle}%
\end{textblock*}%
\vspace{10mm}
\abntex@ifnotempty{\imprimirpreambulo}{%
\hspace{.45\textwidth}%
\begin{minipage}{.5\textwidth}%
\mdseries%
\SingleSpacing%
\imprimirpreambulo%
\begin{flushright}%
\imprimirorientadorRotulo~\imprimirorientador%
\end{flushright}%
\end{minipage}%
}%
\vfill
\expandafter\uppercase\expandafter{\imprimirlocal}\\
\expandafter\uppercase\expandafter{\thedate}%
}

\let\@olddedicatoria\dedicatoria
\let\@oldenddedicatoria\enddedicatoria
\def\dedicatoria{%
\@olddedicatoria%
\vspace*{\fill}%
\hspace{.5\textwidth}%
\begin{minipage}[b]{.45\textwidth}%
\SingleSpacing%
}
\def\enddedicatoria{%
\end{minipage}%
\@oldenddedicatoria%
}

\let\@oldtitulo\titulo
\renewcommand{\titulo}[1]{%
\@oldtitulo{#1}
\hypersetup{%
pdftitle={#1}
}
}
\let\@oldautor\autor
\renewcommand{\autor}[1]{%
\@oldautor{#1}
\hypersetup{%
pdfauthor={#1}
}
}
\let\@oldpreambulo\preambulo
\renewcommand{\preambulo}[1]{%
\@oldpreambulo{#1}
\hypersetup{%
pdfsubject={#1}
}
}

\let\@oldlistoffigures\listoffigures
\def\listoffigures{%
\pdfbookmark[0]{\listfigurename}{lof}
\@oldlistoffigures
}

\let\@oldlistoftables\listoftables
\def\listoftables{%
\pdfbookmark[0]{\listtablename}{lot}
\@oldlistoftables
}

\let\@oldtableofcontents\tableofcontents
\def\tableofcontents{%
\pdfbookmark[0]{\contentsname}{toc}
\@oldtableofcontents
}

\ifthenelse{\boolean{@siglasAtivo}}{%
\renewcommand{\glsxtruserparen}[2]{%
\glsxtrfullsep{#2}%
\glsxtrparen
{#1\ifglshasfield{\glsxtruserfield}{#2}{, \emph{\glscurrentfieldvalue}}{}}%
}%
\renewcommand{\glsuserdescription}[2]{%
\ifglshasfield{\glsxtruserfield}{#2}{\emph{\glscurrentfieldvalue}}{#1}%
}
}{}

\let\@oldcontentsline\contentsline
\def\contentsline#1#2{%
\expandafter\ifx\csname l@#1\endcsname\l@section
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{%
\@oldcontentsline{#1}{\MakeTextUppercase{#2}}%
}{%
\@oldcontentsline{#1}{#2}%
}%
}

\let\@oldforeignlanguage\foreignlanguage
\renewcommand{\foreignlanguage}[2]{\@oldforeignlanguage{#1}{\emph{#2}}}

\newcommand{\@palavraschave}{}
\newcommand{\palavraschave}[1]{%
\renewcommand{\@palavraschave}{#1}
\hypersetup{%
pdfkeywords={#1}
}
}
\newcommand{\imprimirfolhadeaprovacao}[5][Universidade de Caxias do Sul - UCS]{%
\begin{folhadeaprovacao}%
\begin{center}%
\bfseries %
\ABNTEXchapterfont %
\expandafter\uppercase\expandafter{\theauthor} %
\vspace{1.5cm} \par
\expandafter\uppercase\expandafter{\thetitle} %
\vspace{0.5cm}
\end{center}

\abntex@ifnotempty{\imprimirpreambulo}{%
\hspace{.45\textwidth} %
\begin{minipage}{.5\textwidth}%
\mdseries%
\SingleSpacing%
\imprimirpreambulo%
\begin{flushright}%
\imprimirorientadorRotulo~\imprimirorientador%
\end{flushright}%
\end{minipage}%
}
\vspace{24pt} \par %
\hspace{.45\textwidth}%
\begin{minipage}{.5\textwidth}%
\bfseries%
Aprovado(a) em #2 %
\end{minipage}%
\vspace{3cm} \par % 
\noindent\textbf{Banca Examinadora} %
\begin{SingleSpace} %
\vspace*{\ABNTEXsignskip}%
\noindent%
\rule{\ABNTEXsignwidth}{\ABNTEXsignthickness}\\
Prof. \imprimirorientador\\
Universidade de Caxias do Sul - UCS \par
\vspace*{\ABNTEXsignskip}%
\noindent%
\rule{\ABNTEXsignwidth}{\ABNTEXsignthickness}\\
Prof. #3\\
Universidade de Caxias do Sul - UCS \par
\vspace*{\ABNTEXsignskip}
\noindent
\rule{\ABNTEXsignwidth}{\ABNTEXsignthickness}\\
Prof. #4\\
Universidade de Caxias do Sul - UCS \par
\vspace*{\ABNTEXsignskip}
\noindent %
\rule{\ABNTEXsignwidth}{\ABNTEXsignthickness}\\
#5\\
#1 %
\end{SingleSpace} %
\end{folhadeaprovacao} %
}

\newcommand{\incluirimagem}[4][1]{%
\caption{#3}%
\adjustimage{scale=#1,fbox=1.5pt {\fboxsep} 1pt,gstore width=\larguraimagem,center}{#2} \par %
\centering%
\begin{minipage}[h]{\larguraimagem-14pt}%
\raggedright\footnotesize Fonte: #4 %
\end{minipage}
}

\ifthenelse{\boolean{@siglasAtivo}}{%
\newcommand{\incluirsiglas}[1]{%
\GlsXtrLoadResources[%
src  = {#1},
sort = {pt-BR},
type = {acronym},
entry-type-aliases={% make @foreignabbreviation act like @abbreviation
foreignabbreviation=abbreviation},
field-aliases={%
foreignlong=user1,
nativelong=long},
category={same as original entry}% requires bib2gls v1.4+
]
}%
\WithSuffix\newcommand\listofsiglas*{%
\pdfbookmark[0]{\listadesiglasname}{loa}
\printunsrtglossary[type=acronym,title=\listadesiglasname]%
\addtocounter{table}{-1}%
}%
}{}

\ifthenelse{\boolean{@simbolosAtivo}}{%
\newcommand{\incluirsimbolos}[1]{%
\GlsXtrLoadResources[%
src = {#1},
sort = {use},
type = {symbols}
]%
}%
\WithSuffix\newcommand\listofsimbolos*{%
\pdfbookmark[0]{\listadesimbolosname}{los}
\printunsrtglossary[type=symbols,title=\listadesimbolosname]%
\addtocounter{table}{-1}%
}%
}{}
\endinput
%%
%% End of file `ucsmonograph.cls'.
