% Compilation options
\synctex=1
\newif\iflong\longfalse

% Packages
\usepackage[utf8]{inputenx}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{microtype}
\usepackage{listings}
\usepackage{appendix}
\usepackage{appendixnumberbeamer}
\usepackage{mathrsfs, mathenv}
\usepackage{mathtools}
\usepackage{amsmath, amsthm, amssymb, amsfonts, amscd}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{etoolbox}
\usepackage{hyperref}
\usepackage{pgfpages}
\usepackage{subcaption}
\usepackage{appendixnumberbeamer}
\usepackage{xparse}
\usepackage[makeroom]{cancel}
\renewcommand{\CancelColor}{\color{red}}
\usepackage[%
    url=true, backend=biber,
    maxnames=5, maxbibnames=5, style=trad-abbrv,
    url=false,isbn=false,doi=false]{biblatex}

\usepackage{tikz}
\usepackage{pgfplotstable}
\usepackage[weather]{ifsym}
\usetikzlibrary{patterns}
\usetikzlibrary{calc}
\usetikzlibrary{angles}
\usetikzlibrary{quotes}
\pgfplotsset{compat=1.17}

\definecolor{darkred}{rgb}{.5,0,0}
\definecolor{darkgreen}{rgb}{0,.5,0}
\definecolor{darkblue}{rgb}{0,0,.5}
% \newcommand{\red}[1]{\textcolor{darkred}{#1}}
% \newcommand{\green}[1]{\textcolor{darkgreen}{#1}}

\newtheorem{proposition}{Proposition}

% Fix setspace
\makeatletter
\let\BEAMER@footnotetext\@footnotetext
\makeatother
\usepackage{setspace}
\makeatletter
\let\@footnotetext\BEAMER@footnotetext
\expandafter\patchcmd\csname beamerx@\string\beamer@framefootnotetext\endcsname
  {\reset@font} {\def\baselinestretch{\setspace@singlespace}\reset@font} {}{}
\makeatother
\setlength{\parskip}{6pt}
% \setlength{\parindent}{6pt}

% Include videos
% \usepackage{pdfpc-commands}

% Layout
\usefonttheme[onlymath]{serif}
% \useinnertheme{rounded}
\usecolortheme{seahorse}
\usecolortheme{orchid}
\setbeamerfont{footnote}{size=\scriptsize}

% Commands for presentations
\newcommand*\MyPitem{\item[\color{green}\scalebox{0.9}{\textbullet}]}
\newcommand*\MyCitem{\item[\color{red}\scalebox{0.9}{\textbullet}]}

\mode<presentation>
\useoutertheme{infolines}
\setbeamercovered{transparent}
\setbeamertemplate{headline}{}
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}

\setbeamercolor{itemize subitem}{fg=darkgreen}
\setbeamertemplate{itemize items}[square]
\setbeamercolor{itemize subitem}{fg=red}
\setbeamercolor{itemize subsubitem}{fg=gray}
\setbeamertemplate{itemize/enumerate subbody begin}{\normalsize}
\setbeamertemplate{itemize/enumerate subsubbody begin}{\normalsize}
\setbeamercolor{footercolor}{fg=gray,bg=white}
\setbeamertemplate{footline}{
    \hbox{%
    \begin{beamercolorbox}[wd=\paperwidth,ht=3ex,dp=1.5ex,leftskip=2ex,rightskip=2ex]{footercolor}%
        \usebeamerfont{title in head/foot}%
        \hypersetup{hidelinks}%
        \textit \insertsection %
        \ifx\insertsubsection\empty\else%
         \ifdefempty{\subsecname}{\relax}{%
          \hspace{.1cm} -- \hspace{.00cm} \insertsubsection %
         }%
        \fi
        \hfill %
        \insertframenumber{} / \inserttotalframenumber
    \end{beamercolorbox}}%
}

\usecolortheme{whale}
\usecolortheme{rose}
\captionsetup{font=scriptsize,labelfont=scriptsize}
\setbeamerfont{footnote}{size=\scriptsize}

\makeatletter
\renewcommand<>\beamer@framefootnotetext[1]{%
  \global\setbox\beamer@footins\vbox{%
    \hsize\framewidth
    \textwidth\hsize
    \columnwidth\hsize
    \unvbox\beamer@footins
    \reset@font\footnotesize
    \@parboxrestore
    \protected@edef\@currentlabel
         {\csname p@footnote\endcsname\@thefnmark}%
    \color@begingroup
      \uncover#2{\@makefntext{%
        \rule\z@\footnotesep\ignorespaces\parbox[t]{.9\textwidth}{#1\@finalstrut\strutbox}\vskip1sp}}%
    \color@endgroup}%
}
\makeatother

\makeatletter
\renewcommand\@makefnmark{\hbox{\@textsuperscript{\normalfont[\@thefnmark]}}}
\renewcommand\@makefntext[1]{{\normalfont[\@thefnmark]}\enspace #1}
\makeatother

\DeclareCiteCommand{\footfullcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

% Bibliography options
\setbeamercolor{bibliography entry title}{fg=black}
\setbeamercolor{bibliography entry author}{fg=darkgreen}
\AtEveryCitekey{\clearfield{pages}}
\AtEveryCitekey{\clearfield{eprint}}
\AtEveryCitekey{\clearfield{volume}}
\AtEveryCitekey{\clearfield{number}}
\AtEveryCitekey{\clearfield{month}}
% \DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}
\renewcommand*{\mkbibnamegiven}[1]{%
  \ifitemannotation{highlight}
  {} {#1}}
\renewcommand*{\mkbibnamefamily}[1]{%
  \ifitemannotation{highlight}
  {U\textsc{V}}
  {\textsc{#1}}}
