template.latex 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
  2. \usepackage{titlesec}
  3. \newcommand{\sectionbreak}{\clearpage}
  4. $if(fontfamily)$
  5. \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
  6. $else$
  7. \usepackage{lmodern}
  8. $endif$
  9. $if(linestretch)$
  10. \usepackage{setspace}
  11. \setstretch{$linestretch$}
  12. $endif$
  13. \usepackage{amssymb,amsmath}
  14. \usepackage{ifxetex,ifluatex}
  15. \usepackage{fixltx2e} % provides \textsubscript
  16. \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  17. \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
  18. \usepackage[utf8]{inputenc}
  19. $if(euro)$
  20. \usepackage{eurosym}
  21. $endif$
  22. \else % if luatex or xelatex
  23. \ifxetex
  24. \usepackage{mathspec}
  25. \else
  26. \usepackage{fontspec}
  27. \fi
  28. \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
  29. $if(euro)$
  30. \newcommand{\euro}{€}
  31. $endif$
  32. $if(mainfont)$
  33. \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
  34. $endif$
  35. $if(sansfont)$
  36. \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
  37. $endif$
  38. $if(monofont)$
  39. \setmonofont[Mapping=tex-ansi$if(monofontoptions)$,$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$endif$]{$monofont$}
  40. $endif$
  41. $if(mathfont)$
  42. \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
  43. $endif$
  44. $if(CJKmainfont)$
  45. \usepackage{xeCJK}
  46. \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
  47. $endif$
  48. \fi
  49. % use upquote if available, for straight quotes in verbatim environments
  50. \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
  51. % use microtype if available
  52. \IfFileExists{microtype.sty}{%
  53. \usepackage{microtype}
  54. \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
  55. }{}
  56. $if(geometry)$
  57. \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
  58. $endif$
  59. \usepackage{hyperref}
  60. $if(colorlinks)$
  61. \PassOptionsToPackage{usenames,dvipsnames}{color} % color is loaded by hyperref
  62. $endif$
  63. \hypersetup{unicode=true,
  64. $if(title-meta)$
  65. pdftitle={$title-meta$},
  66. $endif$
  67. $if(author-meta)$
  68. pdfauthor={$author-meta$},
  69. $endif$
  70. $if(keywords)$
  71. pdfkeywords={$for(keywords)$$keywords$$sep$; $endfor$},
  72. $endif$
  73. $if(colorlinks)$
  74. colorlinks=true,
  75. linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,
  76. citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
  77. urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
  78. $else$
  79. pdfborder={0 0 0},
  80. $endif$
  81. breaklinks=true}
  82. \urlstyle{same} % don't use monospace font for urls
  83. $if(lang)$
  84. \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  85. \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
  86. $if(babel-newcommands)$
  87. $babel-newcommands$
  88. $endif$
  89. \else
  90. \usepackage{polyglossia}
  91. \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
  92. $for(polyglossia-otherlangs)$
  93. \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
  94. $endfor$
  95. \fi
  96. $endif$
  97. $if(natbib)$
  98. \usepackage{natbib}
  99. \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
  100. $endif$
  101. $if(biblatex)$
  102. \usepackage$if(biblio-style)$[style=$biblio-style$]$endif${biblatex}
  103. $if(biblatexoptions)$\ExecuteBibliographyOptions{$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$}$endif$
  104. $for(bibliography)$
  105. \addbibresource{$bibliography$}
  106. $endfor$
  107. $endif$
  108. $if(listings)$
  109. \usepackage{listings}
  110. $endif$
  111. $if(lhs)$
  112. \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
  113. $endif$
  114. $if(highlighting-macros)$
  115. $highlighting-macros$
  116. $endif$
  117. $if(verbatim-in-note)$
  118. \usepackage{fancyvrb}
  119. \VerbatimFootnotes % allows verbatim text in footnotes
  120. $endif$
  121. $if(tables)$
  122. \usepackage{longtable,booktabs}
  123. $endif$
  124. $if(graphics)$
  125. \usepackage{graphicx,grffile}
  126. \makeatletter
  127. \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
  128. \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
  129. \makeatother
  130. % Scale images if necessary, so that they will not overflow the page
  131. % margins by default, and it is still possible to overwrite the defaults
  132. % using explicit options in \includegraphics[width, height, ...]{}
  133. \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
  134. $endif$
  135. $if(links-as-notes)$
  136. % Make links footnotes instead of hotlinks:
  137. \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
  138. $endif$
  139. $if(strikeout)$
  140. \usepackage[normalem]{ulem}
  141. % avoid problems with \sout in headers with hyperref:
  142. \pdfstringdefDisableCommands{\renewcommand{\sout}{}}
  143. $endif$
  144. $if(indent)$
  145. $else$
  146. \IfFileExists{parskip.sty}{%
  147. \usepackage{parskip}
  148. }{% else
  149. \setlength{\parindent}{0pt}
  150. \setlength{\parskip}{6pt plus 2pt minus 1pt}
  151. }
  152. $endif$
  153. \setlength{\emergencystretch}{3em} % prevent overfull lines
  154. \providecommand{\tightlist}{%
  155. \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
  156. $if(numbersections)$
  157. \setcounter{secnumdepth}{5}
  158. $else$
  159. \setcounter{secnumdepth}{0}
  160. $endif$
  161. $if(subparagraph)$
  162. $else$
  163. % Redefines (sub)paragraphs to behave more like sections
  164. \ifx\paragraph\undefined\else
  165. \let\oldparagraph\paragraph
  166. \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
  167. \fi
  168. \ifx\subparagraph\undefined\else
  169. \let\oldsubparagraph\subparagraph
  170. \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
  171. \fi
  172. $endif$
  173. $if(dir)$
  174. \ifxetex
  175. % load bidi as late as possible as it modifies e.g. graphicx
  176. $if(latex-dir-rtl)$
  177. \usepackage[RTLdocument]{bidi}
  178. $else$
  179. \usepackage{bidi}
  180. $endif$
  181. \fi
  182. \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  183. \TeXXeTstate=1
  184. \newcommand{\RL}[1]{\beginR #1\endR}
  185. \newcommand{\LR}[1]{\beginL #1\endL}
  186. \newenvironment{RTL}{\beginR}{\endR}
  187. \newenvironment{LTR}{\beginL}{\endL}
  188. \fi
  189. $endif$
  190. $for(header-includes)$
  191. $header-includes$
  192. $endfor$
  193. $if(title)$
  194. \title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
  195. $endif$
  196. $if(subtitle)$
  197. \providecommand{\subtitle}[1]{}
  198. \subtitle{$subtitle$}
  199. $endif$
  200. $if(author)$
  201. \author{$for(author)$$author$$sep$ \and $endfor$}
  202. $endif$
  203. \date{$date$}
  204. \begin{document}
  205. $if(title)$
  206. \maketitle
  207. $endif$
  208. $if(abstract)$
  209. \begin{abstract}
  210. $abstract$
  211. \end{abstract}
  212. $endif$
  213. $for(include-before)$
  214. $include-before$
  215. $endfor$
  216. $if(toc)$
  217. {
  218. $if(colorlinks)$
  219. \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$}
  220. $endif$
  221. \setcounter{tocdepth}{$toc-depth$}
  222. \tableofcontents
  223. }
  224. $endif$
  225. $if(lot)$
  226. \listoftables
  227. $endif$
  228. $if(lof)$
  229. \listoffigures
  230. $endif$
  231. $body$
  232. $if(natbib)$
  233. $if(bibliography)$
  234. $if(biblio-title)$
  235. $if(book-class)$
  236. \renewcommand\bibname{$biblio-title$}
  237. $else$
  238. \renewcommand\refname{$biblio-title$}
  239. $endif$
  240. $endif$
  241. \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
  242. $endif$
  243. $endif$
  244. $if(biblatex)$
  245. \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
  246. $endif$
  247. $for(include-after)$
  248. $include-after$
  249. $endfor$
  250. \end{document}