% (c) 2002 Matthew Boedicker <mboedick@mboedick.org> (original author)
%     http://mboedick.org
% (c) 2003-2007 David J. Grant <davidgrant-at-gmail.com> http://www.davidgrant.ca
% (c) 2008 Nathaniel Johnston <nathaniel@nathanieljohnston.com>
%     http://www.nathanieljohnston.com
%
% This work is licensed under the Creative Commons Attribution-Noncommercial-Share
% Alike 2.5 License. To view a copy of this license, visit
% http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to Creative
% Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
{% raw %}
\documentclass[letterpaper,11pt]{article}
\newlength{\outerbordwidth}
\pagestyle{empty}
\raggedbottom
\raggedright
\usepackage[svgnames]{xcolor}
\usepackage{framed, array}
\usepackage{tocloft}
\usepackage[backend=bibtex,maxnames=99]{biblatex}
\usepackage{hyperref}
\usepackage{times}
\usepackage{enumitem}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\setlist{nosep} % or \setlist{noitemsep} to leave space around whole list
%-----------------------------------------------------------
% Hyperlink setup
\hypersetup{
    colorlinks=true,        % false: boxed links; true: colored links
    linkcolor=red,          % color of internal links
    citecolor=green,        % color of links to bibliography
    filecolor=magenta,      % color of file links
    urlcolor=red            % color of external links
}

%-----------------------------------------------------------
%Edit these values as you see fit

% Width of border outside of title bars
\setlength{\outerbordwidth}{3pt}
% Outer background color of title bars (0 = black, 1 = white)
\definecolor{shadecolor}{gray}{0.75}
% Inner background color of title bars
\definecolor{shadecolorB}{gray}{0.93}


%-----------------------------------------------------------
%Margin setup

\setlength{\evensidemargin}{-0.25in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\oddsidemargin}{-0.25in}
\setlength{\paperheight}{11in}
\setlength{\paperwidth}{8.5in}
\setlength{\tabcolsep}{0in}
\setlength{\textheight}{9.5in}
\setlength{\textwidth}{7in}
\setlength{\topmargin}{-0.3in}
\setlength{\topskip}{0in}
\setlength{\voffset}{0.1in}
\setlength\LTleft{0.25in}
\setlength\LTright{0.25in}

\newlength{\subitemsoffset}
\setlength{\subitemsoffset}{-24pt}
\newlength{\itemsoffset}
\setlength{\itemsoffset}{-24pt}


