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

\documentclass[$classoptions$]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newpxtext,newpxmath}
%\usepackage{palatino}
%\usepackage{eulervm}
%\usepackage{libertine}
%\usepackage[libertine]{newtxmath}
% \usepackage{ebgaramond}


% Memoir
%--------------------------------
\pagestyle{ruled}
% \renewcommand*{\chaptitlefont}{\scshape}
\setsecnumdepth{subsection}
\chapterstyle{article}


%% Sans-serif overskrifter
%% % til kapiteloverskrifter
%% \renewcommand\chapnamefont{\Large\bfseries\sffamily}
%% \renewcommand\chapnumfont{\chapnamefont}
%% \renewcommand\chaptitlefont{\Large\bfseries\sffamily\raggedright}
%% % til afsnitsoverskrifter
%% \setsecheadstyle{\Large\bfseries\sffamily\raggedright}
%% \setsubsecheadstyle{\large\bfseries\sffamily\raggedright}
%% \setsubsubsecheadstyle{\normalsize\bfseries\sffamily\raggedright}


\raggedbottomsectiontrue

% Typesetting
%--------------------------------
\usepackage[protrusion=true,final]{microtype} % Does this do anything?
\linespread{1.040}

\usepackage[english]{babel}
\usepackage{listings} % Has to come after babel package
                      % due to LaTeX being LaTeX…

% XeTeX
%--------------------------------
%% \usepackage{xunicode}
%% \usepackage{xltxtra}
%% \usepackage{fontspec}
%% \setmainfont[Mapping=tex-text]{TeX Gyre Pagella}
%%
%% $if(lang)$
%% \usepackage{polyglossia}
%% \setmainlanguage{$lang$}
%% $endif$
%%
%% % converts LaTeX specials (quotes, dashes etc.) to Unicode
%% \defaultfontfeatures{Mapping=tex-text}
%% \setromanfont[Ligatures={Common}]{$mainfont$}
%% \setsansfont[Scale=1]{$altfont$}
%% \setmonofont[Scale=0.8]{$monofont$}
%%
%% % Custom ampersand
%% \newcommand{\amper}{{\fontspec[Scale=.95]{$mainfont$}\selectfont\itshape\&}}
%%
%% $if(mainfont)$
%%     \setmainfont{$mainfont$}
%% $endif$
%% $if(altfont)$
%%     \setsansfont{$altfont$}
%% $endif$


% Packages
%--------------------------------
\usepackage{lastpage} % What does this do?
\usepackage{amsmath}

%%    ~ornaments~                 %%
%\usepackage{pgfornament}

%% SI Units and proper alignment  %%
%%  in tables                     %%
%\usepackage{siunitx}
%\sisetup{detect-all}

% Paragraph spacing
%--------------------------------
%% \setlength{\parskip}{1em}
%% \setlength{\parindent}{0pt}

% Fix figure/table floats in place
%----------------------------------
\usepackage{float}
\let\origfigure=\figure
\let\endorigfigure=\endfigure
\renewenvironment{figure}[1][]{%
  \origfigure[H]
}{%
  \endorigfigure
}
\let\origtable=\table
\let\endorigtable=\endtable
\renewenvironment{table}[1][]{%
  \origtable[H]
}{%
  \endorigtable
}


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

% Spacing after section headers
%-------------------------------
%% \RedeclareSectionCommand[
%%   beforeskip=-\baselineskip,
%%   afterskip=.1\baselineskip]{section}
%% \RedeclareSectionCommand[
%%   beforeskip=-.75\baselineskip,
%%   afterskip=.1\baselineskip]{subsection}
%% \RedeclareSectionCommand[
%%   beforeskip=-.5\baselineskip,
%%   afterskip=.1\baselineskip]{subsubsection}
%% \RedeclareSectionCommand[
%%   beforeskip=.5\baselineskip,
%%   afterskip=-1em]{paragraph}
%% \RedeclareSectionCommand[
%%   beforeskip=-.5\baselineskip,
%%   afterskip=-1em]{subparagraph}

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

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

% Display custom date
%---------------------------------------
$if(customdate)$
\usepackage[$lang$]{datetime2}
\DTMsavedate{customdate}{$customdate$}
$endif$


% Title and author
%--------------------------------
\title{$course$\\$title$$if(subtitle)$\\$subtitle$$endif$}
\author{\vspace{-1ex}
  $for(author)$$author$$sep$\and $endfor$
}
\date{\vspace{-1ex}
  \today
}


% DOCUMENT
%--------------------------------

\begin{document}
\mainmatter
\maketitle

$body$

\end{document}
