
% $ This nullifies emacs subscripting in following%
%%BEGIN: This begins the custom header
\usepackage{array}
\usepackage{xparse}
\usepackage{babel}
\usepackage{datetime}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{graphicx}
\usepackage{multicol}

\definecolor{darkblue}{HTML}{1e2277}
\definecolor{kublue81186}{RGB}{0,81,186}
\newdateformat{monddyyyy}{\shortmonthname[\THEMONTH].~\THEDAY,~\THEYEAR}


%% BEGIN custom header
\ExplSyntaxOn
\NewDocumentCommand \guidesetup { m }
 {
  \keys_set:nn { guide } { #1 }
 }

\int_new:N \g_guide_authors_int
\prop_new:N \g_guide_authors_prop
\tl_new:N \l__guide_authors_tl

\keys_define:nn { guide }
 {
  author .code:n =
   {
    \int_gincr:N \g_guide_authors_int
    \keys_set:nn { guide / author } { #1 }
   },
  author/firstname .code:n = { \guide_add_author:nn { firstname } { #1 } },
  author/lastname .code:n = { \guide_add_author:nn { lastname } { #1 } },
  author/affiliation .code:n = { \guide_add_author:nn { affiliation } { #1 } },
  author/email .code:n = { \guide_add_author:nn { email } { #1 } },
  leftlogo .tl_set:N = \l_guide_leftlogo_tl,
  rightlogo .tl_set:N = \l_guide_rightlogo_tl,
  number .tl_set:N = \l_guide_number_tl,
  title .tl_set:N = \l_guide_title_tl,
  subtitle .tl_set:N = \l_guide_subtitle_tl,
  keywords .tl_set:N = \l_guide_keywords_tl,
  url .tl_set:N = \l_guide_url_tl,
  title .initial:n = {TITLE~NEEDED},
}
\NewDocumentCommand \guidehdr { +O{} }
 {
  \group_begin:
  \keys_set:nn { guide } { #1 }
  \guide_hdr:
  \group_end:
 }
\cs_new_protected:Nn \guide_hdr:
 {
   \centering
   \noindent\fcolorbox{kublue81186}{white}{
  \begin{tabular}
   {
    @{}c
    >{\centering}m{ \dim_eval:n { \textwidth - 2.5in - 6\tabcolsep - 2\arrayrulewidth } }
    c@{}
   }
   &&\tabularnewline[-\dim_eval:n { -\normalbaselineskip + 3ex }]
  \begin{tabular}{@{}>{\centering}p{1.25in}@{}}
  \includegraphics[width=.75in]{\l_guide_leftlogo_tl}
  \end{tabular}
  &
  \centering
    {\textsc{\large{}\l_guide_title_tl}}
    \tl_if_empty:NF \l_guide_subtitle_tl
    {
      {\\\textsc{\large{}\l_guide_subtitle_tl}}
    }
  \\
  \textcolor{kublue81186}{\rule[0.5ex]{1\linewidth}{0.7pt}}\\
  \guide_print_authors:
  &
  \begin{tabular}{@{}>{\centering}p{1.25in}@{}}
  \includegraphics[width=1.25in]{\l_guide_rightlogo_tl}
  \end{tabular}
  \tabularnewline
  \tl_if_empty:NTF \l_guide_number_tl
   { \leavevmode\vphantom{G}}
   {\small\bfseries { Guide~No: ~ \tl_use:N \l_guide_number_tl }} & 
   \tl_if_empty:NF \l_guide_keywords_tl
   {\centering
    \textbf{Keywords}: ~ \l_guide_keywords_tl}
   & 
   \small\bfseries\monddyyyy\today \tabularnewline
   \tl_if_empty:NF \l_guide_url_tl
   {
   \multicolumn{3}{c}{
    See ~ \url{\l_guide_url_tl} ~ for ~ updates.}
     }
  \tabularnewline
  \end{tabular}
  }
}

\cs_new_protected:Nn \guide_add_author:nn
 {
  \prop_gput:Nxn \g_guide_authors_prop
   { #1 \int_to_arabic:n { \g_guide_authors_int } }
   { #2 }
 }
\cs_generate_variant:Nn \prop_gput:Nnn { Nx }
\cs_new_protected:Nn \guide_print_authors:
 {
  \tl_clear:N \l__guide_authors_tl
  \int_step_inline:nnnn { 1 } { 1 } { \g_guide_authors_int }
   {
    \tl_put_right:Nn \l__guide_authors_tl
     {
      \textbf
       {
        \prop_item:Nn \g_guide_authors_prop { firstname ##1 }~
        \prop_item:Nn \g_guide_authors_prop { lastname ##1 },~
       }
       \prop_item:Nn \g_guide_authors_prop { affiliation##1 },~
       \href{mailto:\prop_item:Nn \g_guide_authors_prop { email##1 } }
       {\url{\prop_item:Nn \g_guide_authors_prop { email##1 }}}
       \\
     }
   }
   \tl_use:N \l__guide_authors_tl
 }
\ExplSyntaxOff
%%END This ends the custom header


%%Now the hyperref colors

\hypersetup{
 unicode=true,pdfusetitle,bookmarks=true,
 bookmarksnumbered=false, bookmarksopen=false,
 breaklinks=true, pdfborder={0 0 0},
 pdfborderstyle={}, backref=false,
 colorlinks=true, linkcolor=darkblue,
 urlcolor=darkblue, citecolor=darkblue}

%% Was previously in "preambleFloatCenter.tex"
%%BEGIN: graphics and such inside floats are centered by default
\renewenvironment{figure}[1][]{%
 \ifthenelse{\equal{#1}{}}{%
   \@float{figure}
 }{%
   \@float{figure}[#1]%
 }%
 \centering
}{%
 \end@float
}
\renewenvironment{table}[1][]{%
 \ifthenelse{\equal{#1}{}}{%
   \@float{table}
 }{%
   \@float{table}[#1]%
 }%

 \centering
}{%
 \end@float
}
%%END: graphics and such inside floats are centered by default

