summaryrefslogtreecommitdiff
path: root/template.tex
blob: e1ede4f3eedce34f0730189a4b391823ba875819 (plain)
  1. \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
  2. $if(fontfamily)$
  3. \usepackage{$fontfamily$}
  4. $else$
  5. \usepackage{lmodern}
  6. $endif$
  7. $if(linestretch)$
  8. \usepackage{setspace}
  9. \setstretch{$linestretch$}
  10. $endif$
  11. \usepackage{amssymb,amsmath}
  12. \usepackage{ifxetex,ifluatex}
  13. \usepackage{fixltx2e% provides \textsubscript
  14. \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=% if pdftex
  15.   \usepackage[T1]{fontenc}
  16.   \usepackage[utf8]{inputenc}
  17. $if(euro)$
  18.   \usepackage{eurosym}
  19. $endif$
  20. \else % if luatex or xelatex
  21.   \ifxetex
  22.     \usepackage{mathspec}
  23.     \usepackage{xltxtra,xunicode}
  24.   \else
  25.     \usepackage{fontspec}
  26.   \fi
  27.   \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  28.   \newcommand{\euro}{}
  29. $if(mainfont)$
  30.     \setmainfont{$mainfont$}
  31. $endif$
  32. $if(sansfont)$
  33.     \setsansfont{$sansfont$}
  34. $endif$
  35. $if(monofont)$
  36.     \setmonofont[Mapping=tex-ansi]{$monofont$}
  37. $endif$
  38. $if(mathfont)$
  39.     \setmathfont(Digits,Latin,Greek){$mathfont$}
  40. $endif$
  41. \fi
  42. % use upquote if available, for straight quotes in verbatim environments
  43. \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
  44. % use microtype if available
  45. \IfFileExists{microtype.sty}{\usepackage{microtype}}{}
  46. $if(geometry)$
  47. \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
  48. $endif$
  49. $if(natbib)$
  50. \usepackage{natbib}
  51. \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
  52. $endif$
  53. $if(biblatex)$
  54. \usepackage{biblatex}
  55. $if(biblio-files)$
  56. \bibliography{$biblio-files$}
  57. $endif$
  58. $endif$
  59. $if(listings)$
  60. \usepackage{listings}
  61. $endif$
  62. $if(lhs)$
  63. \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
  64. $endif$
  65. $if(highlighting-macros)$
  66. $highlighting-macros$
  67. $endif$
  68. $if(verbatim-in-note)$
  69. \usepackage{fancyvrb}
  70. $endif$
  71. $if(tables)$
  72. \usepackage{longtable,booktabs}
  73. $endif$
  74. $if(graphics)$
  75. \usepackage{graphicx}
  76. \makeatletter
  77. \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
  78. \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
  79. \makeatother
  80. % Scale images if necessary, so that they will not overflow the page
  81. % margins by default, and it is still possible to overwrite the defaults
  82. % using explicit options in \includegraphics[width, height, ...]{}
  83. \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
  84. $endif$
  85. \usepackage{hyperxmp}
  86. \ifxetex
  87.   \usepackage[setpagesize=false, % page size defined by xetex
  88.               unicode=false, % unicode breaks when used with xetex
  89.               xetex]{hyperref}
  90. \else
  91.   \usepackage[unicode=true]{hyperref}
  92. \fi
  93. \hypersetup{breaklinks=true,
  94.             bookmarks=true,
  95.             pdfauthor={$author-meta$},
  96.             pdftitle={$title-meta$},
  97.             colorlinks=true,
  98.             citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
  99.             urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
  100.             linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
  101.             pdfborder={0 0 0}}
  102. \urlstyle{same}  % don't use monospace font for urls
  103. $if(links-as-notes)$
  104. % Make links footnotes instead of hotlinks:
  105. \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
  106. $endif$
  107. $if(strikeout)$
  108. \usepackage[normalem]{ulem}
  109. % avoid problems with \sout in headers with hyperref:
  110. \pdfstringdefDisableCommands{\renewcommand{\sout}{}}
  111. $endif$
  112. %\setlength{\parindent}{0pt}
  113. %\setlength{\parskip}{6pt plus 2pt minus 1pt}
  114. \setlength{\emergencystretch}{3em}  % prevent overfull lines
  115. $if(numbersections)$
  116. \setcounter{secnumdepth}{5}
  117. $else$
  118. \setcounter{secnumdepth}{0}
  119. $endif$
  120. $if(verbatim-in-note)$
  121. \VerbatimFootnotes % allows verbatim text in footnotes
  122. $endif$
  123. $if(lang)$
  124. \ifxetex
  125.   \usepackage{polyglossia}
  126.   \setmainlanguage[$for(langoption)$$langoption$$sep$,$endfor$]{$lang$}
  127. \else
  128.   \usepackage[$lang$]{babel}
  129. \fi
  130. $endif$
  131. $if(title)$
  132. \title{$title$}
  133. $if(subtitle)$
  134. % add subtitle in \maketitle, if not done already by documentclass "paper"
  135. \IfFileExists{xifthen.sty}{%
  136.   \usepackage{xifthen}
  137.   \ifthenelse{\isnamedefined{subtitle}}{}{%
  138.     \def\@subtitle{} \def\subtitle##1{\gdef\@subtitle{##1}}
  139.     \IfFileExists{titling.sty}{%
  140.       \usepackage{titling}
  141.       \posttitle{\par\end{center}} % avoid immediate \vskip
  142.       \renewcommand{\maketitlehookb}{%
  143.         \begin{center}\Large \@subtitle \par\end{center}\vskip 0.5em}
  144.       }{}
  145.     }
  146.   }{}
  147. \subtitle{$subtitle$}
  148. $endif$
  149. $if(author)$
  150. \author{$for(author)$$author$$sep$ \and $endfor$}
  151. $endif$
  152. $if(date)$
  153. \date{$date$}
  154. $else$
  155. \date{}
  156. $endif$
  157. $endif$
  158. \usepackage[usestackEOL]{stackengine}
  159. $if(isbn)$
  160.   \usepackage[ISBN=$isbn$,SC0]{ean13isbn}
  161. $else$
  162.   \newcommand{\EANisbn}
  163. $endif$
  164. $if(coverpage)$
  165. \usepackage[final]{pdfpages}
  166. $endif$
  167. % TODO: avoid hardcoding language options (needed for british with polyglossia)
  168. \usepackage[autostyle,autopunct,parthreshold,english=british,strict]{csquotes}
  169. $for(header-includes)$
  170. $header-includes$
  171. $endfor$
  172. \begin{document}
  173. $if(pagestyle)$ % for documentclass memoir page header/footer styling
  174. \pagestyle{$pagestyle$}
  175. $endif$
  176. $if(headstyles)$ % for documentclass memoir headline styling
  177. \headstyles{$headstyles$}
  178. $endif$
  179. $if(chapterstyle)$ % for documentclass memoir chapter headline styling
  180. \chapterstyle{$chapterstyle$}
  181. $endif$
  182. $if(coverpage)$
  183. \includepdf[pages={1}]{$coverpage$}
  184. $endif$
  185. $if(frontmatter)$
  186. \frontmatter
  187. $endif$
  188. $if(title)$
  189. \maketitle
  190. $endif$
  191. $if(abstract)$
  192. \begin{abstract}
  193. $abstract$
  194. \end{abstract}
  195. $endif$
  196. $for(include-before)$
  197. $include-before$
  198. $endfor$
  199. $if(toc)$
  200. {
  201. \hypersetup{linkcolor=black}
  202. \setcounter{tocdepth}{$toc-depth$}
  203. \tableofcontents
  204. }
  205. $endif$
  206. $if(mainmatter)$
  207. \mainmatter
  208. $endif$
  209. $body$
  210. $if(backmatter)$
  211. \backmatter
  212. $endif$
  213. $if(natbib)$
  214. $if(biblio-files)$
  215. $if(biblio-title)$
  216. $if(book-class)$
  217. \renewcommand\bibname{$biblio-title$}
  218. $else$
  219. \renewcommand\refname{$biblio-title$}
  220. $endif$
  221. $endif$
  222. \bibliography{$biblio-files$}
  223. $endif$
  224. $endif$
  225. $if(biblatex)$
  226. \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
  227. $endif$
  228. $for(include-after)$
  229. $include-after$
  230. $endfor$
  231. \end{document}