summaryrefslogtreecommitdiff
path: root/template.tex
blob: 2a1641adfb4a131a45d81fe869d52f08c789cd85 (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=0 % 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[hyphens]{url}
  86. \usepackage{hyperxmp}
  87. \ifxetex
  88. \usepackage[setpagesize=false, % page size defined by xetex
  89. unicode=false, % unicode breaks when used with xetex
  90. xetex]{hyperref}
  91. \else
  92. \usepackage[unicode=true]{hyperref}
  93. \fi
  94. \hypersetup{breaklinks=true,
  95. bookmarks=true,
  96. pdfauthor={$author-meta$},
  97. pdftitle={$title-meta$},
  98. colorlinks=true,
  99. citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
  100. urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
  101. linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
  102. pdfborder={0 0 0}}
  103. \urlstyle{same} % don't use monospace font for urls
  104. $if(links-as-notes)$
  105. % Make links footnotes instead of hotlinks:
  106. \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
  107. $endif$
  108. $if(strikeout)$
  109. \usepackage[normalem]{ulem}
  110. % avoid problems with \sout in headers with hyperref:
  111. \pdfstringdefDisableCommands{\renewcommand{\sout}{}}
  112. $endif$
  113. %\setlength{\parindent}{0pt}
  114. %\setlength{\parskip}{6pt plus 2pt minus 1pt}
  115. \setlength{\emergencystretch}{3em} % prevent overfull lines
  116. $if(numbersections)$
  117. \setcounter{secnumdepth}{5}
  118. $else$
  119. \setcounter{secnumdepth}{0}
  120. $endif$
  121. $if(verbatim-in-note)$
  122. \VerbatimFootnotes % allows verbatim text in footnotes
  123. $endif$
  124. $if(lang)$
  125. \ifxetex
  126. \usepackage{polyglossia}
  127. \setmainlanguage[$for(langoption)$$langoption$$sep$,$endfor$]{$lang$}
  128. \else
  129. \usepackage[$lang$]{babel}
  130. \fi
  131. $endif$
  132. $if(title)$
  133. \title{$title$}
  134. $if(subtitle)$
  135. % add subtitle in \maketitle, if not done already by documentclass "paper"
  136. \IfFileExists{xifthen.sty}{%
  137. \usepackage{xifthen}
  138. \ifthenelse{\isnamedefined{subtitle}}{}{%
  139. \def\@subtitle{} \def\subtitle##1{\gdef\@subtitle{##1}}
  140. \IfFileExists{titling.sty}{%
  141. \usepackage{titling}
  142. \posttitle{\par\end{center}} % avoid immediate \vskip
  143. \renewcommand{\maketitlehookb}{%
  144. \begin{center}\Large \@subtitle \par\end{center}\vskip 0.5em}
  145. }{}
  146. }
  147. }{}
  148. \subtitle{$subtitle$}
  149. $endif$
  150. $if(author)$
  151. \author{$for(author)$$author$$sep$ \and $endfor$}
  152. $endif$
  153. $if(date)$
  154. \date{$date$}
  155. $else$
  156. \date{}
  157. $endif$
  158. $endif$
  159. \usepackage[usestackEOL]{stackengine}
  160. $if(isbn)$
  161. \usepackage[ISBN=$isbn$,SC0]{ean13isbn}
  162. $if(isbn-nobarcode)$
  163. \newcommand{\myisbn}{\ISBN}
  164. $else$
  165. \newcommand{\myisbn}{\EANisbn}
  166. $endif$
  167. $else$
  168. \newcommand{\myisbn}
  169. $endif$
  170. $if(coverpage)$
  171. \usepackage[final]{pdfpages}
  172. $endif$
  173. % TODO: avoid hardcoding language options (needed for british with polyglossia)
  174. \usepackage[autostyle,autopunct,parthreshold,english=british,strict]{csquotes}
  175. $for(header-includes)$
  176. $header-includes$
  177. $endfor$
  178. \begin{document}
  179. $if(pagestyle)$ % for documentclass memoir page header/footer styling
  180. \pagestyle{$pagestyle$}
  181. $endif$
  182. $if(headstyles)$ % for documentclass memoir headline styling
  183. \headstyles{$headstyles$}
  184. $endif$
  185. $if(chapterstyle)$ % for documentclass memoir chapter headline styling
  186. \chapterstyle{$chapterstyle$}
  187. $endif$
  188. $if(coverpage)$
  189. \includepdf[pages={1}]{$coverpage$}
  190. $endif$
  191. $if(frontmatter)$
  192. \frontmatter
  193. $endif$
  194. $if(title)$
  195. \maketitle
  196. $endif$
  197. $if(abstract)$
  198. \begin{abstract}
  199. $abstract$
  200. \end{abstract}
  201. $endif$
  202. $for(include-before)$
  203. $include-before$
  204. $endfor$
  205. $if(toc)$
  206. {
  207. \hypersetup{linkcolor=black}
  208. \setcounter{tocdepth}{$toc-depth$}
  209. \tableofcontents
  210. }
  211. $endif$
  212. $if(mainmatter)$
  213. \mainmatter
  214. $endif$
  215. $body$
  216. $if(backmatter)$
  217. \backmatter
  218. $endif$
  219. $if(natbib)$
  220. $if(biblio-files)$
  221. $if(biblio-title)$
  222. $if(book-class)$
  223. \renewcommand\bibname{$biblio-title$}
  224. $else$
  225. \renewcommand\refname{$biblio-title$}
  226. $endif$
  227. $endif$
  228. \bibliography{$biblio-files$}
  229. $endif$
  230. $endif$
  231. $if(biblatex)$
  232. \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
  233. $endif$
  234. $for(include-after)$
  235. $include-after$
  236. $endfor$
  237. \end{document}