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

% -----------------
% START OF PREAMBLE
% -----------------
\documentclass[12pt,a4paper]{scrartcl}


% Commands
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}


% Packages
\usepackage{fontspec}
\usepackage{eurosym}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{upquote}
\usepackage{microtype}
\usepackage{longtable,booktabs}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage[normalem]{ulem}
\usepackage{fancyhdr}
\usepackage[setpagesize=false,
            unicode=false,
            colorlinks=true,
            urlcolor=blue,
            linkcolor=black]{hyperref}


% Required fix for fancyhdr
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
% Fancy headers and footers settings
\pagestyle{fancy}
\lhead{$left-header$}
\rhead{$right-header$}


% Required for syntax highlighting
$highlighting-macros$


% Don't let images overflow the page
% Can still explicit set width/height/options for an image
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}


% Make links footnotes instead of hotlinks
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}


% Avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}


% No paragraph indentation
% and set space between paragraphs
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines


% No section numbering
\makeatletter
\def\@seccntformat#1{%
  \expandafter\ifx\csname c@#1\endcsname\c@section\else
  \csname the#1\endcsname\quad
  \fi}
\makeatother


% -----------------
%  END OF PREAMBLE
% -----------------
\begin{document}

\begin{center}
  \hfill \break%
  $if(title)$\Huge{$title$}\\[0.5em]$endif$
  $if(authors)$\Large{$authors$}\\[2.5em]$endif$
\end{center}

$body$

\end{document}
