%% Copyright 2016 Christophe Roger
%
% Author:
% Christophe Roger (Darwiin)
%
% Adapted:
% Feb. 27, 2021		Suren A. Chilingaryan
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is M. C. Roger.
%
% This work consists of the files awesome-source-cv.cls

\ProvidesClass{yaac-another-awesome-cv}[2020/03/24  v2.2.1 'YAAC: Another Awesome CV' Class]

\def\@@ptsize{10pt}

\DeclareOption{10pt}{\def\@@ptsize{10pt}}
\DeclareOption{11pt}{\def\@@ptsize{11pt}}
\DeclareOption{12pt}{\def\@@ptsize{12pt}}

\ProcessOptions\relax

\LoadClass[a4paper,\@@ptsize]{article}

\newif\if@showLinks   \@showLinksfalse
\newif\if@isCompact   \@isCompactfalse

\DeclareOption{green}{
  \def\@green{green}
}

\DeclareOption{red}{
  \def\@red{red}
}

\DeclareOption{indigo}{
  \def\@indigo{indigo}
}
\DeclareOption{orange}{
  \def\@orange{orange}
}

\DeclareOption{monochrome}{
  \def\@monochrome{monochrome}
}

\DeclareOption{localFont}{
  \def\@local{local}
}

\DeclareOption{alternative}{
  \def\@alternative{alternate}
}

\DeclareOption{dsvariant}{
  \def\@dsvariant{ds}
}

\DeclareOption{scivariant}{
  \def\@scivariant{sci}
  \def\scivariant{sci}
}


\DeclareOption{showLinks}{ \@showLinkstrue}
\DeclareOption{compact}{ \@isCompacttrue}

\ProcessOptions

% Dependences
%A Few Useful Packages
\RequirePackage[english]{babel}
%\RequirePackage[english,french]{babel}
\RequirePackage[utf8]{luainputenc}
\RequirePackage{fontspec} 					                 % for loading fonts
\RequirePackage{url,parskip} 	    % other packages for formatting
\RequirePackage[usenames,dvipsnames,table]{xcolor}
\RequirePackage{fullpage}
\RequirePackage[margin=1.5cm]{geometry}
\RequirePackage[fixed]{fontawesome5}
\RequirePackage{hyperref}
\RequirePackage{titlesec}
\RequirePackage{array}
\RequirePackage{enumitem}
\RequirePackage{longtable}
\RequirePackage{etoolbox}
\RequirePackage{tikz}
\RequirePackage[skins]{tcolorbox}
\RequirePackage{fancyhdr}
\RequirePackage{ifthen}

