%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[$fontsize$, a4paper]{article}
\usepackage{fontspec}

% LAYOUT
%--------------------------------
\usepackage{geometry}
\geometry{$geometry$}

% Trim excessive whitespace before lists
\usepackage{enumitem}
\setlist{nolistsep}

% LANGUAGE
%--------------------------------
$if(lang)$
\usepackage{polyglossia}
\setmainlanguage{$lang$}
$endif$

% TYPOGRAPHY
%--------------------------------
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage[protrusion=true,final]{microtype}

% converts LaTeX specials (quotes, dashes etc.) to Unicode
\defaultfontfeatures{Mapping=tex-text}
\setromanfont [Ligatures={Common}, Numbers={OldStyle}]{$mainfont$}
\setsansfont[Scale=0.9]{$altfont$}
\setmonofont[Scale=0.8]{$monofont$}

% Set paragraph break
\setlength{\parskip}{$parskip$}
\setlength{\parindent}{$parindent$}

% Custom ampersand
\newcommand{\amper}{{\fontspec[Scale=.95]{$mainfont$}\selectfont\itshape\&}}

$if(mainfont)$
    \setmainfont{$mainfont$}
$endif$
$if(altfont)$
    \setsansfont{$altfont$}
$endif$

% Spacing after section headers
\usepackage{titlesec}
\titlespacing{\section}{0pt}{\parskip}{$secspacingdiff$}

% Multi-column support
$if(multicol)$
\usepackage{multicol}
\setlength{\columnsep}{$columnsep$}
$endif$

% Header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{$author_name$, $author_id$}

% Move up title block
\usepackage{titling}
\setlength{\droptitle}{-6ex}

% Command required by how Pandoc handles the list conversion
\providecommand{\tightlist}{
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

% Section headings
% \addtokomafont{section}{\rmfamily\centering\scshape}
\titlelabel{\thetitle.\enskip}


% PDF SETUP
%--------------------------------
\usepackage[xetex, bookmarks, colorlinks, breaklinks]{hyperref}
\hypersetup
{
  pdfauthor={$author$},
  pdfsubject={$course$},
  pdftitle={$course$ - Handin $handinnumber$},
  colorlinks,breaklinks,
  filecolor=black,
  urlcolor=[rgb]{0.117,0.682,0.858},
  linkcolor=[rgb]{0.117,0.682,0.858},
  linkcolor=[rgb]{0.117,0.682,0.858},
  citecolor=[rgb]{0.117,0.682,0.858}
}

% To display custom date in the example
$if(customdate)$
\usepackage[$lang$]{datetime2}
\DTMsavedate{customdate}{$customdate$}
$endif$

% DOCUMENT
%--------------------------------
\begin{document}

\title{$course$\\
Hand-in $handinnumber$\vspace{-2ex}
}
\author{$author_name$, $author_group$, $author_id$}
\date{\vspace{-2ex}
\today}
\maketitle

$if(multicol)$
\begin{multicols}{$columns$}
$endif$

$body$

$if(multicol)$
\end{multicols}
$endif$

\end{document}
