
\ProvidesPackage{BeamerthemeUNCGmath} 

\usepackage{times}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,latexsym,amssymb}
\usepackage{stmaryrd}
\usepackage{verbatim}
\usepackage{framed,color}
\usepackage{tikz,pgfplots}
\usetikzlibrary{shadings}
\usepackage[makeroom]{cancel}
\usepackage{float}
\usepackage[config, labelfont={bf}]{caption,subfig}

\pgfplotsset{compat=newest}

%\usepackage{pst-all}           %PStricks

%uncomment for handouts
%\usepackage{pgfpages}
%\pgfpagesuselayout{2 on 1}[letterpaper, border shrink=5mm]



%%%%%%%%%%

%% Define Custom Colors

\definecolor{UNCGblue}{RGB}{000,051,102}
\definecolor{UNCGyellow}{RGB}{255,204,000}

\definecolor{olive}{rgb}{0.3, 0.4, .1}
\definecolor{fore}{RGB}{249,242,215}
\definecolor{back}{RGB}{51,51,51}
\definecolor{title}{RGB}{255,0,90}
\definecolor{dgreen}{rgb}{0.,0.6,0.}
\definecolor{gold}{rgb}{1.,0.84,0.}
\definecolor{JungleGreen}{cmyk}{0.99,0,0.52,0}
\definecolor{BlueGreen}{cmyk}{0.85,0,0.33,0}
\definecolor{RawSienna}{cmyk}{0,0.72,1,0.45}
\definecolor{Magenta}{cmyk}{0,1,0,0}
\definecolor{MidnightBlue}{cmyk}{0.75,0.5,0,0.2}
\definecolor{GCgreen}{HTML}{1F5647}
\definecolor{UTorange}{RGB}{247,127,0}
\definecolor{shadecolor}{gray}{0.95}


%% Set Color Scheme for Slides 
%    bg = background, fg = foreground
%    sets slide titles to bold and small size 
%    Turns off navigation symbols 

\setbeamercolor{title}{bg=white,fg=UNCGblue}
\setbeamercolor{footlinecolor}{fg=UNCGyellow,bg=UNCGblue}
\setbeamercolor{structure}{fg=UNCGyellow}
\setbeamertemplate{navigation symbols}{}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamerfont{frametitle}{size=\small}
\setbeamerfont{normal text}{size=\small}
\usefonttheme{structuresmallcapsserif}
\setbeamercolor{subsection in toc}{fg=UNCGblue}
\setbeamercolor*{frametitle}{fg=UNCGblue}
\setbeamercolor{date}{fg=UNCGyellow}   % Change if yellow does not show up


%% Define logo on main title slide

\institute{\color{UNCGblue}
\includegraphics[height=1.65cm]{UNCG_logo_abbrev_math.png}}

%% Define the Title slide

\newcommand{\makeTitleSlide}{ 

\setbeamertemplate{background canvas}[vertical shading]
  [bottom=white,top=UNCGyellow,middle=white,midpoint=.925]

\begin{frame}
  
\vspace{5mm}

\titlepage

\hspace*{-10.85mm}
\includegraphics[width=\paperwidth]{UNCG_banner.jpg}
\vspace{-7mm}

\end{frame}

\setbeamertemplate{background canvas}[vertical shading]
  [bottom=white,top=white,middle=white,midpoint=.25]
\setbeamercolor{background canvas}{bg=white}

  
}

%% Define default slide backgrounds

\newcommand{\makeBackgroundShaded}{
\setbeamertemplate{background canvas}[vertical shading]
  [bottom=shadecolor,top=UNCGyellow,middle=shadecolor,midpoint=.925]
}

\newcommand{\makeBackgroundWhite}{
\setbeamertemplate{background canvas}[vertical shading]
  [bottom=white,top=white,middle=white,midpoint=.925]
}