% DS: Latex complains
%\DeclareUnicodeCharacter{00E9}{\'{e}}
% Define default accent colors
\definecolor{headcolor}{HTML}{000066}       %BLUE
\definecolor{basecolor}{HTML}{000000}       %BLACK

\ifundef{\@green} {
  \ifundef{\@red} {
    \ifundef{\@indigo}{
      \ifundef{\@orange} {
        \ifundef{\@monochrome} {}
        { \definecolor{basecolor}{HTML}{000000}}
      }
      { \definecolor{basecolor}{HTML}{e68a00} }
    }
    { \definecolor{basecolor}{rgb}{0.2, 0.07, 0.48} }
  }
  { \definecolor{basecolor}{HTML}{b30000} }     %RED
}
{ \definecolor{basecolor}{rgb}{0.0, 0.62, 0.38} }

\definecolor{darkGrey}{HTML}{989898}

\colorlet{linkcolor}{basecolor}
\colorlet{accentcolor}{linkcolor!90}%{headcolor!90}
\colorlet{symbolcolor}{linkcolor!85}

% Setup hyperref package, and colours for links
%\definecolor{linkcolour}{rgb}{0,0.2,0.6}

\if@showLinks
  \hypersetup{%
    breaklinks
  }%
\else
  \hypersetup{%
    pdfborder = {0 0 0},
    breaklinks
  }%
\fi

% Setup fancyhdr package
\fancyhf{}
\fancyhfoffset{0em}
% Remove head rule
\renewcommand{\headrulewidth}{0pt}
%\fancyfoot[C]{\thepage}
\pagestyle{fancy}

%\pagestyle{empty}                         % non-numbered pages
%\font\fb=''[cmr10]''                      % for use with \LaTeX command

% Setup CV sections
\titleformat{\section}{\Large\raggedright}{}{0em}{}[\titlerule]
\titlespacing{\section}{0pt}{2pt}{2pt}

% Configure list
\setlist[itemize,1]{label=\faAngleRight, nosep, leftmargin=2em}
\setlist[itemize,2]{label=\faAngleRight, nosep, leftmargin=1.5em}

% Setup Array : new column type
\newcolumntype{R}[1]{>{\hfill}m{#1}}

%Italian hyphenation for the word: ''corporations''
\hyphenation{im-pre-se}

% Setup fonts
\defaultfontfeatures{Mapping=tex-text}
%

% Define font to use according to localFont option
\ifundef{\@local}
{
% DS: Original fonts are ugly
%  \setmainfont[BoldFont = Helvetica Neue, ItalicFont=Helvetica Neue Thin Italic ,SmallCapsFont = Helvetica Neue Light]{Helvetica Neue Thin}
%  \setmainfont{Source Sans Pro Light}[BoldFont = SourceSansPro-Regular, ItalicFont= Source Sans Pro Light Italic]
%  \setmainfont{TeX Gyre Termes}
%  \setmainfont{TeX Gyre Pagella}
%  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \setmainfont{Liberation Serif}[
%    Ligatures=TeX,
%    ItalicFont=* Italic,
%    BoldFont=* Bold,
%    BoldItalicFont=* Bold Italic,
%    UprightFont=* Regular,
    SmallCapsFont=Latin Modern Roman Caps
  ]
  \setsansfont{Liberation Sans}[SmallCapsFont={Liberation Sans}]
  \setmonofont{Liberation Mono}[SmallCapsFont={Liberation Mono}]

}
{
  \setmainfont{SourceSansPro-Light}[
    Path = fonts/,
    BoldFont = SourceSansPro-Regular,
    ItalicFont = SourceSansPro-LightIt]
}

% DS: Adapt default parameters
\newlength{\topoffset}
\setlength{\topoffset}{0.2em}

%New length definition
\newlength{\fulllength}
%\setlength{\fulllength}{17.8cm}
\setlength{\fulllength}{17.0cm}

\newlength{\topleftcolumnlength}
\setlength{\topleftcolumnlength}{3.5cm}
\newlength{\toprightcolumnlength}
\setlength{\toprightcolumnlength}{\dimexpr(\fulllength-\topleftcolumnlength)\relax}

\newlength{\leftcolumnlength}
\setlength{\leftcolumnlength}{2.5cm}

\newlength{\rightcolumnlength}
%\setlength{\rightcolumnlength}{15.3cm minus 1cm}
%\setlength{\rightcolumnlength}{\dimexpr(\fulllength-\leftcolumnlength)\relax}
\setlength{\rightcolumnlength}{\dimexpr(\fulllength-\leftcolumnlength)\relax}

% Override default left column length of (2.5cm)
% Usage: \setleftcolumnlength{<length>}
\newcommand{\setleftcolumnlength}[1]{
  \setlength{\leftcolumnlength}{#1}
  \setlength{\rightcolumnlength}{\dimexpr(\fulllength-\leftcolumnlength)\relax}
}

\newcommand{\settopleftcolumnlength}[1]{
  \setlength{\topleftcolumnlength}{#1}
  \setlength{\toprightcolumnlength}{\dimexpr(\fulllength-\topleftcolumnlength)\relax}
}


% Font Awesome icons aliases
\newcommand{\mailSymbol}{\faAt}
\newcommand{\locationSymbol}{\faMapMarker*}
\newcommand{\infoSymbol}{\faInfo}
\newcommand{\linkedinSymbol}{\faLinkedinIn}
\newcommand{\viadeoSymbol}{\faViadeo}
\newcommand{\mobileSymbol}{\faMobile*}
\newcommand{\githubSymbol}{\faGithub}
\newcommand{\stackoverflowSymbol}{\faStackOverflow}
\newcommand{\stackexchangeSymbol}{\faStackExchange}
\newcommand{\mediumSymbol}{\faMedium}
\newcommand{\bitbucketSymbol}{\faBitbucket}
\newcommand{\websiteSymbol}{\faLink}


\newcommand\link[2]{\color{linkcolor}\href{#1}{#2}\color{Black} }
\newcommand\important[1]{\textbf #1}

% Create a tag
% Usage: \cvtag{<tag label>}
\newcommand{\cvtag}[1]{%
  \tikz[baseline]\node[anchor=base,draw=darkGrey!70,rounded corners=0.5ex,inner xsep=1ex,inner ysep =0.55ex,text height=1.3ex,text depth=.25ex]{#1};
}

% Render author's name
% Usage: \user{<firstanme>}{<lastname>}
\newcommand\user[2]{\color{accentcolor}{\LARGE #1 \textsc{\textbf{#2}}}\color{Black}}

% Render a text with its symbol
% Usage; \socialtext{<icon>}{<label>}
\newcommand{\socialtext}[2]{\mbox{\textcolor{symbolcolor}{#1}#2\hspace{0.8em}}}

% Render a link with its symbol
% Usage; \sociallink{<icon>}{<label>}
\newcommand{\sociallink}[3]{\mbox{\textcolor{symbolcolor}{#1}\link{#2}{#3}\hspace{0.8em}}}

% Define author's name
% Usage: \name{<firstname>}{<lastname>}
% Usage: \firstname{<firstname>}
% Usage: \lastname{<lastname>}
% Usage: \familyname{<familyname>}
\newcommand*{\name}[2]{\def\@firstname{#1}\def\@lastname{#2}}
\newcommand*{\firstname}[1]{\def\@firstname{#1}}
\newcommand*{\lastname}[1]{\def\@lastname{#1}}
\newcommand*{\familyname}[1]{\def\@lastname{#1}}
\def\@familyname{\@lastname}

% Define author's tagline
% Usage: \tagline{<tag line>}
\newcommand*{\tagline}[1]{\def\@tagline{#1}}

% Define author's photo
% Usage: \photo[<shape: circular, square, roundedsquare, squircle>]{<diameter>}{<photo>}
% The shape of the author's photo is circular by default.
\newcommand{\photo}[3][circular]{\def\@photo{#3}\def\@photodiameter{#2}\def\@photoshape{#1}}

% Render author's address
% Usage: \address{<address>}
\newcommand*{\address}[1]{\socialtext{\locationSymbol}{#1}}

% Render author's infos
% Usage: \infos{<infos>}
\newcommand*{\infos}[1]{\socialtext{\infoSymbol}{#1}}

% DS: Defrancise, shorten
% Render author's linked-in (optional)
% Usage: \linkedin{<linked-in-nick>}
%\newcommand*{\linkedin}[1]{\sociallink{\linkedinSymbol}{http://www.linkedin.com/in/#1/fr}{linkedin.com/in/#1}}
\newcommand*{\linkedin}[1]{\sociallink{\linkedinSymbol}{http://www.linkedin.com/in/#1}{linkedin}}
%\newcommand*{\linkedin}[1]{\sociallink{\linkedinSymbol}{http://www.linkedin.com/in/#1}{#1}}

% Render author's viadeo(optional)
% Usage: \viadeo{<viadeo-nick>}
\newcommand*{\viadeo}[1]{\sociallink{\viadeoSymbol}{http://www.viadeo.com/fr/profile/#1}{viadeo.com/fr/profile/#1}}

% Render author's github (optional)
% Usage: \github{<github-nick>}
\newcommand*{\github}[1]{\sociallink{\githubSymbol}{https://www.github.com/#1}{github.com/#1}}           % Github icon + URL

% Render author's stackoverflow profile (optional)
% Usage: \stackoverflow{<stackoverflow-user-id>}
\newcommand*{\stackoverflow}[1]{\sociallink{\stackoverflowSymbol}{https://www.stackoverflow.com/u/#1}{stackoverflow.com/u/#1}}

% Render author's stackexchange profile (optional)
% Usage: \stackexchange{<stackexchange-user-id>}
\newcommand*{\stackexchange}[1]{\sociallink{\stackexchangeSymbol}{https://stackexchange.com/users/#1}{stackexchange.com/users/#1}}

% Render author's medium (optional)
% Usage: \medium{<medium-nick>}
\newcommand*{\medium}[1]{\sociallink{\mediumSymbol}{https://www.medium.com/@#1}{medium.com/#1}}

% Render author's bitbucket (optional)
% Usage: \bitbucket{<bitbucket-account-name>}
\newcommand*{\bitbucket}[1]{\sociallink{\bitbucketSymbol}{https://bitbucket.com/#1}{bitbucket.com/#1}}

% Render author's email (optional)
% Usage: \email{<email adress>}
\newcommand*{\email}[1]{\sociallink{\mailSymbol}{mailto:#1}{#1}}

% Render a website link (optional)
% Usage: \website{<website name>}{<website adress>}
\newcommand*{\website}[2]{\sociallink{\websiteSymbol}{#1}{#2}}

% Render author's mobile phone (optional)
% Usage: \smartphone{<mobile phone number>}
\newcommand*\smartphone[1]{\socialtext{\mobileSymbol}{#1}}

% Render author's telegram acoount (optional)
% Usage: \telegram{@telegram_id}
\newcommand*\telegram[1]{\socialtext{\faTelegram}{#1}}

% Render author's tagline
\newcommand\resumetitle[1]{
  \ifundef{\@alternative}{
	 \par{
	 	 \bigskip\center{\Large \color{accentcolor}\textbf{#1}\color{Black}}\par
	 }
	 \bigskip
  }{
    \color{accentcolor}\textbf{\large{#1}}\color{black}
  }
}

\newcommand\idphoto{
	\ifthenelse{\equal{\@photoshape}{square}}{
		% Draw square photo
		\tikz\path[fill overzoom image={\@photo}]rectangle(\linewidth,\linewidth);
	}{
		\ifthenelse{\equal{\@photoshape}{roundedsquare}}{
			% Draw square photo with rounded corners
			\tikz\path[fill overzoom image={\@photo}][rounded corners=2mm]rectangle(\linewidth,\linewidth);
		}{
			\ifthenelse{\equal{\@photoshape}{squircle}}{
				% Draw squircle photo
				\tikz\path[fill overzoom image={\@photo}][rounded corners=8mm]rectangle(\linewidth,\linewidth);
				}{
					% Draw circular photo
					\tikz\path[fill overzoom image={\@photo}]circle[radius=0.5\linewidth];
				}
		}

	}
}

% Define social entries to print in header
\newcommand{\socialinfo}[1]{\def\@socialinfo{#1}}
\newcommand{\headermsg}[1]{\def\@headermsg{#1}}

% Render CV header
% Needs \@firstname, \@lastname and \@tagline to be defined
\newcommand*{\makecvheader}{
 \ifdef{\@dsvariant}{
    \ifundef{\@photodiameter}{
      \begin{minipage}{\linewidth}
    }{
      \begin{minipage}{\dimexpr\linewidth-\@photodiameter-2em}
    }
    \ifundef{\@tagline}{
	\user{\@firstname}{\@lastname}
    }{
	\user{\@firstname}{\@lastname}\\
	\resumetitle{\@tagline}
    }
    \vskip-\topskip\vskip0.3em\rule{\linewidth}{0.1pt}
    \smallskip
    \begin{tabular}{>{\raggedright}m{\topleftcolumnlength} m{\toprightcolumnlength}}
    \noalign{\vskip\topoffset}
    \small{\@socialinfo} & \@headermsg
    \end{tabular}
    \end{minipage}

    \ifdef{\@photodiameter}{
      \begin{minipage}{\@photodiameter}
        \idphoto
      \end{minipage}
    }{}
    \bigskip
 }{
  \ifundef{\@alternative}{
    \ifundef{\@photodiameter}{
      \begin{minipage}{\linewidth}
    }{
      \begin{minipage}{\dimexpr\linewidth-\@photodiameter-2em}
    }
    \color{accentcolor}\user{\@firstname}{\@lastname}\color{black}\\
    \small{\@socialinfo}
    \end{minipage}
    \ifdef{\@photodiameter}{
      \begin{minipage}{\@photodiameter}
        \idphoto
      \end{minipage}
    }{}
    \resumetitle{\@tagline}
  }{
    \ifundef{\@photodiameter}{
      \begin{minipage}{\linewidth}
    }{
      \begin{minipage}{\dimexpr\linewidth-\@photodiameter-2em}
    }
    \user{\@firstname}{\@lastname}\\
    \resumetitle{\@tagline}
    \smallskip\\
    \small{\@socialinfo}
    \end{minipage}
    \ifdef{\@photodiameter}{
      \begin{minipage}{\@photodiameter}
        \idphoto
      \end{minipage}
    }{}
    \bigskip
  }
 }
}

% Define a footer for CV
% Usage: \makecvfooter{<left>}{<center>}{<right>}
\newcommand*{\makecvfooter}[3]{%
  \fancyfoot{}
  \fancyfoot[L]{#1}
  \fancyfoot[C]{#2}
  \fancyfoot[R]{#3}
}

% Resume part title definition
\newcommand\sectionTitle[2]{\section{\texorpdfstring{\color{accentcolor}#2\enspace \textsc{#1}}{#1}}}

% Define the 'keywords' environment
\newenvironment{keywords}{%
  \renewcommand{\arraystretch}{1.1}

  \begin{tabular}{>{}r>{}p{13cm}}
}{%
  \end{tabular}
}



% Render a scholarshipentry in the scolarship environment
% Usage: \scholarshipentry{<date>}{<description>}
\newcommand\keywordsentry[2]{
  \textbf{#1} &   #2\\
}

% Define a new column type for the scholarship environment
\newcolumntype{Y}{>{\raggedleft}p{\leftcolumnlength}}

% Define the 'scholarship' environment
\newenvironment{scholarship}{%
  \begin{tabular}{Y p{\rightcolumnlength}}
}{%
  \end{tabular}
}

% Render a scholarshipentry in the scolarship environment
% Usage: \scholarshipentry{<date>}{<description>}
\newcommand\scholarshipentry[2]{
  #1    &  #2 \\
}

% Define the 'skills' environment
\newenvironment{skills}{%
  \begin{longtable}{R{\leftcolumnlength}p{\rightcolumnlength}}
}{%
  \end{longtable}
}

% Render a skill in the skills environment
% Usage: \skill{<skill>}{<level>}
\newcommand\skill[2]{
  \textbf{#1}    & \foreach \x in {1,...,5}{{\color{accentcolor!80} \ifnumgreater{\x}{#2}{\faCircle[regular]}{\faCircle}}\enspace } \\
}

\newcolumntype{E}{>{\raggedright\arraybackslash}p{\rightcolumnlength}}

% Define the 'experiences' environment
\newenvironment{experiences}{%
  \begin{longtable}{R{\leftcolumnlength}|E}
}{%
  \end{longtable}
}

% Render an experience in the experiences environment
% Usage:
% \experience
%  {<End date>}      {<Title>}{<Enterprise>}{<Country>}
%  {<Start date}     {
%                      <Experience description (Could be a list)>
%                    }
%                    {<Technology list>}
\newcommand\experience[7]{
  \textbf{#1}    & \textbf{#2, \textsc{#3}, #4}   								\\*
  \textbf{#5}    & \begin{minipage}[t]{\rightcolumnlength}
  					         #6
                   \end{minipage}										\\*
                 & \footnotesize{\foreach \n in {#7}{\cvtag{\n}}} 	\\
  }

% Render a consultant experience in the experiences environment
% Usage:
% \consultantexperience
%  {<End date>}      {<Consultant title>}{<Consulting Enterprise>}{<Country>}
%  {<Start date}     {<Client title>}{<Client business unit>}
%                    {
%                      <Experience description (Could be a list)>
%                    }
%                    {<Technology list>}
\newcommand\consultantexperience[9]{
  \textbf{#1}    & \textbf{#2, \textsc{#3}, #4}   								\\*
  \textbf{#5}    & \emph{#6} pour \textsc{#7}                       				\\*
  				       & \begin{minipage}[t]{\rightcolumnlength}
  						        #8
                   	\end{minipage}										\\*
                 & \footnotesize{\foreach \n in {#9}{\cvtag{\n}}} 	\\
  }

% Define the empty separator macro with different spacing according to document class option 'compact'
\if@isCompact
  \newcommand\emptySeparator{\multicolumn{2}{c}{}\\[-0.6em]}
\else
  \newcommand\emptySeparator{\multicolumn{2}{c}{}\\}
\fi



% Define the 'projects' environment
\newenvironment{projets}{%
  \begin{longtable}{l}
}{%
  \end{longtable}
}

% Define the 'project' entry in the 'projects' environment
% Usage:
% \project
%   {<Project name>}{<dates>}
%   {<link1> <link2>}
%   {<Project description>}
%   {<techno1>,<techno2>}
\newcommand\projet[5]{
  \begin{minipage}[t]{\dimexpr(\linewidth) - 1.5em}
    \textbf{\textsc{#1}} \hfill \textsc{#2}\smallskip\\
    #3\\
    #4\smallskip\\
    \footnotesize{\foreach \n in {#5}{\cvtag{\n}}}\\
  \end{minipage}
  \\*
}


\newcommand*\twocolumnsection[2]{
  \begin{minipage}[t]{\dimexpr(\linewidth/2) - 3em}
    #1
  \end{minipage}
  \hfill
  \begin{minipage}[t]{\dimexpr(\linewidth/2) - 3em}
    #2
  \end{minipage}
  }

% Define the 'referencees' environment
\newenvironment{referees}{%
}{%
  \hfill
  \bigskip
}

\newcommand*\referee[5]{
  \hspace{1em}
  \begin{minipage}[t]{\dimexpr(\linewidth/3) - 3em}
    \begin{tabular}{>{}l >{}l}
      \multicolumn{2}{l}{\textbf{#1}}\\
      \multicolumn{2}{l}{\emph{#2}, \textsc{#3}}\\
      \quad \mailSymbol & \href{mailto:#4}{#4} \\
      \quad \faPhone & #5 \\
    \end{tabular}
  \end{minipage}%
  }

\newcommand*\refereeMailOnly[4]{
  \hspace{1em}
  \begin{minipage}[t]{\dimexpr(\linewidth/3) - 3em}
    \begin{tabular}{>{}l >{}l}
      \multicolumn{2}{l}{\textbf{#1}}\\
      \multicolumn{2}{l}{\emph{#2}, \textsc{#3}}\\
      \quad \mailSymbol & \href{mailto:#4}{#4} \\
    \end{tabular}
  \end{minipage}%
}

% DS: Extensions
\RequirePackage{academicons}
\RequirePackage{ragged2e}
\RequirePackage{makecell}
\RequirePackage{fontawesome5}
\usepackage{ifthen}
\usepackage[nodisplayskipstretch]{setspace}
\usepackage{mfirstuc}
\usepackage{booktabs}

%\RequirePackage{xparse}
%\RequirePackage{tabularx}
%\RequirePackage{multicol}
%\RequirePackage{extdash}

%Configs
%Prevent unnecessart hyphenation
%\setstretch{1}
%\tolerance=1
\emergencystretch=3em
\hyphenpenalty=10000
%\vbadness=500
%\hbadness=1000

\newcommand\ifemptyelse[3]{\ifthenelse{\equal{#1}{}}{#2}{#3}}
\def \ifempty#1{\def\temp{#1} \ifx\temp\empty}
\renewcommand{\cellalign}{tl}

%Symbols
\newcommand{\skypeSymbol}{\faSkype}
\newcommand{\scholarSymbol}{\hskip1ex\aiGoogleScholar}
\newcommand{\orcidSymbol}{\hskip1ex\aiOrcid}
\newcommand{\rgSymbol}{\hskip1ex\aiResearchGate}

%\def\faSourcetree{{\FontAwesomeBrands\csname faicon@sourcetree\endcsname}}
\newcommand{\ossSymbol}{\faSourcetree}

% Markup
\newcommand{\hltag}[1]{% highlight (or red!10)
  \tikz[baseline]\node[anchor=base,draw=darkGrey!70,fill=darkGrey!20,rounded corners=0.5ex,inner xsep=1ex,inner ysep =0.55ex,text height=1.3ex,text depth=.25ex]{#1};
}

% Links, etc.
\newcommand*{\urlref}[2]{\href{#2}{#1}}
\newcommand*{\oss}[2]{\link{#2}{\ossSymbol #1}}

% Contacts
\newcommand*{\skype}[1]{\sociallink{\skypeSymbol}{skype:#1}{skype:#1}}
%\newcommand*{\scholar}[1]{\sociallink{\scholarSymbol}{https://scholar.google.com/citations?user=#1}{#1}}
%\newcommand*{\orcid}[1]{\sociallink{\orcidSymbol}{https://orcid.org/#1}{#1}}
%\newcommand*{\rg}[1]{\sociallink{\rgSymbol}{https://www.researchgate.net/profile/#1}{#1}}

\newcommand*{\scholar}[2]{\sociallink{\scholarSymbol}{https://scholar.google.com/citations?user=#1}{#2}}
\newcommand*{\scholarlink}[2]{\urlref{#2}{https://scholar.google.com/citations?user=#1}}

\newcommand*{\orcid}[2]{\sociallink{\orcidSymbol}{https://orcid.org/#1}{#2}}
\newcommand*{\orcidlink}[2]{\urlref{#2}{https://orcid.org/#1}}
\newcommand*{\rg}[2]{\sociallink{\rgSymbol}{https://www.researchgate.net/profile/#1}{#2}}
\newcommand*{\rglink}[2]{\urlref{#2}{https://www.researchgate.net/profile/#1}}

% References
\newcommand\refstd{\emph}
\newcommand\reflinked[1]{\hyperlink{#1}{\emph{#1}}}
\newcommand\refint[2]{\hyperlink{#1}{\emph{#2}}}
\newcommand\refuni{\refstd}
\newcommand\refexp{\reflinked}
\newcommand\reffac{\reflinked}
\newcommand\refcol{\reflinked}
\newcommand\refjob{\reflinked}
\newcommand\refproj[1]{\hyperlink{proj:#1}{\emph{#1}}}
\newcommand\refsoft[1]{\hyperlink{soft:#1}{\emph{#1}}}

\newcommand\hlnone[1]{#1}
\newcommand\hlparenthesis[1]{(#1)}
\newcommand\hlbold[1]{\textbf{#1}}
\newcommand\hlemph[1]{\emph{#1}}
\newcommand\hlcolor[1]{\textcolor{headcolor}{#1}}

\newcommand\hltitle{\hlbold}
\newcommand\hljob{\hlbold}
\newcommand\hldegree{\hlnone}
\newcommand\hlsoft{\hlnone}
\newcommand\hlverb{\hlnone}
\newcommand\hlrole{\hlnone}
\newcommand\hltype{\hlparenthesis}
\newcommand\hlproj{\hlnone}

% Dates
\newcommand\since[1]{Since #1}
\newcommand\ivl[2]{#1 -- #2}
\newcommand\at[2]{#1 #2}

%Sizes

%\newlength{\tricolumnlength}
%\setlength{\tricolumnlength}{2cm}
%\newlength{\midcolumnlength}
%\setlength{\midcolumnlength}{\dimexpr(\fulllength-\leftcolumnlength-\tricolumnlength)\relax}

% Running titles
%\newcommand\subtitle[2]{\section{\texorpdfstring{\color{accentcolor}#2\enspace \textsc{#1}}{#1}}}
\newcommand\subtitle[2]{\section{\texorpdfstring{\textsc{#1}}{#1}}}

% Column types
\newcolumntype{C}{>{\raggedright}p{\topleftcolumnlength}}
\newcolumntype{K}{p{\toprightcolumnlength}}

%\newcolumntype{L}{>{\raggedright}p{\leftcolumnlength}}
\newcolumntype{L}{>{\raggedleft}p{\leftcolumnlength}}
\newcolumntype{R}{p{\rightcolumnlength}}


% Lists
%\newenvironment{tricoltable}{\begin{longtable}{L p{\midcolumnlength} p{\tricolumnlength}}}{\end{longtable}}
\newenvironment{categories}{\begin{tabular}{C  K}}{\end{tabular}}
\newenvironment{jobs}{\begin{longtable}{C  K}}{\end{longtable}}
\newenvironment{events}{\begin{longtable}{L | R}}{\end{longtable}}
%\newenvironment{competences}{\begin{itemize}}{\end{itemize}}
\newenvironment{competences}{\begin{tabular}{C  K}}{\end{tabular}}

%\setlength{\arrayrulewidth}{1mm}
 %\makeatletter
%\def\CT@arc#1#2{\ifdim\baselineskip=\z@\noalign\fi{\gdef\CT@arc@{\color#1{#2}}}}\let\CT@arc@\relax
%\def\rulecolor#1#{\CT@arc{#1}}
%\rulecolor{gray!50}

\arrayrulecolor{gray!50}
\newenvironment{complexevents}{%
  \renewcommand{\arraystretch}{1.4}%
  \begin{longtable}{L | R}%
}{%
  \end{longtable}%
 \renewcommand{\arraystretch}{1.0}%
}

\newenvironment{verycomplexevents}{%
  \renewcommand{\arraystretch}{1.4}%
  \begin{longtable}{L | R}%
}{%
  \end{longtable}%
  \renewcommand{\arraystretch}{1.0}%
}

\newcommand\subsectiontitle[1]{%
    \multicolumn{2}{l}{%
	\hspace{\leftcolumnlength}\hspace{1em}\textbf{#1}%
    } \\*\cline{2-2}%
}

\newcommand\eventsection[2]{%
  \ifx #2\empty\else
    \end{#2}%
    \vspace{-1em}%
    \begin{#2}%
  \fi
  \multicolumn{2}{l}{%
    \hspace{\leftcolumnlength}\hspace{1em}\textbf{#1}%
  } \\*\cline{2-2}%
}

\newcommand\datedeventsection[3]{%
  \ifx #3\empty\else
    \end{#3}%
    \vspace{-1em}%
    \begin{#3}%
  \fi%
  \enspace \textbf{#1} & \textbf{#2} \\*\hline
}



% Usage: \category{<name>}{<keywords>}
\newcommand\category[2]{ \textbf{#1} & #2 \\}
%\newcommand\category[2]{ #1 & #2 \\}
%\newcommand\competence[2]{ \item{\textbf{#1}: #2} }
\newcommand\competence[2]{ \textbf{#1} & #2 \\}

% Usage: \event {<dates>}      [<Title>][at]{Details}
\newcommand\event[2]{\enspace #1 & #2\\}

%\newcommand\triplevent[3]{ \enspace #1 & #2 & #3 \\ }
%\newcommand\tripleventsection[2]{ \enspace \underline{\textbf{#1}} & \textbf{#2} & xxx \\ }

% \activity {dates} {name} {long_name} {description} {responsibilities}

\newcommand\titledevent[3]{\event{#1}{\hltitle{#2} #3}}
\newcommand\linkedevent[3]{\event{#1}{\urlref{#2}{#3}}}
\newcommand\job[6]{\noalign{\hypertarget{#2}{}} \event{#1}{\hljob{#3} at\ifempty{#5}\urlref{#4}{#6}\else \urlref{#4}{#6}: #5\fi}}
\newcommand\degree[4]{\noalign{\hypertarget{#2}{}} \event{#1}{\hldegree{#3} #4}}

\newenvironment{projects}{%
  \renewcommand{\arraystretch}{1.0}%
  \begin{longtable}{L | R}%
}{%
  \end{longtable}%
 \renewcommand{\arraystretch}{1.0}%
}

\newcommand\project[3]{\end{projects}\vspace{-1.5em}\begin{projects}\event{\textbf{#1}}{
    \textbf{\makefirstuc{#3}}
}}
\newcommand\action[3]{
    \faAngleRight & #3 \\
}

\newcommand\excofa[5]{\noalign{\hypertarget{#2}{}} \event{#1}{
    \ifempty{#3}\urlref{\hlproj{#2}}{#4}\else\urlref{\hlproj{#2}}{#4}: #3\fi   \ifemptyelse{#5}{}{ \emph{(#5)}}
%\ifemptyelse{#3}{}{: #3}%\ifemptyelse{#5}{}{ \emph{(#5)}}
}}
\newcommand\experiment[5]{\excofa{#1}{#2}{#3}{#4}{#5}} % \emph{(Collaborator)}}}
\newcommand\collaboration[5]{\excofa{#1}{#2}{#3}{#4}{#5}}% \emph{(Collaborator)}}}
\newcommand\facility[5]{\excofa{#1}{#2}{#3}{#4}{#5}}% \emph{(Contributor)}}}

\newcommand\funding[7]{\noalign{\foreach \n in {#4}{\hypertarget{proj:\n}{}}}	\event{#1}{
%\newcommand\funding[7]{\noalign{\ifemptyelse{#7}{}{\foreach \n in {#7}{\hypertarget{XXX}{}}}} \event{#1}{
  \begin{minipage}[t]{\dimexpr(\linewidth)}
    (\hlrole{#5})		 #6 \\ % #7
    \footnotesize{\hltag{#2} \foreach \n in {#3}{\cvtag{\n}}}
  \end{minipage}
}}

\newcommand\leadership[5]{\event{#1}{
  \begin{minipage}[t]{\dimexpr(\linewidth)}
    \hlverb{#2} #3 \\
    #4: \footnotesize{\foreach \n in {#5}{\cvtag{\n}}}
  \end{minipage}
}}

\newcommand\responsibility[3]{\event{#1}{\makefirstuc{#3}}}

\newcommand\software[7]{\noalign{\hypertarget{soft:#2}{}} \event{#1}{
 \begin{minipage}[t]{\dimexpr(\linewidth)}
  \hlsoft{\urlref{#2}{http://#3}}: \ifemptyelse{#7}{#6}{#6 (\emph{#7})}
  \ifemptyelse{#4#3}{}{
    \\ \footnotesize{
        \ifemptyelse{#3}{}{
	    \hltag{\urlref{#3}{http://#3}}
        }
	\foreach \n in {#4}{\cvtag{\hyperlink{\n}{\n}}}
    }
  }
 \end{minipage}
}}

\newcommand\obsolete[7]{\event{#1}{
  \hlsoft{\urlref{#2}{http://#3}}: \ifemptyelse{#7}{#6}{#6 (\emph{#7})}
}}

\newcommand*{\toright}[1]{%
    \nobreak\hfill\penalty50\hskip1em\null\nobreak%
    \hfill #1\parfillskip=0pt \finalhyphendemerits=0 \par}

\newcommand\rnd[5]{\event{#1}{%
  \begin{minipage}[t]{\dimexpr(\linewidth)}%
    \hlverb{#4} #5%
    \footnotesize{\toright{%
     \ifemptyelse{#2}{%
	\foreach \n in {#3}{\hyperlink{\n}{\hltag{\n}}}%
    }{%
	\foreach \n in {#2}{\hyperlink{soft:\n}{\hltag{\n}}}%
    }}}%
  \end{minipage}%
}}

\newcommand\research[5]{\rnd{#1}{#2}{#3}{#4}{#5}}
\newcommand\technology[5]{\rnd{#1}{#2}{#3}{#4}{#5}}

%\newcommand\supervision[3]{\event{#1}{\hlverb{#2} #3}}
%\newcommand\teaching[3]{\event{#1}{\hlverb{#2} #3}}
\newcommand\supervision[3]{\event{#1}{#3}}
\newcommand\teaching[3]{\event{#1}{#3}}

\newcommand\outreach[5]{\event{\footnotesize{#1}}{
% \footnotesize{
  \ifemptyelse{#2}{\hltype{talk}}{%
    \hltype{#2}
  } ``\emph{#3}'' at #4
% }
}}

\newcommand\conference[5]{\outreach{#1}{#2}{#3}{#4}{#5}}
\newcommand\workshop[5]{\outreach{#1}{#2}{#3}{#4}{#5}}
\newcommand\seminar[5]{\outreach{#1}{#2}{#3}{#4}{#5}}

%\NewDocumentCommand{\jobevent}{mmmO{}}{\event{#1}{#2 #3 x}}
%\event{#1}{\textbf{#2} at #3 \IfNoValueTF{}{. #4}}

% Literature
\usepackage[backend=biber,style=ieee,sorting=ydnt,maxnames=1,mincitenames=1,minbibnames=1,minsortnames=1]{biblatex}
%\renewcommand*{\bibfont}{\small}
\renewcommand*{\bibfont}{\footnotesize}
\usepackage{titling}

