% References on bottom of slide

\newcommand{\addreference}[2]{%
    {
        \scriptsize\textcolor{kit-green100}{
            \begin{tabular}{lp{0.88\columnwidth}}
                [#1] & #2
            \end{tabular}
        }
    }%
}

\makeatletter

\newcommand{\addreferences}{%
    \begin{scriptsize}
    \begin{tabular}{lp{0.88\textwidth}}
    \@addreferencesi
}

\newcommand\@addreferencesi{\@ifnextchar\stopreferences{\@addreferencesend}{\@addreferencesii}}

\newcommand\@addreferencesii[2]{%
    \textcolor{kit-green100}{[#1]} & \textcolor{kit-green100}{#2} \\
    \@addreferencesi % restart the recursion
}

\newcommand\@addreferencesend[1]{% The argument is \stopimages
    \end{tabular}
    \end{scriptsize}
}

\makeatother

% References on the bottom of the current column

\newcommand{\addreferencecol}[2]{%
    {
        \scriptsize\textcolor{kit-green100}{
            \begin{tabular}{lp{0.78\columnwidth}}
                [#1] & #2
            \end{tabular}
        }
    }%
}

\makeatletter

\newcommand{\addreferencescol}{%
    \begin{scriptsize}
    \begin{tabular}{lp{0.78\columnwidth}}
    \@addreferencescoli
}

\newcommand\@addreferencescoli{\@ifnextchar\stopreferences{\@addreferencescolend}{\@addreferencescolii}}

\newcommand\@addreferencescolii[2]{%
    \textcolor{kit-green100}{[#1]} & \textcolor{kit-green100}{#2} \\
    \@addreferencescoli % restart the recursion
}

\newcommand\@addreferencescolend[1]{% The argument is \stopimages
    \end{tabular}
    \end{scriptsize}
}

\makeatother

\newcommand{\citereference}[1]{\textcolor{kit-green100}{\textbf{\scriptsize{[#1]}}}}
\newcommand{\citereferencewhite}[1]{\textcolor{white}{\textbf{\scriptsize{[#1]}}}}


% defines algorithm counter for chapter-level
\newcounter{genericAlgorithmCounter}
\let\OldSection\section
\renewcommand{\section}{\setcounter{genericAlgorithmCounter}{1}\OldSection}
%defines appearance of the algorithm counter
\renewcommand{\thegenericAlgorithmCounter}{\thechapter .\arabic{genericAlgorithmCounter}}
% defines a new caption label as Algorithm x.y
\DeclareCaptionLabelFormat{algocaption}{Algorithm \thegenericAlgorithmCounter} 

%
% Algorithm stuff
%

\lstnewenvironment{algorithm}[1][] 
{
    \captionsetup{labelformat=algocaption,labelsep=colon}
    \lstset{
        mathescape=true,
        escapeinside=||,
        frame=TB,
        numbers=left,
        numberstyle=\tiny,
        basicstyle=\normalfont,
        columns=fullflexible,
        keywordstyle=\color{black}\bfseries,
        keywords={,for, while, end, do, nd, or, return, if,}
        numbers=left,
        xleftmargin=.04\textwidth,
        captionpos=b,
        belowskip=1.5em,
        aboveskip=1.5em,
        #1 % This is to add custom settings
    }
}
{\addtocounter{genericAlgorithmCounter}{1}}

\let\origthelstnumber\thelstnumber
\makeatletter
\newcommand*\Suppressnumber{%
  \lst@AddToHook{OnNewLine}{%
    \let\thelstnumber\relax%
     \advance\c@lstnumber-\@ne\relax%
    }%
}
\newcommand*\Reactivatenumber{%
  \lst@AddToHook{OnNewLine}{%
   \let\thelstnumber\origthelstnumber%
   \advance\c@lstnumber\@ne\relax}%
}
\makeatother

