%==============================================================================
% Beamer style for the poster template posted at
% http://www.nathanieljohnston.com/2009/08/latex-poster-template/
%
% Created by the Computational Physics and Biophysics Group at Jacobs University
% https://teamwork.jacobs-university.de:8443/confluence/display/CoPandBiG/LaTeX+Poster
% Modified by Nathaniel Johnston (nathaniel@nathanieljohnston.com) in August 2009
% =============================================================================

\ProvidesPackage{beamerthemeUWATposter}
\RequirePackage{tikz}		% for drawing the nice rounded boxes
\usetikzlibrary{arrows,backgrounds}
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
\RequirePackage{textcomp}
\RequirePackage{amsmath,amssymb}
\usefonttheme{professionalfonts}
\newcommand{\makeruleinbox}{{\usebeamercolor[bg]{block alerted title}\centering\hspace*{-0.7cm}\rule{\inboxrule}{0.5cm}}}
\usepackage{ragged2e}

% Spacing before and inside list environments to add white space before lists and between items inside lists
\makeatletter
\def\@listi{\leftmargin\leftmarginii
\topsep 1ex % Spacing before lists
\parsep 0\p@ \@plus\p@
\itemsep 6pt} % Spacing between items
\makeatother

\usecaptiontemplate{\small\structure{\insertcaptionname~\insertcaptionnumber: }\insertcaption} % A fix for figure numbering

%-----------------------------------------------------------
% Define a whole bunch of custom colours and fonts
%-----------------------------------------------------------
\definecolor{yellow_2_UW}{RGB}{255,234,41}
\definecolor{yellow_3_UW}{RGB}{255,213,79}
\definecolor{yellow_4_UW}{RGB}{228,180,41}

% set the basic colors
\setbeamercolor{palette primary}   {fg=black,bg=white}
\setbeamercolor{palette secondary} {fg=black,bg=white}
\setbeamercolor{palette tertiary}  {bg=black,fg=white}
\setbeamercolor{palette quaternary}{fg=black,bg=white}
\setbeamercolor{structure}         {fg=black}
\setbeamercolor{titlelike}         {bg=black,fg=white}
\setbeamercolor{frametitle}        {bg=black!10,fg=black}
\setbeamercolor{cboxb}             {fg=black,bg=black}
\setbeamercolor{cboxr}             {fg=black,bg=red}

% set colors for itemize/enumerate
\setbeamercolor{item}{fg=themecolor}
\setbeamercolor{item projected}{fg=white,bg=themecolor}

% set colors for blocks
\setbeamercolor{block title}{fg=themecolor,bg=white}
\setbeamercolor{block body}{fg=black,bg=white}

% set colors for alerted blocks (blocks with frame)
%\setbeamercolor{block alerted title}{fg=themecolor,bg=black}
\setbeamercolor{block alerted title}{fg=themecolor,bg=white}
\setbeamercolor{block alerted body}{fg=black,bg=black!8}
\usepackage{fontspec}
% set the fonts
\setbeamerfont{section in head/foot}{series=\bfseries}
\setbeamerfont{block title}{series=\bfseries}
\setbeamerfont{block alerted title}{series=\bfseries}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamerfont{frametitle}{size=\large}
\setbeamerfont{block body}{series=\rmfamily}
%\setbeamerfont{block body}{size={\fontsize{32}{36}}}

% set some beamer theme options
\setbeamertemplate{title page}[default][colsep=-4bp,rounded=true]
\setbeamertemplate{sections/subsections in toc}[square]
\setbeamertemplate{items}[circle]
\setbeamertemplate{blocks}[width=0.0]
\beamertemplatenavigationsymbolsempty

% set bibliography style
\setbeamertemplate{bibliography item}[text]
\setbeamercolor{bibliography item}{fg=black,bg=white}
\setbeamercolor{bibliography entry author}{fg=black,bg=white}
\setbeamercolor{bibliography item}{fg=black,bg=white}

% define some length variables that are used by the template
\newlength{\inboxwd}
\newlength{\iinboxwd}
\newlength{\inboxrule}
\makeatletter
\makeatother