%-----------------------------------------------------------
%Custom commands
\newcommand{\resitem}[1]{\item #1 \vspace{-2pt}}
\newcommand{\resheading}[1]{\vspace{8pt}
  \parbox{\textwidth}{\setlength{\fboxsep}{\outerbordwidth}
    \begin{shaded}
    \setlength{\fboxsep}{0pt}\framebox[\textwidth][l]{\setlength{\fboxsep}{4pt}\fcolorbox{shadecolorB}{shadecolorB}{\textbf{\sffamily{\mbox{~}\makebox[6.762in][l]{\large #1} \vphantom{p\^{E}}}}}}
    \end{shaded}
  }\vspace{-5pt}
}

\newcommand{\ressubheadingshort}[3]{
    \begin{center}
    \begin{tabular*}{6.5in}{l@{\extracolsep{\fill}}r}
        \multicolumn{2}{c}{\textbf{#1} \cftdotfill{\cftdotsep} #2} \\
        \textit{#3} & \\
        \vphantom{E}
    \end{tabular*}
    \end{center}
    \vspace{\itemsoffset}
}

\newcommand{\ressubheading}[4]{
    \begin{center}
    \begin{tabular*}{6.5in}{l@{\extracolsep{\fill}}r}
        \multicolumn{2}{c}{\textbf{#1} \cftdotfill{\cftdotsep} #2} \\
        \multicolumn{2}{c}{\textit{#3} \cftdotfill{\cftdotsep} \textit{#4}} \\
        \vphantom{E}
    \end{tabular*}
    \end{center}
    \vspace{\itemsoffset}
}

\newcommand{\ressubheadingitemslongtitle}[5]{
    \begin{center}
    \begin{tabular*}{6.5in}{l@{\extracolsep{\fill}}r}
        \multicolumn{2}{p{6.5in}}{\textbf{#1}\cftdotfill{\cftdotsep} #2} \\
        \multicolumn{2}{p{6.5in}}{\textit{#3} \cftdotfill{\cftdotsep} \textit{#4}} \\
        \vphantom{E}
    \end{tabular*}
    \end{center}
    \vspace{\subitemsoffset}
    \begin{itemize}\renewcommand{\labelitemi}{}
        \item\begin{itemize}
        #5
        \end{itemize}
    \end{itemize}
}

\newcommand{\ressubheadingitems}[5]{
    \begin{center}
    \begin{tabular*}{6.5in}{l@{\extracolsep{\fill}}r}
        \multicolumn{2}{c}{\textbf{#1} \cftdotfill{\cftdotsep} #2} \\
        \multicolumn{2}{p{6.5in}}{\textit{#3} \cftdotfill{\cftdotsep} \textit{#4}} \\
        \vphantom{E}
    \end{tabular*}
    \end{center}
    \vspace{\subitemsoffset}
    \begin{itemize}\renewcommand{\labelitemi}{}
        \item\begin{itemize}
        #5
        \end{itemize}
    \end{itemize}
}

%-----------------------------------------------------------
{% endraw %}

% Bibliography
\bibliography{ {{-p['_id']-}} }{}
%\bibliographystyle{plain}

\begin{document}


\begin{tabular*}{7in}{l@{\extracolsep{\fill}}r}
\textbf{\Large {{p['title']}} {{p['name']}}} & \textbf{\today} \\
{{employment[0]['organization'] if employment else ''}} & {{p['email']}} \\
{{p.get('address', '')}} & {{p.get('phone', '')}} \\
\end{tabular*}
\\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Education}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% for e in education %}
\ressubheadingitems{ {{-latex_safe(e['institution'])-}} }
    { {{-e['location']-}} }
    { {{-latex_safe(e['degree'])-}} }
    { {{-month_and_year(e.get('begin_month'), e.get('begin_year'))}} -
      {{month_and_year(e.get('end_month'), e.get('end_year'))-}} }
    { {% for o in e.get('other', ()) %}
        \resitem{ {{- o -}} }
     {% endfor%}
     {% if 'gpa' in e %}
        \resitem{GPA: {{e['gpa']-}} }
     {% endif %}
    }
{% endfor %}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Employment}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% for e in employment %}
\ressubheadingitems{ {{-latex_safe(e['organization'])-}} }
    { {{-e['location']-}} }
    { {{-latex_safe(e['position'])-}} }
    { {{-month_and_year(e.get('begin_month'), e.get('begin_year'))}} -
      {{month_and_year(e.get('end_month'), e.get('end_year'))-}} }
    { {% for o in e.get('other', ()) %}
        \resitem{ {{-latex_safe(o)-}} }
     {% endfor%}
    }
{% endfor %}

{% if len(aghs) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Awards \& Honors}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vspace{-2pt}
\begin{center}
\begin{longtable}{p{5.75in} l@{\extracolsep{\fill}} r }
{% for agh in aghs %}
    {{-agh['description']-}} \dotfill & \hspace{.1in} & {{-agh['year']-}}\\
{% endfor %}
    \vphantom{E}
\end{longtable}
\end{center}\vspace*{-16pt}
{% endif %}

{% if len(p["research_focus_areas"]) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{ Major research focus area(s) and current projects.}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection*{Research Focus Areas}
\begin{itemize}[label=$-$]
{% for areas in p["research_focus_areas"]%}
\item {{ latex_safe(areas["description"]) }}
{% endfor%}
\end{itemize}
{% endif %}

{% if len(projects) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Projects}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% for proj in projects %}
{% set me = proj['team'][0] %}
\ressubheadingitemslongtitle{ {{-proj['name']-}} }
    { {{-me['position']-}} }
    { {{-proj['description']-}} }
    { {{-month_and_year(me.get('begin_month'), me.get('begin_year'))}} -
      {{month_and_year(me.get('end_month'), me.get('end_year'))-}} }
    {
      {% for o in proj['other'] %}
        \resitem{ {{-latex_safe(o)-}} }
      {% endfor %}
      {% if proj['website'] and len(proj['website']) > 0 %}
      \resitem{Website: \url{ {{-latex_safe(proj['website'], url_check=False)-}} } }
      {% endif %}
      }
\vspace{0.5em}
{% endfor %}
{% endif %}


{% if len(pi_grants) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Grants as Lead PI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\Large\underline{Lifetime Total Grant Amount as PI:} \textbf{ \${{"{:,.2f}".format(pi_amount)}} }}

{% for grant in pi_grants %}
\ressubheadingitemslongtitle{ {{-grant['title']-}} }
    { \${{-"{:,.2f}".format(grant['amount'])-}} }
    { {{-grant['funder']}} {{grant['program']}} {{latex_safe(grant.get('grant_id', ''))-}} }
    { {{-month_and_year(grant.get('begin_month'), grant.get('begin_year'))}} -
      {{month_and_year(grant.get('end_month'), grant.get('end_year'))-}} }
    {
      {% if 'narrative' in grant or 'benefit_of_collaboration' in grant %}
        \resitem{
          {%- if 'narrative' in grant %}
            \href{ {{-grant['narrative']-}} }{Narrative}.
          {%- endif %}
          {%- if 'benefit_of_collaboration' in grant %}
            \href{ {{-grant['benefit_of_collaboration']-}} }{Benefit of Collaboration}.
          {%- endif %}
          {%- if 'call_for_proposals' in grant %}
            \href{ {{-grant['call_for_proposals']-}} }{Call for Proposals}.
          {%- endif %}
        }
      {% endif %}
    }
{% endfor %}
{% endif %}


{% if len(coi_grants) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Grants as Non-Lead PI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\Large\underline{Lifetime Subaward Grant Amount:} \textbf{ \${{"{:,.2f}".format(coi_sub_amount)}} }
subaward of \textbf{ \${{"{:,.2f}".format(coi_amount)}} } total awarded. }

{% for grant in coi_grants %}
\ressubheadingitemslongtitle{ {{-grant['title']-}} }
    { \${{-"{:,.2f}".format(grant['subaward_amount'])-}} }
    { {{-grant['funder']}} {{grant['program']}} {{latex_safe(grant.get('grant_id', ''))-}} }
    { {{-month_and_year(grant.get('begin_month'), grant.get('begin_year'))}} -
      {{month_and_year(grant.get('end_month'), grant.get('end_year'))-}} }
    {
      \resitem{Role: {{grant['me']['position']-}} }
      \resitem{Total award: \${{-"{:,.2f}".format(grant['amount'])-}} }
      \resitem{PI: {{grant['pi']['name']}} at {{latex_safe(grant['pi']['institution'])}} }
      {% if 'narrative' in grant or 'benefit_of_collaboration' in grant %}
        \resitem{
          {%- if 'narrative' in grant %}
            \href{ {{-grant['narrative']-}} }{Narrative}.
          {%- endif %}
          {%- if 'benefit_of_collaboration' in grant %}
            \href{ {{-grant['benefit_of_collaboration']-}} }{Benefit of Collaboration}.
          {%- endif %}
          {%- if 'call_for_proposals' in grant %}
            \href{ {{-grant['call_for_proposals']-}} }{Call for Proposals}.
          {%- endif %}
        }
      {% endif %}
    }
{% endfor %}
{% endif %}


{% if len(currentphds) > 0 or len(graduatedphds) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{ Graduate and Postgraduate advising}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% if len(currentphds) > 0 %}
\subsection*{ Current Ph.D. students }
    \begin{itemize}[label=$-$]
    {% for ugr in currentphds %}
        \item   {{latex_safe(ugr['name'])-}}  \\
    {%endfor%}
    \end{itemize}
{% endif %}
{% if len(graduatedphds) > 0 %}
\subsection*{ Graduated Ph.D. students }
    \begin{itemize}[label=$-$]
    {% for ugr in graduatedphds %}
        \item   {{latex_safe(ugr['name']) }}\textemdash Graduated {{ugr['end_year']}}  \\
    {%endfor%}
    \end{itemize}
{% endif %}
{% endif %}

{% if len(postdocs) > 0 %}
\subsection*{ Postdoctoral researchers and research scientists supported on grants}
    \begin{itemize}[label=$-$]
    {% for ugr in postdocs %}
        \item   {{latex_safe(ugr['name'])-}} - ({{ ugr['begin_year']}} - {{ ugr['end_year']}}) \\
    {%endfor%}
    \end{itemize}
{% endif %}

{% if len(visitors) > 0 %}
        \subsection*{ Self-funded visitors contributing to research}
    \begin{itemize}[label=$-$]
    {% for ugr in visitors %}
        \item   {{latex_safe(ugr['name'])-}}\textemdash {{ugr['position']}}  \\
    {%endfor%}
    \end{itemize}
{% endif %}


{% if len(masters) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{ Masters students advised }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{itemize}[label=$-$]
    {% for ugr in masters %}
        \item   {{latex_safe(ugr['name'])-}} \textemdash {{latex_safe(ugr['role'])}}  \\
    {%endfor%}
    \end{itemize}
{% endif %}

{% if len(undergrads) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{ Undergraduate research students }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{itemize}[label=$-$]
    {% for ugr in undergrads %}
        \item   {{latex_safe(ugr['name'])-}} \textemdash {{latex_safe(ugr['role'])}}  \\
    {%endfor%}
    \end{itemize}
{% endif %}

{% if len(service) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Service}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vspace{-2pt}
\begin{center}
\begin{longtable}{p{5.75in} l@{\extracolsep{\fill}} r }
{% for serve in service %}
    {{-serve['description']-}} \dotfill & \hspace{.1in} & {{-serve['year']-}} \\
{% endfor %}
    \vphantom{E}
\end{longtable}
\end{center}\vspace*{-16pt}
{% endif %}

{% if len(pubs) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Publications}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    {% if hindex %}
\textbf{ h-index:}
    \begin{itemize}[label=$-$]
            \item   h = {{ str(hindex['h']) }}
(since = {{hindex['since']}}, total citations = {{ hindex["citations"]-}} )\\
h-last five years = {{ str(hindex['h_last_five']) }}
(since = {{ hindex['year']-5 }}, total citations = {{ hindex["citations_last_five"]-}} )\\
pulled: {{ hindex["month"] }}/{{ hindex["day"] }}/{{ hindex["year"] }}\\
Google Scholar profile URL:{{ latex_safe_url(latex_safe(p["google_scholar_url"])) }}\\
    \end{itemize}{% endif %}

    \vskip 12pt
\begin{enumerate}
{% for pub in pubs %}
    \item \fullcite{ {{-pub['_id']-}} }
{% endfor %}
\end{enumerate}
{% endif %}

{% if len(presentations) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Presentations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{enumerate}
{% for pres in presentations %}
\item {{ latex_safe(pres['authors'])-}}, {\bf {{ latex_safe(
sentencecase(pres['title']))-}} },
{%-set inst = pres['institution'] %}
{%-if pres['type'] in ['colloquium', 'seminar']%}
{\it {{ latex_safe(pres['type']).title()-}} },
{\it {{ latex_safe(pres['department']['name'])-}} },
{\it {{ latex_safe(inst['name'])-}} },
{\it {{ latex_safe(inst['city'])-}} }\
{\it {{ latex_safe(inst['state'])-}}},
{%-else %}
{\it {{ latex_safe(pres['meeting_name'])-}} },
{\it {{ latex_safe(pres['location'])-}} },
{%-endif %}
{%-if pres['webinar'] in ['true', true]%}
{\it (Webinar),}
{%-endif -%}
{ {{ latex_safe(monthstyle.get(pres['begin_month'],'None'))}} }
{{-pres['begin_day']-}}
{%-if not pres['end_day'] or pres['end_day'] == pres['begin_day']-%}
$^\mathrm{ {{-pres['begin_day_suffix']-}} }$
{%-elif pres['end_month'] != pres['begin_month']-%}
--{{-pres['end_month']-}} {{-pres['end_day']-}}
$^\mathrm{ {{-pres['end_day_suffix']-}} }$
{%-else-%}
--{{-pres['end_day']-}}
$^\mathrm{ {{-pres['end_day_suffix']-}} }$
{%-endif %}
( {{-pres['begin_year']-}} ).
{% endfor %}
\end{enumerate}
{% endif %}


%\clearpage
{% if 'teaching' in p and len(p['teaching']) > 0 %}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Teaching Experience}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% for t in p['teaching'] %}
\ressubheadingitems{ {{-t['course']-}} }
    { {{-t['organization']-}} }
    { {{-t['position']-}} }
    { {{-month_and_year(t.get('month'), t.get('year'))-}}
      {% if 'end_year' in t %}-
        {{-month_and_year(t.get('end_month'), t.get('end_year'))-}}
      {% endif %}
    }
    { {% if 'description' in t %}
        \resitem{ {{-latex_safe(t['description'])-}} }
      {% endif %}
      {% if 'website' in t or 'syllabus' in t or 'video' in t or 'materials' in t %}
        \resitem{
          {%- if 'website' in t %}
            \href{ {{-latex_safe_url(t['website'])-}} }{Website}.
          {%- endif %}
          {%- if 'syllabus' in t %}
            \href{ {{-latex_safe_url(t['syllabus'])-}} }{Syllabus}.
          {%- endif %}
          {%- if 'video' in t %}
            \href{ {{-latex_safe_url(t['video'])-}} }{Video}.
          {%- endif %}
          {%- if 'materials' in t %}
            \href{ {{-latex_safe_url(t['materials'])-}} }{Source Materials}.
          {%- endif %}
        }
      {% endif %}
    }
{% endfor %}
{% endif %}


{%if 'membership' in p and len(p['membership']) > 0%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Memberships}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{% for m in p['membership'] %}
\ressubheadingshort{ {{-latex_safe(m['organization'])-}} }
    {\em{ {{-month_and_year(m.get('begin_month'), m.get('begin_year'))-}} -
          {{-month_and_year(m.get('end_month'), m.get('end_year'))-}} } }
    { {{-latex_safe(m['position'])-}} }
{% endfor %}{% endif %}

{%if 'skills' in p and len(p['skills']) > 0%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resheading{Skills}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{itemize}
{%for cat, cgrp in groupby(p['skills'], key=category_val)%}
  \item {{cat}}
  \begin{itemize}{%for lvl, lgrp in groupby(cgrp, key=level_val)%}
    \resitem{\textbf{ {{-lvl.capitalize()}}:} {{gets(lgrp, 'name', '<nemo>') | join(', ')-}} }
  {%endfor%}\end{itemize}
{%endfor%}
\end{itemize}
{%endif%}
\end{document}
