% This is a combination of Pandoc templating and LaTeX
% Pandoc templating https://pandoc.org/MANUAL.html#templates
% See the README for help

\thispagestyle{empty}

$if(coverpage-geometry)$
\newgeometry{$for(coverpage-geometry)$$coverpage-geometry$$sep$,$endfor$}
$else$
\newgeometry{top=-100in}
$endif$

% Page color
$if(coverpage-theme.page-html-color)$
\definecolor{pgcolor}{HTML}{$coverpage-theme.page-html-color$}
\pagecolor{pgcolor}\afterpage{\nopagecolor}
$endif$

\newcommand{\coverauthorstyle}[1]{{$if(coverpage-theme.author-fontsize)$\fontsize{$coverpage-theme.author-fontsize$}{$coverpage-theme.author-spacing$}\selectfont
$endif$$for(coverpage-theme.author-fontstyle)$\$coverpage-theme.author-fontstyle${$endfor$$if(coverpage-theme.author-color)$\textcolor{$coverpage-theme.author-color$}$endif${#1}$for(coverpage-theme.author-fontstyle)$}$endfor$}}

\begin{tikzpicture}[remember picture, overlay, inner sep=0pt, outer sep=0pt]

$if(coverpage-bg-image)$
\tikzfading[name=fadeout, inner color=transparent!0,outer color=transparent!100]
\tikzfading[name=fadein, inner color=transparent!100,outer color=transparent!0]
\node[$if(coverpage-theme.bg-image-fading)$ scope fading=$coverpage-theme.bg-image-fading$, $endif$anchor=south west$if(coverpage-theme.bg-image-rotate)$, rotate=$coverpage-theme.bg-image-rotate$$endif$$if(coverpage-theme.bg-image-opacity)$, opacity=$coverpage-theme.bg-image-opacity$$endif$] at ($$(current page.south west)+($if(coverpage-theme.bg-image-left)$$coverpage-theme.bg-image-left$$else$0cm$endif$, $if(coverpage-theme.bg-image-bottom)$$coverpage-theme.bg-image-bottom$$else$0cm$endif$)$$) {
\includegraphics[width=$coverpage-theme.bg-image-size$, keepaspectratio]{$coverpage-bg-image$}};
$endif$

$if(coverpage-style-code.title.plain)$
$if(coverpage-title)$
% Title
\newcommand{\titlelocationleft}{$coverpage-theme.title-left$}
\newcommand{\titlelocationbottom}{$coverpage-theme.title-bottom$}
\newcommand{\titlealign}{$coverpage-theme.title-align$}

\begin{scope}{%
$if(coverpage-theme.title-fontsize)$\fontsize{$coverpage-theme.title-fontsize$}{$coverpage-theme.title-spacing$}\selectfont
$endif$$if(coverpage-theme.title-fontfamily)$\coverpagetitlefont
$endif$\node[anchor=$coverpage-theme.title-anchor$, align=$coverpage-theme.title-align$, rotate=$coverpage-theme.title-rotate$] (Title1) at ($$(current page.south west)+(\titlelocationleft,\titlelocationbottom)$$)  [text width = $coverpage-theme.title-width$$if(coverpage-theme.title-node-spec)$, $coverpage-theme.title-node-spec$$endif$]  {$if(coverpage-theme.title-color)$\textcolor{$coverpage-theme.title-color$}$endif${$for(coverpage-theme.title-fontstyle)$\$coverpage-theme.title-fontstyle${$endfor$\nohyphens{$coverpage-title$}$for(coverpage-theme.title-fontstyle)$}$endfor$}};
}
\end{scope}
$endif$
$endif$
$if(coverpage-style-code.author.plain)$
$if(coverpage-author)$

% Author
\newcommand{\authorlocationleft}{$coverpage-theme.author-left$}
\newcommand{\authorlocationbottom}{$coverpage-theme.author-bottom$}
\newcommand{\authoralign}{$coverpage-theme.author-align$}

\begin{scope}
{%
$if(coverpage-theme.author-fontsize)$\fontsize{$coverpage-theme.author-fontsize$}{$coverpage-theme.author-spacing$}\selectfont
$endif$$if(coverpage-theme.author-fontfamily)$\coverpageauthorfont
$endif$\node[anchor=$coverpage-theme.author-anchor$, align=$coverpage-theme.author-align$, rotate=$coverpage-theme.author-rotate$] (Author1) at ($$(current page.south west)+(\authorlocationleft,\authorlocationbottom)$$)  [text width = $coverpage-theme.author-width$$if(coverpage-theme.author-node-spec)$, $coverpage-theme.author-node-spec$$endif$]  {\coverauthorstyle{$for(coverpage-author)$$coverpage-author$$sep$$coverpage-theme.author-sep$$endfor$\\}};
}
\end{scope}
$endif$
$endif$
$if(coverpage-style-code.header.plain)$
$if(coverpage-header)$

% Header
\newcommand{\headerlocationleft}{$coverpage-theme.header-left$}
\newcommand{\headerlocationbottom}{$coverpage-theme.header-bottom$}
\newcommand{\headerlocationalign}{$coverpage-theme.header-align$}

\begin{scope}
{%
$if(coverpage-theme.header-fontsize)$\fontsize{$coverpage-theme.header-fontsize$}{$coverpage-theme.header-spacing$}\selectfont
$endif$ $if(coverpage-theme.header-fontfamily)$\coverpageheaderfont
$endif$\node[anchor=$coverpage-theme.header-anchor$, align=$coverpage-theme.header-align$, rotate=$coverpage-theme.header-rotate$] (Header1) at %
($$(current page.south west)+(\headerlocationleft,\headerlocationbottom)$$)  [text width = $coverpage-theme.header-width$$if(coverpage-theme.header-node-spec)$, $coverpage-theme.header-node-spec$$endif$]  {$if(coverpage-theme.header-color)$\textcolor{$coverpage-theme.header-color$}$endif${$for(coverpage-theme.header-fontstyle)$\$coverpage-theme.header-fontstyle${$endfor$\nohyphens{$coverpage-header$}$for(coverpage-theme.header-fontstyle)$}$endfor$}};
}
\end{scope}
$endif$
$endif$
$if(coverpage-style-code.footer.plain)$
$if(coverpage-footer)$

% Footer
\newcommand{\footerlocationleft}{$coverpage-theme.footer-left$}
\newcommand{\footerlocationbottom}{$coverpage-theme.footer-bottom$}
\newcommand{\footerlocationalign}{$coverpage-theme.footer-align$}

\begin{scope}
{%
$if(coverpage-theme.footer-fontsize)$\fontsize{$coverpage-theme.footer-fontsize$}{$coverpage-theme.footer-spacing$}\selectfont
$endif$ $if(coverpage-theme.footer-fontfamily)$\coverpagefooterfont
$endif$\node[anchor=$coverpage-theme.footer-anchor$, align=$coverpage-theme.footer-align$, rotate=$coverpage-theme.footer-rotate$] (Footer1) at %
($$(current page.south west)+(\footerlocationleft,\footerlocationbottom)$$)  [text width = $coverpage-theme.footer-width$$if(coverpage-theme.footer-node-spec)$, $coverpage-theme.footer-node-spec$$endif$]  {$if(coverpage-theme.footer-color)$\textcolor{$coverpage-theme.footer-color$}$endif${$for(coverpage-theme.footer-fontstyle)$\$coverpage-theme.footer-fontstyle${$endfor$\nohyphens{$coverpage-footer$}$for(coverpage-theme.footer-fontstyle)$}$endfor$}};
}
\end{scope}
$endif$
$endif$
$if(coverpage-style-code.date.plain)$
$if(coverpage-date)$

% Date
\newcommand{\datelocationleft}{$coverpage-theme.date-left$}
\newcommand{\datelocationbottom}{$coverpage-theme.date-bottom$}
\newcommand{\datelocationalign}{$coverpage-theme.date-align$}

\begin{scope}
{%
$if(coverpage-theme.date-fontsize)$\fontsize{$coverpage-theme.date-fontsize$}{$coverpage-theme.date-spacing$}\selectfont
$endif$ $if(coverpage-theme.date-fontfamily)$\coverpagedatefont
$endif$\node[anchor=$coverpage-theme.date-anchor$, align=$coverpage-theme.date-align$, rotate=$coverpage-theme.date-rotate$] (Date1) at %
($$(current page.south west)+(\datelocationleft,\datelocationbottom)$$)  [text width = $coverpage-theme.date-width$$if(coverpage-theme.date-node-spec)$, $coverpage-theme.date-node-spec$$endif$]  {$if(coverpage-theme.date-color)$\textcolor{$coverpage-theme.date-color$}$endif${$for(coverpage-theme.date-fontstyle)$\$coverpage-theme.date-fontstyle${$endfor$\nohyphens{$coverpage-date$}$for(coverpage-theme.date-fontstyle)$}$endfor$}};
}
\end{scope}
$endif$
$endif$

\end{tikzpicture}
\clearpage
\restoregeometry
