<filename>resources/template.tex<gh_stars>1000+
\documentclass[10pt,openright]{$documentclass$}

\usepackage{geometry}
\usepackage{afterpage}
\usepackage{resources/dtrt}
\geometry{
  papersize={8.125in,10.250in},
  bindingoffset=0.2in,
  top=1.5cm,
  bottom=1.5cm,
  inner=1.91cm,
  outer=6.68cm,
  % For pdf
  left=2.0cm,
  right=2.0cm,
  centering
}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{hyperref}

$if(colorlinks)$
\hypersetup{%
  colorlinks=true,
  linkcolor=blue,
  anchorcolor=blue,
  urlcolor=cyan,
  filecolor=red,
  linkbordercolor=red,
  pdfborderstyle={/S/U/W 1}
  pdfauthor={<NAME>},
  pdfsubject={haskell, computer science, programming, ghc, monads},
  pdftitle={What I Wish I Knew When Learning Haskell},
}
$else$
\hypersetup{%
  colorlinks=false,         % hyperlinks will be black
  linkcolor=black,
  pdfborderstyle={0 0 0},
  pdfauthor={<NAME>},
  pdfsubject={haskell, computer science, programming, ghc, monads},
  pdftitle={What I Wish I Knew When Learning Haskell},
}

\newif\ifprint
\printtrue
\ifprint
  \let\oldhref\href
  \renewcommand\href[2]{%
    \oldhref{#1}{#2}%
    \footnote{\url{#1}}%
  }
\fi
$endif$

\newcommand\blankpage{%
    \null
    \thispagestyle{empty}%
    \addtocounter{page}{-1}%
    \newpage}

\usepackage{amssymb,amsmath}
\usepackage{framed}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{graphicx}

%\frenchspacing

\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE,LO]{\thepage}
\fancyhead[LE,RO]{\leftmark}

\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}

\usepackage{csvsimple}
\usepackage{catchfile}

% Syntax Higlighting
\usepackage{listings}

% Haskell Syntax Highlighting
\usepackage{resources/haskell}

\lstset{
  language=haskell,
  basicstyle=\linespread{0.2}\small\sffamily,
  breaklines=true,
  frame=ltb,
  framerule=0pt,
  xleftmargin=15pt,
  framexleftmargin=16pt,
  framextopmargin=10pt,
  framexbottommargin=10pt,
  stepnumber=1,
  numbers=left,
  numbersep=5pt,
  numberstyle=\ttfamily\tiny\color[gray]{0.3},
  belowcaptionskip=\bigskipamount,
  captionpos=b,
  escapeinside={*'}{'*},
  tabsize=2,
  emphstyle={\bf},
  commentstyle=\it,
  stringstyle=\mdseries\rmfamily,
  showspaces=false,
  keywordstyle=\bfseries\rmfamily,
  columns=fullflexible,
  showstringspaces=false,
  morecomment=[l]\%,
}

\usepackage{etoolbox}
\makeatletter
%\patchcmd{\chapter}{\newpage \newpage}{}{}{}

\usepackage[utf8]{inputenc}
\usepackage{ifxetex,ifluatex}
\usepackage{fontspec}
\setmainfont[Ligatures=Common, ItalicFont={Adobe Garamond Pro Italic}]
    {Adobe Garamond Pro}
\setmonofont[Ligatures=NoCommon, Scale=0.80]{Source Code Pro}

\urlstyle{same}
\usepackage{longtable,booktabs}

\usepackage{graphicx,grffile}
\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
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}

\newenvironment{dedication}
  {\clearpage
   \thispagestyle{empty}
   \vspace*{\stretch{1}}
   \itshape
   \raggedleft
  }
  {\par
   \vspace{\stretch{3}}
   \clearpage
  }

$if(indent)$
$else$
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
$endif$
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(numbersections)$
\setcounter{secnumdepth}{5}
$else$
\setcounter{secnumdepth}{0}
$endif$

$if(subparagraph)$
$else$
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
$endif$

$if(dir)$
\ifxetex
  % load bidi as late as possible as it modifies e.g. graphicx
  $if(latex-dir-rtl)$
  \usepackage[RTLdocument]{bidi}
  $else$
  \usepackage{bidi}
  $endif$
\fi
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \TeXXeTstate=1
  \newcommand{\RL}[1]{\beginR #1\endR}
  \newcommand{\LR}[1]{\beginL #1\endL}
  \newenvironment{RTL}{\beginR}{\endR}
  \newenvironment{LTR}{\beginL}{\endL}
\fi
$endif$

$for(header-includes)$
$header-includes$
$endfor$

\date{$date$}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\input{resources/cover.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\begin{dedication}
%\end{dedication}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\input{resources/copyright.tex}

\newpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

$for(include-before)$
$include-before$

$endfor$
$if(toc)$
{
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$

\newpage
\clearpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

$body$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

$for(include-after)$
$include-after$
$endfor$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\afterpage{\blankpage}
\clearpage
\newpage

\input{resources/back.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
