1% Options for packages loaded elsewhere
2\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
3\PassOptionsToPackage{hyphens}{url}
4$if(colorlinks)$
5\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
6$endif$
7$if(dir)$
8$if(latex-dir-rtl)$
9\PassOptionsToPackage{RTLdocument}{bidi}
10$endif$
11$endif$
12$if(CJKmainfont)$
13\PassOptionsToPackage{space}{xeCJK}
14$endif$
15%
16\documentclass[
17$if(fontsize)$
18  $fontsize$,
19$endif$
20$if(lang)$
21  $babel-lang$,
22$endif$
23$if(papersize)$
24  $papersize$paper,
25$endif$
26$if(beamer)$
27  ignorenonframetext,
28$if(handout)$
29  handout,
30$endif$
31$if(aspectratio)$
32  aspectratio=$aspectratio$,
33$endif$
34$endif$
35$for(classoption)$
36  $classoption$$sep$,
37$endfor$
38]{$documentclass$}
39$if(beamer)$
40$if(background-image)$
41\usebackgroundtemplate{%
42  \includegraphics[width=\paperwidth]{$background-image$}%
43}
44$endif$
45\usepackage{pgfpages}
46\setbeamertemplate{caption}[numbered]
47\setbeamertemplate{caption label separator}{: }
48\setbeamercolor{caption name}{fg=normal text.fg}
49\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$
50$for(beameroption)$
51\setbeameroption{$beameroption$}
52$endfor$
53% Prevent slide breaks in the middle of a paragraph
54\widowpenalties 1 10000
55\raggedbottom
56$if(section-titles)$
57\setbeamertemplate{part page}{
58  \centering
59  \begin{beamercolorbox}[sep=16pt,center]{part title}
60    \usebeamerfont{part title}\insertpart\par
61  \end{beamercolorbox}
62}
63\setbeamertemplate{section page}{
64  \centering
65  \begin{beamercolorbox}[sep=12pt,center]{part title}
66    \usebeamerfont{section title}\insertsection\par
67  \end{beamercolorbox}
68}
69\setbeamertemplate{subsection page}{
70  \centering
71  \begin{beamercolorbox}[sep=8pt,center]{part title}
72    \usebeamerfont{subsection title}\insertsubsection\par
73  \end{beamercolorbox}
74}
75\AtBeginPart{
76  \frame{\partpage}
77}
78\AtBeginSection{
79  \ifbibliography
80  \else
81    \frame{\sectionpage}
82  \fi
83}
84\AtBeginSubsection{
85  \frame{\subsectionpage}
86}
87$endif$
88$endif$
89$if(beamerarticle)$
90\usepackage{beamerarticle} % needs to be loaded first
91$endif$
92\usepackage{amsmath,amssymb}
93$if(fontfamily)$
94\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
95$else$
96\usepackage{lmodern}
97$endif$
98$if(linestretch)$
99\usepackage{setspace}
100$endif$
101\usepackage{iftex}
102\ifPDFTeX
103  \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
104  \usepackage[utf8]{inputenc}
105  \usepackage{textcomp} % provide euro and other symbols
106\else % if luatex or xetex
107$if(mathspec)$
108  \ifXeTeX
109    \usepackage{mathspec}
110  \else
111    \usepackage{unicode-math}
112  \fi
113$else$
114  \usepackage{unicode-math}
115$endif$
116  \defaultfontfeatures{Scale=MatchLowercase}
117  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
118$if(mainfont)$
119  \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
120$endif$
121$if(sansfont)$
122  \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
123$endif$
124$if(monofont)$
125  \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$}
126$endif$
127$for(fontfamilies)$
128  \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}
129$endfor$
130$if(mathfont)$
131$if(mathspec)$
132  \ifXeTeX
133    \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
134  \else
135    \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
136  \fi
137$else$
138  \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
139$endif$
140$endif$
141$if(CJKmainfont)$
142  \ifXeTeX
143    \usepackage{xeCJK}
144    \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
145  \fi
146$endif$
147$if(luatexjapresetoptions)$
148  \ifLuaTeX
149    \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}
150  \fi
151$endif$
152$if(CJKmainfont)$
153  \ifLuaTeX
154    \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}
155    \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
156  \fi
157$endif$
158\fi
159$if(zero-width-non-joiner)$
160%% Support for zero-width non-joiner characters.
161\makeatletter
162\def\zerowidthnonjoiner{%
163  % Prevent ligatures and adjust kerning, but still support hyphenating.
164  \texorpdfstring{%
165    \textormath{\nobreak\discretionary{-}{}{\kern.03em}%
166      \ifvmode\else\nobreak\hskip\z@skip\fi}{}%
167  }{}%
168}
169\makeatother
170\ifPDFTeX
171  \DeclareUnicodeCharacter{200C}{\zerowidthnonjoiner}
172\else
173  \catcode`^^^^200c=\active
174  \protected\def ^^^^200c{\zerowidthnonjoiner}
175\fi
176%% End of ZWNJ support
177$endif$
178$if(beamer)$
179$if(theme)$
180\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}
181$endif$
182$if(colortheme)$
183\usecolortheme{$colortheme$}
184$endif$
185$if(fonttheme)$
186\usefonttheme{$fonttheme$}
187$endif$
188$if(mainfont)$
189\usefonttheme{serif} % use mainfont rather than sansfont for slide text
190$endif$
191$if(innertheme)$
192\useinnertheme{$innertheme$}
193$endif$
194$if(outertheme)$
195\useoutertheme{$outertheme$}
196$endif$
197$endif$
198% Use upquote if available, for straight quotes in verbatim environments
199\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
200\IfFileExists{microtype.sty}{% use microtype if available
201  \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}
202  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
203}{}
204$if(indent)$
205$else$
206\makeatletter
207\@ifundefined{KOMAClassName}{% if non-KOMA class
208  \IfFileExists{parskip.sty}{%
209    \usepackage{parskip}
210  }{% else
211    \setlength{\parindent}{0pt}
212    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
213}{% if KOMA class
214  \KOMAoptions{parskip=half}}
215\makeatother
216$endif$
217$if(verbatim-in-note)$
218\usepackage{fancyvrb}
219$endif$
220\usepackage{xcolor}
221\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
222\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
223\hypersetup{
224$if(title-meta)$
225  pdftitle={$title-meta$},
226$endif$
227$if(author-meta)$
228  pdfauthor={$author-meta$},
229$endif$
230$if(lang)$
231  pdflang={$lang$},
232$endif$
233$if(subject)$
234  pdfsubject={$subject$},
235$endif$
236$if(keywords)$
237  pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
238$endif$
239$if(colorlinks)$
240  colorlinks=true,
241  linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$},
242  filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$},
243  citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$},
244  urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$},
245$else$
246  hidelinks,
247$endif$
248  pdfcreator={LaTeX via pandoc}}
249\urlstyle{same} % disable monospaced font for URLs
250$if(verbatim-in-note)$
251\VerbatimFootnotes % allow verbatim text in footnotes
252$endif$
253$if(geometry)$
254$if(beamer)$
255\geometry{$for(geometry)$$geometry$$sep$,$endfor$}
256$else$
257\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
258$endif$
259$endif$
260$if(beamer)$
261\newif\ifbibliography
262$endif$
263$if(listings)$
264\usepackage{listings}
265\newcommand{\passthrough}[1]{#1}
266\lstset{defaultdialect=[5.3]Lua}
267\lstset{defaultdialect=[x86masm]Assembler}
268$endif$
269$if(lhs)$
270\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
271$endif$
272$if(highlighting-macros)$
273$highlighting-macros$
274$endif$
275$if(tables)$
276\usepackage{longtable,booktabs,array}
277$if(multirow)$
278\usepackage{multirow}
279$endif$
280\usepackage{calc} % for calculating minipage widths
281$if(beamer)$
282\usepackage{caption}
283% Make caption package work with longtable
284\makeatletter
285\def\fnum@table{\tablename~\thetable}
286\makeatother
287$else$
288% Correct order of tables after \paragraph or \subparagraph
289\usepackage{etoolbox}
290\makeatletter
291\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
292\makeatother
293% Allow footnotes in longtable head/foot
294\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
295\makesavenoteenv{longtable}
296$endif$
297$endif$
298$if(graphics)$
299\usepackage{graphicx}
300\makeatletter
301\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
302\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
303\makeatother
304% Scale images if necessary, so that they will not overflow the page
305% margins by default, and it is still possible to overwrite the defaults
306% using explicit options in \includegraphics[width, height, ...]{}
307\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
308% Set default figure placement to htbp
309\makeatletter
310\def\fps@figure{htbp}
311\makeatother
312$endif$
313$if(links-as-notes)$
314% Make links footnotes instead of hotlinks:
315\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}
316$endif$
317$if(strikeout)$
318$-- also used for underline
319\usepackage[normalem]{ulem}
320% Avoid problems with \sout in headers with hyperref
321\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
322$endif$
323\setlength{\emergencystretch}{3em} % prevent overfull lines
324\providecommand{\tightlist}{%
325  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
326$if(numbersections)$
327\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
328$else$
329\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
330$endif$
331$if(beamer)$
332$else$
333$if(block-headings)$
334% Make \paragraph and \subparagraph free-standing
335\ifx\paragraph\undefined\else
336  \let\oldparagraph\paragraph
337  \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
338\fi
339\ifx\subparagraph\undefined\else
340  \let\oldsubparagraph\subparagraph
341  \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
342\fi
343$endif$
344$endif$
345$if(pagestyle)$
346\pagestyle{$pagestyle$}
347$endif$
348$if(csl-refs)$
349\newlength{\cslhangindent}
350\setlength{\cslhangindent}{1.5em}
351\newlength{\csllabelwidth}
352\setlength{\csllabelwidth}{3em}
353\newlength{\cslentryspacingunit} % times entry-spacing
354\setlength{\cslentryspacingunit}{\parskip}
355\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
356 {% don't indent paragraphs
357  \setlength{\parindent}{0pt}
358  % turn on hanging indent if param 1 is 1
359  \ifodd #1
360  \let\oldpar\par
361  \def\par{\hangindent=\cslhangindent\oldpar}
362  \fi
363  % set entry spacing
364  \setlength{\parskip}{#2\cslentryspacingunit}
365 }%
366 {}
367\usepackage{calc}
368\newcommand{\CSLBlock}[1]{#1\hfill\break}
369\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
370\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
371\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
372$endif$
373$for(header-includes)$
374$header-includes$
375$endfor$
376$if(lang)$
377\ifXeTeX
378  % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
379  \usepackage{polyglossia}
380  \setmainlanguage[$for(polyglossia-lang.options)$$polyglossia-lang.options$$sep$,$endfor$]{$polyglossia-lang.name$}
381$for(polyglossia-otherlangs)$
382  \setotherlanguage[$for(polyglossia-otherlangs.options)$$polyglossia-otherlangs.options$$sep$,$endfor$]{$polyglossia-otherlangs.name$}
383$endfor$
384\else
385  \usepackage[$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
386% get rid of language-specific shorthands (see #6817):
387\let\LanguageShortHands\languageshorthands
388\def\languageshorthands#1{}
389$if(babel-newcommands)$
390  $babel-newcommands$
391$endif$
392\fi
393$endif$
394\ifLuaTeX
395  \usepackage{selnolig}  % disable illegal ligatures
396\fi
397$if(dir)$
398\ifXeTeX
399  % Load bidi as late as possible as it modifies e.g. graphicx
400  \usepackage{bidi}
401\fi
402\ifPDFTeX
403  \TeXXeTstate=1
404  \newcommand{\RL}[1]{\beginR #1\endR}
405  \newcommand{\LR}[1]{\beginL #1\endL}
406  \newenvironment{RTL}{\beginR}{\endR}
407  \newenvironment{LTR}{\beginL}{\endL}
408\fi
409$endif$
410$if(natbib)$
411\usepackage[$natbiboptions$]{natbib}
412\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
413$endif$
414$if(biblatex)$
415\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
416$for(bibliography)$
417\addbibresource{$bibliography$}
418$endfor$
419$endif$
420$if(nocite-ids)$
421\nocite{$for(nocite-ids)$$it$$sep$, $endfor$}
422$endif$
423$if(csquotes)$
424\usepackage{csquotes}
425$endif$
426
427$if(title)$
428\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
429$endif$
430$if(subtitle)$
431$if(beamer)$
432$else$
433\usepackage{etoolbox}
434\makeatletter
435\providecommand{\subtitle}[1]{% add subtitle to \maketitle
436  \apptocmd{\@title}{\par {\large #1 \par}}{}{}
437}
438\makeatother
439$endif$
440\subtitle{$subtitle$}
441$endif$
442\author{$for(author)$$author$$sep$ \and $endfor$}
443\date{$date$}
444$if(beamer)$
445$if(institute)$
446\institute{$for(institute)$$institute$$sep$ \and $endfor$}
447$endif$
448$if(titlegraphic)$
449\titlegraphic{\includegraphics{$titlegraphic$}}
450$endif$
451$if(logo)$
452\logo{\includegraphics{$logo$}}
453$endif$
454$endif$
455
456\begin{document}
457$if(has-frontmatter)$
458\frontmatter
459$endif$
460$if(title)$
461$if(beamer)$
462\frame{\titlepage}
463$else$
464\maketitle
465$endif$
466$if(abstract)$
467\begin{abstract}
468$abstract$
469\end{abstract}
470$endif$
471$endif$
472
473$for(include-before)$
474$include-before$
475
476$endfor$
477$if(toc)$
478$if(toc-title)$
479\renewcommand*\contentsname{$toc-title$}
480$endif$
481$if(beamer)$
482\begin{frame}[allowframebreaks]
483$if(toc-title)$
484  \frametitle{$toc-title$}
485$endif$
486  \tableofcontents[hideallsubsections]
487\end{frame}
488$else$
489{
490$if(colorlinks)$
491\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
492$endif$
493\setcounter{tocdepth}{$toc-depth$}
494\tableofcontents
495}
496$endif$
497$endif$
498$if(lof)$
499\listoffigures
500$endif$
501$if(lot)$
502\listoftables
503$endif$
504$if(linestretch)$
505\setstretch{$linestretch$}
506$endif$
507$if(has-frontmatter)$
508\mainmatter
509$endif$
510$body$
511
512$if(has-frontmatter)$
513\backmatter
514$endif$
515$if(natbib)$
516$if(bibliography)$
517$if(biblio-title)$
518$if(has-chapters)$
519\renewcommand\bibname{$biblio-title$}
520$else$
521\renewcommand\refname{$biblio-title$}
522$endif$
523$endif$
524$if(beamer)$
525\begin{frame}[allowframebreaks]{$biblio-title$}
526  \bibliographytrue
527$endif$
528  \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
529$if(beamer)$
530\end{frame}
531$endif$
532
533$endif$
534$endif$
535$if(biblatex)$
536$if(beamer)$
537\begin{frame}[allowframebreaks]{$biblio-title$}
538  \bibliographytrue
539  \printbibliography[heading=none]
540\end{frame}
541$else$
542\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
543$endif$
544
545$endif$
546$for(include-after)$
547$include-after$
548
549$endfor$
550\end{document}
551