%==============================================================================
% Set the lengths of side, middle and columns margin.
%==============================================================================
\newlength{\sidemargin}
\newlength{\middlemargin}
\newlength{\colwidth}
\newlength{\onecolwidth}
\setlength{\sidemargin}{0.04\paperwidth} % Separation width (white space) between columns
\setlength{\middlemargin}{0.02\paperwidth} % Separation width (white space) between columns
\setlength{\colwidth}{\dimexpr (\paperwidth-2\sidemargin-\middlemargin)/2} % Width of one column
\setlength{\onecolwidth}{\dimexpr (\paperwidth-2\sidemargin)}
%\setlength{\twocolwid}{0.9\paperwidth} % Width of two columns


%==============================================================================
% Make a good hrule command
%==============================================================================
\newcommand{\Hrule}[5][.]{%
  \begin{columns}
  \begin{column}{\dimexpr (\paperwidth-#5)/2}\end{column}
  \begin{column}{#5}
  \par\addvspace{#3}%
  \begingroup\color{#1}%
  \hrule height #2
  \endgroup
  \vspace{#4}
  \end{column}
  \begin{column}{\dimexpr (\paperwidth-#5)/2}\end{column}
  \end{columns}
}


%==============================================================================
% build the poster title
%==============================================================================

\setbeamertemplate{headline}{
 \leavevmode % make sure we are in horizontal mode
  \begin{columns}
      \begin{column}{\sidemargin}\end{column}
      \begin{column}{1.5\colwidth}
        \vskip2cm
        \raggedright
        \usebeamercolor{title in headline}{\color{black}\Huge{\textbf{\inserttitle}}\\[0.5ex] \par}
        \usebeamercolor{author in headline}{\color{black}\LARGE{\insertauthor}\\[1ex]}
        \usebeamercolor{institute in headline}{\color{black}\normalsize{\insertinstitute}}
        \vskip1cm
      \end{column}
      \begin{column}{\middlemargin}\end{column}
      \begin{column}{0.5\colwidth}
      \begin{center}
      \includegraphics[width=\textwidth]{images/UniversityOfWaterloo_logo_vert_cmyk.eps}
      \end{center}
      \end{column}
      \begin{column}{\sidemargin}\end{column}
  \end{columns}
}

% Block definition
\setbeamertemplate{block begin}
{
  \par\vskip\medskipamount
  \begin{beamercolorbox}[colsep*=0ex,dp={2ex},left]{block title}
    \vskip-0.25cm
    \usebeamerfont{block title}\Large\insertblocktitle
%% Uncomment the next two lines to add a line below the box title
%    \vskip-1.5cm
%  	{\rule{\textwidth}{0.4pt}}
    \vskip0.5cm

  \end{beamercolorbox}
  {\parskip0pt\par}
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}

    \usebeamerfont{block body}
  \vskip-0.4cm
  
  \begin{beamercolorbox}[colsep*=0ex,vmode]{block body}
  \vspace{-0.1cm}
  %{\rule{\textwidth}{0.4pt}}
  \justifying
}

\setbeamertemplate{block end}
{
  \end{beamercolorbox}
  \vskip\smallskipamount
}


% Alert block definition (with frame)
\setbeamertemplate{block alerted begin}
{
  \par\vskip\medskipamount
  \begin{beamercolorbox}[sep=0ex,rounded=true,left,dp={2ex}]{block alerted title}
    \vskip0.01cm
    \usebeamerfont{block title}\Large\insertblocktitle
  \end{beamercolorbox}
  {\parskip0pt\par}
  \usebeamerfont{block body}
  \vskip-0.8cm
  \begin{beamercolorbox}[sep=0.5cm, rounded=true,center]{block alerted title}
  \setlength{\inboxwd}{\linewidth}
  \addtolength{\inboxwd}{-1cm}
  \begin{beamercolorbox}[rounded=true,wd={\inboxwd},center]{block alerted body}
  \setlength{\iinboxwd}{\inboxwd}
  \setlength{\inboxrule}{\inboxwd}
  \addtolength{\iinboxwd}{-0.5cm}
  \addtolength{\inboxrule}{0.5cm}
  \begin{center}
  \begin{minipage}{\iinboxwd}
  \justifying
}

\setbeamertemplate{block alerted end}
{
  \end{minipage}
  \end{center}
  \end{beamercolorbox}
  \end{beamercolorbox}
  \vskip\smallskipamount
}