%% Define Transition Slides for new sections
%    Needs to be altered in order for the entire outline to appear instead of 
%    the title of the new section. 

\AtBeginSection[]
{
\setbeamertemplate{footline}{}
\setbeamertemplate{background canvas}[vertical shading]
  [bottom=shadecolor,top=UNCGyellow,middle=shadecolor,midpoint=.925]
\setbeamercolor{background canvas}{bg=UNCGblue}
\begin{frame}
	\vv
	
	\Large
	\hh \usebeamerfont{section title}\textcolor{UNCGblue}{\insertsectionhead}\hh 
	
	\vv 
	\vv
	
\hspace*{-11mm}
\includegraphics[width=\paperwidth]{UNCG_banner.jpg}
\vspace{-1.22in}
\end{frame}

\setbeamertemplate{background canvas}[vertical shading]
  [bottom=white,top=white,middle=white,midpoint=.25]
\setbeamercolor{background canvas}{bg=white}
\setbeamertemplate{footline}[my footline]
}








%%  Define Gradient effect for background color of slide titles

\colorlet{titleleft}{UNCGyellow}
\colorlet{titleright}{white}

\makeatletter
\pgfdeclarehorizontalshading[titleleft,titleright]{beamer@frametitleshade}{\paperheight}{%
  color(0pt)=(titleleft);
  color(\paperwidth)=(titleright)}
  
\defbeamertemplate*{frametitle}{horizontal shading}
{%
  \nointerlineskip%
  %\vskip-2pt%
  \hbox{\leavevmode
    \advance\beamer@leftmargin by -12bp%
    \advance\beamer@rightmargin by -12bp%
    \beamer@tempdim=\textwidth%
    \advance\beamer@tempdim by \beamer@leftmargin%
    \advance\beamer@tempdim by \beamer@rightmargin%
    \hskip-\Gm@lmargin\hbox{%
      \setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{\paperwidth}%
          \vbox{}\vskip-.75ex%
          \leftskip0.3cm%
          \rightskip0.3cm plus1fil\leavevmode
          \insertframetitle%
          \ifx\insertframesubtitle\@empty%
            \strut\par%
          \else
            \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
          \fi%
          \nointerlineskip
          \vbox{}%
          \end{minipage}}%
      \beamer@tempdim=\ht\beamer@tempbox%
      \advance\beamer@tempdim by 2pt%
      \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
        \usebeamercolor{frametitle right}
        \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
        \pgfusepath{clip}
        \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
      \end{pgfpicture}
      \hskip-\paperwidth%
      \box\beamer@tempbox%
    }%
    \hskip-\Gm@rmargin%
  }%
    \vskip-2pt
}
\makeatother

%%  Define Footer (solid blue bar with text and formatting defined in the associated .tex file)

\def\footertext#1 {\def\@footertext{#1}}
\def\@footertext{footertext}
\defbeamertemplate*{footline}{my footline}
{
    \ifnum \insertpagenumber=1
      \leavevmode%
      \hbox{%
      \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,center]{}%
        % empty environment to raise height
      \end{beamercolorbox}}%
      \vskip0pt%
    \else
      \leavevmode%
      \hbox{%
      \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,left]{footlinecolor}%
\addFootertext{\@footertext}
      \end{beamercolorbox}}%
      \vskip0pt%
    \fi
}
\newcommand{\addFootertext}[1] {#1}

\setbeamertemplate{footline}[my footline]

\newcommand{\vv}{\vspace*{\fill}}
\newcommand{\hh}{\hspace*{\fill}}
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=blue!20,inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}



%% Define logo for bottom right of all content slides


% \pgfdeclareimage[height=0.5cm]{university-logo}{UNCG_logo_math.png}
% \logo{\pgfuseimage{university-logo}}


\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=south east,yshift=2pt,xshift=-5pt] at (current page.south east) {\includegraphics[height=1cm]{UNCG_logo_math.png}};
\end{tikzpicture}}









