{{=<< >>=}}
\documentclass{<<&class>>}
<<#xelatex>>
\usepackage{fontspec}
\usepackage{xunicode}
<</xelatex>>
<<^xelatex>>
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
<</xelatex>>
\usepackage[<<&tex_lang>>]{babel}

\usepackage{fancyhdr}
\usepackage{spverbatim}
\usepackage{booktabs}
\usepackage{graphicx}
<<#initials>> % only if use_initials is set to true
\usepackage{lettrine}
<</initials>>

\usepackage[colorlinks=true,breaklinks=true]{hyperref}

<<^xelatex>>
\usepackage[anythingbreaks]{breakurl}
<</xelatex>>

% TODO: provide a way to configure
\usepackage[a5paper, top=2cm, bottom=1.5cm,
  <<#book>> left=2.5cm,right=1.5cm<</book>><<^book>> left=2cm,right=2cm<</book>>]{geometry}%A5 by default

<<^xelatex>>
% Even with inputenc, not all unicode chars are recognized. This a
% listof some I stumbled upon and manually added to fix
\usepackage{newunicodechar}
\newunicodechar{ }{ } % thin non breaking space
\newunicodechar{°}{$^{\circ}$}
% Force LaTeX not to overflow page e.g. when there is long words
% (e.g. filenames, urls, ...). The result is not necesarily very
% beautiful, though, but at least it's readable.
\setlength\emergencystretch{.5\textwidth}
<</xelatex>>

\makeatletter

\newcommand{\HRule}{
  \paragraph{}
  \begin{center}
    *****
  \end{center}
  \paragraph{}
}

\date{<<&date>>}

% Title
<<#book>>
\renewcommand{\maketitle}{
  \thispagestyle{empty}
  \vspace*{\stretch{1}}
  
  \begin{center}
    {\Huge \@title   \\[5mm]}
  \end{center}
  \vspace*{\stretch{2}}
  
  \newpage
  \thispagestyle{empty}
  
  \pagebreak
  \newpage
  
  \thispagestyle{empty}
  \chapter*{}
  \vspace*{\stretch{1}}
  \begin{center}
    %    {\Huge \@author \\[5mm]}
    {\Huge \@title   \\[5mm]}
    %    {\huge \today   \\[5mm]}    
  \end{center}
  
  %  \HRule
  
  \vspace*{\stretch{2}}
  
  \begin{center}
    {\large \@author}
  \end{center}
  
  
  \vspace*{\stretch{1}}

  
  \vspace*{\stretch{1}}

  \begin{center}
    <<#has_version>>{<<&version>>\\[5mm]}<</has_version>>
    <<#has_date>>\@date<</has_date>>
  \end{center}

  
  \pagebreak
  \newpage
  \thispagestyle{empty}
  \pagebreak
  \newpage
}
<</book>>


% Headers
\pagestyle{fancyplain} 
\lhead[\fancyplain{}{}]{\fancyplain{}{}}
% Right header
\rhead[\fancyplain{}{}]{\fancyplain{}{}}
% Center header
\chead[\fancyplain{}{\rm\thepage}]{\fancyplain{}{\rm\thepage}}
% Footer
\cfoot{\fancyplain{}{}}
\makeatother

\title{<<&title>>}
\author{<<&author>>}

\begin{document}

\maketitle

<<&content>>

\end{document}
