% PAGE
\usepackage[margin=2cm]{geometry} % Margins

% FONT
\usepackage[T1, T2A]{fontenc} % Font rendering
\usepackage[utf8]{inputenc}  % Input encoding
\usepackage[english, serbianc]{babel}
\usepackage{microtype}

% PARAGRAPH
\widowpenalty10000 % Prevent widows
\clubpenalty10000 % Prevent orphans
\setlength{\parindent}{0pt} % Paragraph indentation
\setlength{\parskip}{12pt}  % Space between paragraphs

% CHAPTER
\usepackage{titlesec} % Modify titles style
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter%
  \hspace{20pt}}{0pt}{} % Modify chapter style

% NUMBERING
\setcounter{secnumdepth}{5} % Depth of section numbering
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{equation}{chapter}

% HEADER AND FOOTER
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancypagestyle{mainmatter}{
  \fancyhf{}
  \lhead{\nouppercase{\removelinebreaks\@naslov}}
  \rhead{}
  \ifbsc \lfoot{\nouppercase{\removelinebreaks\@student} - Дипломски рад} \fi
  \ifmsc \lfoot{\nouppercase{\removelinebreaks\@student} - Мастер рад} \fi
  \cfoot{}
  \rfoot{\thepage}
}
\fancypagestyle{frontmatter}{
  \fancyhf{}
  \lhead{}
  \rhead{}
  \cfoot{}
  \rfoot{}
}
\fancypagestyle{plain}{
  \lhead{\nouppercase{\removelinebreaks\@naslov}}
  \rhead{}
  \ifbsc \lfoot{\nouppercase{\removelinebreaks\@student} - Дипломски рад} \fi
  \ifmsc \lfoot{\nouppercase{\removelinebreaks\@student} - Мастер рад} \fi
  \cfoot{}
  \rfoot{\thepage}
}
\addtocontents{toc}{\protect\thispagestyle{frontmatter}}
\makeatother

% BIBLIOGRAPHY
\addto{\captionsserbianc}{\renewcommand{\bibname}{Литература}}
\usepackage{cite}

% QUOTES
\usepackage[style=german]{csquotes}

% MATH
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{siunitx}

% REFERENCES & CAPTIONS
\usepackage{hyperref} % use [hidelinks] to hide links
\usepackage{subcaption}
\captionsetup{justification=centering}

% ITEMIZE
\usepackage{enumitem}
\setlist[itemize]{noitemsep, topsep=0pt}

% TABLES
\usepackage{booktabs}

% TITLE PAGE
\makeatletter
\newcommand{\naslov}[1]{\gdef\@naslov{#1}}
\newcommand{\naslove}[1]{\gdef\@naslove{#1}}
\newcommand{\teza}[1]{\gdef\@teza{#1}}
\newcommand{\mentor}[1]{\gdef\@mentor{#1}}
\newcommand{\student}[1]{\gdef\@student{#1}}
\newcommand{\odobreno}[1]{\gdef\@odobreno{#1}}
\newcommand{\godina}[1]{\gdef\@godina{#1}}
\newif\ifbsc
\newif\ifmsc
\newcommand{\removelinebreaks}[1]{%
  \begingroup\def\n{ }#1\endgroup}

\newcommand{\n}{\vadjust{\vspace{12pt}}\nolinebreak\hspace{\fill}\linebreak}

\renewcommand{\maketitle}{
\begin{titlepage}
    \begin{center}
      {\fontsize{16}{\baselineskip}\selectfont УНИВЕРЗИТЕТ У БЕОГРАДУ\\[6pt] ГРАЂЕВИНСКИ ФАКУЛТЕТ}

      \includegraphics[width=46mm]{img/grf.png}
      \vspace{2cm}

      {\fontsize{20}{\baselineskip}\selectfont\bfseries\MakeUppercase{\@naslov}}

      \vspace{1cm}

      { \fontsize{16}{\baselineskip}\selectfont
        \ifbsc - ДИПЛОМСКИ РАД - \fi
        \ifmsc - МАСТЕР РАД - \fi
      }
      \vfill

      { \fontsize{16}{\baselineskip}\selectfont

        \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} l}
          \textbf{Ментор:} & \textbf{Кандидат:} \\[12pt]
          \@mentor & \@student \\
        \end{tabular*}
      }

      \vspace{1cm}
      
      { \fontsize{16}{\baselineskip}\selectfont Београд, \@godina }
    \end{center}
  \end{titlepage}
}
\makeatother