aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-09-25 19:07:43 -0700
committerJohn MacFarlane <[email protected]>2024-09-29 14:18:31 -0700
commit2a6268de67b883cd814358111d764d330f100d9b (patch)
tree850c5717d198ec99484542b863ea9a676877e4cb
parent7565a90cec79c5fcd1d3b3e5ddb042d2cdaccac3 (diff)
Refactor latex template using partials.
+ Split out common parts of latex template into partials: common.latex, fonts.latex, font-settings.latex, passoptions.latex, hypersetup.latex, after-header-includes.latex. + Split out old latex template into default.latex and default.beamer. + Make default.beamer the default template for beamer.
-rw-r--r--data/templates/after-header-includes.latex10
-rw-r--r--data/templates/common.latex273
-rw-r--r--data/templates/default.beamer191
-rw-r--r--data/templates/default.latex552
-rw-r--r--data/templates/font-settings.latex103
-rw-r--r--data/templates/fonts.latex27
-rw-r--r--data/templates/hypersetup.latex30
-rw-r--r--data/templates/passoptions.latex9
-rw-r--r--pandoc.cabal8
-rw-r--r--src/Text/Pandoc/Templates.hs1
-rw-r--r--test/command/9472.md11
-rw-r--r--test/writer.latex3
-rw-r--r--test/writers-lang-and-dir.latex11
13 files changed, 669 insertions, 560 deletions
diff --git a/data/templates/after-header-includes.latex b/data/templates/after-header-includes.latex
new file mode 100644
index 000000000..2c59e8718
--- /dev/null
+++ b/data/templates/after-header-includes.latex
@@ -0,0 +1,10 @@
+\usepackage{bookmark}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{$if(urlstyle)$$urlstyle$$else$same$endif$}
+$if(links-as-notes)$
+% Make links footnotes instead of hotlinks:
+\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}
+$endif$
+$if(verbatim-in-note)$
+\VerbatimFootnotes % allow verbatim text in footnotes
+$endif$
diff --git a/data/templates/common.latex b/data/templates/common.latex
new file mode 100644
index 000000000..4c3fc0935
--- /dev/null
+++ b/data/templates/common.latex
@@ -0,0 +1,273 @@
+$--
+$-- paragraph formatting
+$--
+$if(indent)$
+$else$
+\makeatletter
+\@ifundefined{KOMAClassName}{% if non-KOMA class
+ \IfFileExists{parskip.sty}{%
+ \usepackage{parskip}
+ }{% else
+ \setlength{\parindent}{0pt}
+ \setlength{\parskip}{6pt plus 2pt minus 1pt}}
+}{% if KOMA class
+ \KOMAoptions{parskip=half}}
+\makeatother
+$endif$
+$if(beamer)$
+$else$
+$if(block-headings)$
+% Make \paragraph and \subparagraph free-standing
+\makeatletter
+\ifx\paragraph\undefined\else
+ \let\oldparagraph\paragraph
+ \renewcommand{\paragraph}{
+ \@ifstar
+ \xxxParagraphStar
+ \xxxParagraphNoStar
+ }
+ \newcommand{\xxxParagraphStar}[1]{\oldparagraph*{#1}\mbox{}}
+ \newcommand{\xxxParagraphNoStar}[1]{\oldparagraph{#1}\mbox{}}
+\fi
+\ifx\subparagraph\undefined\else
+ \let\oldsubparagraph\subparagraph
+ \renewcommand{\subparagraph}{
+ \@ifstar
+ \xxxSubParagraphStar
+ \xxxSubParagraphNoStar
+ }
+ \newcommand{\xxxSubParagraphStar}[1]{\oldsubparagraph*{#1}\mbox{}}
+ \newcommand{\xxxSubParagraphNoStar}[1]{\oldsubparagraph{#1}\mbox{}}
+\fi
+\makeatother
+$endif$
+$endif$
+$--
+$-- verbatim in notes
+$--
+$if(verbatim-in-note)$
+\usepackage{fancyvrb}
+$endif$
+$-- highlighting
+$if(listings)$
+\usepackage{listings}
+\newcommand{\passthrough}[1]{#1}
+\lstset{defaultdialect=[5.3]Lua}
+\lstset{defaultdialect=[x86masm]Assembler}
+$endif$
+$if(lhs)$
+\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
+$endif$
+$if(highlighting-macros)$
+$highlighting-macros$
+$endif$
+$--
+$-- tables
+$--
+$if(tables)$
+\usepackage{longtable,booktabs,array}
+$if(multirow)$
+\usepackage{multirow}
+$endif$
+\usepackage{calc} % for calculating minipage widths
+$if(beamer)$
+\usepackage{caption}
+% Make caption package work with longtable
+\makeatletter
+\def\fnum@table{\tablename~\thetable}
+\makeatother
+$else$
+% Correct order of tables after \paragraph or \subparagraph
+\usepackage{etoolbox}
+\makeatletter
+\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
+\makeatother
+% Allow footnotes in longtable head/foot
+\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
+\makesavenoteenv{longtable}
+$endif$
+$endif$
+$--
+$-- graphics
+$--
+$if(graphics)$
+\usepackage{graphicx}
+\makeatletter
+\newsavebox\pandoc@box
+\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
+ \sbox\pandoc@box{#1}%
+ \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
+ \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
+ \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
+ \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
+ \else\usebox{\pandoc@box}%
+ \fi%
+}
+% Set default figure placement to htbp
+\def\fps@figure{htbp}
+\makeatother
+$endif$
+$if(svg)$
+\usepackage{svg}
+$endif$
+$--
+$-- strikeout/underline
+$--
+$if(strikeout)$
+\ifLuaTeX
+ \usepackage{luacolor}
+ \usepackage[soul]{lua-ul}
+\else
+ \usepackage{soul}
+$if(beamer)$
+ \makeatletter
+ \let\HL\hl
+ \renewcommand\hl{% fix for beamer highlighting
+ \let\set@color\beamerorig@set@color
+ \let\reset@color\beamerorig@reset@color
+ \HL}
+ \makeatother
+$endif$
+$if(CJKmainfont)$
+ \ifXeTeX
+ % soul's \st doesn't work for CJK:
+ \usepackage{xeCJKfntef}
+ \renewcommand{\st}[1]{\sout{#1}}
+ \fi
+$endif$
+\fi
+$endif$
+$--
+$-- CSL citations
+$--
+$if(csl-refs)$
+% definitions for citeproc citations
+\NewDocumentCommand\citeproctext{}{}
+\NewDocumentCommand\citeproc{mm}{%
+ \begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
+\makeatletter
+ % allow citations to break across lines
+ \let\@cite@ofmt\@firstofone
+ % avoid brackets around text for \cite:
+ \def\@biblabel#1{}
+ \def\@cite#1#2{{#1\if@tempswa , #2\fi}}
+\makeatother
+\newlength{\cslhangindent}
+\setlength{\cslhangindent}{1.5em}
+\newlength{\csllabelwidth}
+\setlength{\csllabelwidth}{3em}
+\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing
+ {\begin{list}{}{%
+ \setlength{\itemindent}{0pt}
+ \setlength{\leftmargin}{0pt}
+ \setlength{\parsep}{0pt}
+ % turn on hanging indent if param 1 is 1
+ \ifodd #1
+ \setlength{\leftmargin}{\cslhangindent}
+ \setlength{\itemindent}{-1\cslhangindent}
+ \fi
+ % set entry spacing
+ \setlength{\itemsep}{#2\baselineskip}}}
+ {\end{list}}
+\usepackage{calc}
+\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
+\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
+\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
+\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
+$endif$
+$--
+$-- Babel language support
+$--
+$if(lang)$
+\ifLuaTeX
+\usepackage[bidi=basic]{babel}
+\else
+\usepackage[bidi=default]{babel}
+\fi
+$if(babel-lang)$
+\babelprovide[main,import]{$babel-lang$}
+$if(mainfont)$
+\ifPDFTeX
+\else
+\babelfont{rm}[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$$if(mainfontfallback)$,RawFeature={fallback=mainfontfallback}$endif$]{$mainfont$}
+\fi
+$endif$
+$endif$
+$for(babel-otherlangs)$
+\babelprovide[import]{$babel-otherlangs$}
+$endfor$
+$for(babelfonts/pairs)$
+\babelfont[$babelfonts.key$]{rm}{$babelfonts.value$}
+$endfor$
+% get rid of language-specific shorthands (see #6817):
+\let\LanguageShortHands\languageshorthands
+\def\languageshorthands#1{}
+$if(selnolig-langs)$
+\ifLuaTeX
+ \usepackage[$for(selnolig-langs)$$it$$sep$,$endfor$]{selnolig} % disable illegal ligatures
+\fi
+$endif$
+$endif$
+$--
+$-- pagestyle
+$--
+$if(pagestyle)$
+\pagestyle{$pagestyle$}
+$endif$
+$--
+$-- prevent overfull lines
+$--
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+$--
+$-- tight lists
+$--
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+$--
+$-- section numbering
+$--
+$if(numbersections)$
+\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
+$else$
+\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
+$endif$
+$--
+$-- subfigure support
+$--
+$if(subfigure)$
+\usepackage{subcaption}
+$endif$
+$--
+$-- text direction support for pdftex
+$--
+$if(dir)$
+\ifPDFTeX
+ \TeXXeTstate=1
+ \newcommand{\RL}[1]{\beginR #1\endR}
+ \newcommand{\LR}[1]{\beginL #1\endL}
+ \newenvironment{RTL}{\beginR}{\endR}
+ \newenvironment{LTR}{\beginL}{\endL}
+\fi
+$endif$
+$--
+$-- bibliography support support for natbib and biblatex
+$--
+$if(natbib)$
+\usepackage[$natbiboptions$]{natbib}
+\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
+$endif$
+$if(biblatex)$
+\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
+$for(bibliography)$
+\addbibresource{$bibliography$}
+$endfor$
+$endif$
+$if(nocite-ids)$
+\nocite{$for(nocite-ids)$$it$$sep$, $endfor$}
+$endif$
+$--
+$-- csquotes
+$--
+$if(csquotes)$
+\usepackage{csquotes}
+$endif$
diff --git a/data/templates/default.beamer b/data/templates/default.beamer
new file mode 100644
index 000000000..a3fada27e
--- /dev/null
+++ b/data/templates/default.beamer
@@ -0,0 +1,191 @@
+$passoptions.latex()$
+\documentclass[
+$if(fontsize)$
+ $fontsize$,
+$endif$
+ ignorenonframetext,
+$if(handout)$
+ handout,
+$endif$
+$if(aspectratio)$
+ aspectratio=$aspectratio$,
+$endif$
+$if(babel-lang)$
+ $babel-lang$,
+$endif$
+$for(classoption)$
+ $classoption$$sep$,
+$endfor$
+]{$documentclass$}
+$if(geometry)$
+\geometry{$for(geometry)$$geometry$$sep$,$endfor$}
+$endif$
+\newif\ifbibliography
+$if(background-image)$
+\usebackgroundtemplate{%
+ \includegraphics[width=\paperwidth]{$background-image$}%
+}
+% In beamer background-image does not work well when other images are used, so this is the workaround
+\pgfdeclareimage[width=\paperwidth,height=\paperheight]{background}{$background-image$}
+\usebackgroundtemplate{\pgfuseimage{background}}
+$endif$
+\usepackage{pgfpages}
+\setbeamertemplate{caption}[numbered]
+\setbeamertemplate{caption label separator}{: }
+\setbeamercolor{caption name}{fg=normal text.fg}
+\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$
+$for(beameroption)$
+\setbeameroption{$beameroption$}
+$endfor$
+% Prevent slide breaks in the middle of a paragraph
+\widowpenalties 1 10000
+\raggedbottom
+$if(section-titles)$
+\setbeamertemplate{part page}{
+ \centering
+ \begin{beamercolorbox}[sep=16pt,center]{part title}
+ \usebeamerfont{part title}\insertpart\par
+ \end{beamercolorbox}
+}
+\setbeamertemplate{section page}{
+ \centering
+ \begin{beamercolorbox}[sep=12pt,center]{section title}
+ \usebeamerfont{section title}\insertsection\par
+ \end{beamercolorbox}
+}
+\setbeamertemplate{subsection page}{
+ \centering
+ \begin{beamercolorbox}[sep=8pt,center]{subsection title}
+ \usebeamerfont{subsection title}\insertsubsection\par
+ \end{beamercolorbox}
+}
+\AtBeginPart{
+ \frame{\partpage}
+}
+\AtBeginSection{
+ \ifbibliography
+ \else
+ \frame{\sectionpage}
+ \fi
+}
+\AtBeginSubsection{
+ \frame{\subsectionpage}
+}
+$endif$
+$if(beamerarticle)$
+\usepackage{beamerarticle} % needs to be loaded first
+$endif$
+$fonts.latex()$
+$-- Set Beamer theme before user font settings so they can override theme
+$if(theme)$
+\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}
+$endif$
+$if(colortheme)$
+\usecolortheme{$colortheme$}
+$endif$
+$if(fonttheme)$
+\usefonttheme{$fonttheme$}
+$endif$
+$if(mainfont)$
+\usefonttheme{serif} % use mainfont rather than sansfont for slide text
+$endif$
+$if(innertheme)$
+\useinnertheme{$innertheme$}
+$endif$
+$if(outertheme)$
+\useoutertheme{$outertheme$}
+$endif$
+$font-settings.latex()$
+$common.latex()$
+$for(header-includes)$
+$header-includes$
+$endfor$
+$after-header-includes.latex()$
+$hypersetup.latex()$
+
+$if(title)$
+\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
+$endif$
+$if(subtitle)$
+\subtitle{$subtitle$}
+$endif$
+\author{$for(author)$$author$$sep$ \and $endfor$}
+\date{$date$}
+$if(institute)$
+\institute{$for(institute)$$institute$$sep$ \and $endfor$}
+$endif$
+$if(titlegraphic)$
+\titlegraphic{\includegraphics$if(titlegraphicoptions)$[$for(titlegraphicoptions)$$titlegraphicoptions$$sep$, $endfor$]$endif${$titlegraphic$}}
+$endif$
+$if(logo)$
+\logo{\includegraphics{$logo$}}
+$endif$
+
+\begin{document}
+$if(title)$
+\frame{\titlepage}
+$if(abstract)$
+\begin{abstract}
+$abstract$
+\end{abstract}
+$endif$
+$endif$
+
+$for(include-before)$
+$include-before$
+
+$endfor$
+$if(toc)$
+$if(toc-title)$
+\renewcommand*\contentsname{$toc-title$}
+$endif$
+\begin{frame}[allowframebreaks]
+$if(toc-title)$
+ \frametitle{$toc-title$}
+$endif$
+ \setcounter{tocdepth}{$toc-depth$}
+ \tableofcontents
+\end{frame}
+\setcounter{tocdepth}{$toc-depth$}
+\tableofcontents
+}
+$endif$
+$if(lof)$
+\listoffigures
+$endif$
+$if(lot)$
+\listoftables
+$endif$
+$if(linestretch)$
+\setstretch{$linestretch$}
+$endif$
+$body$
+
+$if(natbib)$
+$if(bibliography)$
+$if(biblio-title)$
+$if(has-chapters)$
+\renewcommand\bibname{$biblio-title$}
+$else$
+\renewcommand\refname{$biblio-title$}
+$endif$
+$endif$
+\begin{frame}[allowframebreaks]{$biblio-title$}
+ \bibliographytrue
+ \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
+\end{frame}
+
+$endif$
+$endif$
+$if(biblatex)$
+\begin{frame}[allowframebreaks]{$biblio-title$}
+ \bibliographytrue
+ \printbibliography[heading=none]
+\end{frame}
+
+$endif$
+$for(include-after)$
+$include-after$
+
+$endfor$
+\end{document}
diff --git a/data/templates/default.latex b/data/templates/default.latex
index 678583f99..4364f93a5 100644
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -1,13 +1,4 @@
-% Options for packages loaded elsewhere
-\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
-\PassOptionsToPackage{hyphens}{url}
-$if(colorlinks)$
-\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
-$endif$
-$if(CJKmainfont)$
-\PassOptionsToPackage{space}{xeCJK}
-$endif$
-%
+$passoptions.latex()$
\documentclass[
$if(fontsize)$
$fontsize$,
@@ -15,549 +6,44 @@ $endif$
$if(papersize)$
$papersize$paper,
$endif$
-$if(beamer)$
- ignorenonframetext,
-$if(handout)$
- handout,
-$endif$
-$if(aspectratio)$
- aspectratio=$aspectratio$,
-$endif$
-$if(babel-lang)$
- $babel-lang$,
-$endif$
-$endif$
$for(classoption)$
$classoption$$sep$,
$endfor$
]{$documentclass$}
-$if(beamer)$
-$if(background-image)$
-\usebackgroundtemplate{%
- \includegraphics[width=\paperwidth]{$background-image$}%
-}
-% In beamer background-image does not work well when other images are used, so this is the workaround
-\pgfdeclareimage[width=\paperwidth,height=\paperheight]{background}{$background-image$}
-\usebackgroundtemplate{\pgfuseimage{background}}
-$endif$
-\usepackage{pgfpages}
-\setbeamertemplate{caption}[numbered]
-\setbeamertemplate{caption label separator}{: }
-\setbeamercolor{caption name}{fg=normal text.fg}
-\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$
-$for(beameroption)$
-\setbeameroption{$beameroption$}
-$endfor$
-% Prevent slide breaks in the middle of a paragraph
-\widowpenalties 1 10000
-\raggedbottom
-$if(section-titles)$
-\setbeamertemplate{part page}{
- \centering
- \begin{beamercolorbox}[sep=16pt,center]{part title}
- \usebeamerfont{part title}\insertpart\par
- \end{beamercolorbox}
-}
-\setbeamertemplate{section page}{
- \centering
- \begin{beamercolorbox}[sep=12pt,center]{section title}
- \usebeamerfont{section title}\insertsection\par
- \end{beamercolorbox}
-}
-\setbeamertemplate{subsection page}{
- \centering
- \begin{beamercolorbox}[sep=8pt,center]{subsection title}
- \usebeamerfont{subsection title}\insertsubsection\par
- \end{beamercolorbox}
-}
-\AtBeginPart{
- \frame{\partpage}
-}
-\AtBeginSection{
- \ifbibliography
- \else
- \frame{\sectionpage}
- \fi
-}
-\AtBeginSubsection{
- \frame{\subsectionpage}
-}
-$endif$
-$endif$
-$if(beamerarticle)$
-\usepackage{beamerarticle} % needs to be loaded first
-$endif$
-\usepackage{amsmath,amssymb}
-$if(linestretch)$
-\usepackage{setspace}
-$endif$
-\usepackage{iftex}
-\ifPDFTeX
- \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
- \usepackage[utf8]{inputenc}
- \usepackage{textcomp} % provide euro and other symbols
-\else % if luatex or xetex
-$if(mathspec)$
- \ifXeTeX
- \usepackage{mathspec} % this also loads fontspec
- \else
- \usepackage{unicode-math} % this also loads fontspec
- \fi
-$else$
- \usepackage{unicode-math} % this also loads fontspec
-$endif$
- \defaultfontfeatures{Scale=MatchLowercase}$-- must come before Beamer theme
- \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
-\fi
-$if(fontfamily)$
-$else$
-$-- Set default font before Beamer theme so the theme can override it
-\usepackage{lmodern}
-$endif$
-$-- Set Beamer theme before user font settings so they can override theme
-$if(beamer)$
-$if(theme)$
-\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}
-$endif$
-$if(colortheme)$
-\usecolortheme{$colortheme$}
-$endif$
-$if(fonttheme)$
-\usefonttheme{$fonttheme$}
-$endif$
-$if(mainfont)$
-\usefonttheme{serif} % use mainfont rather than sansfont for slide text
-$endif$
-$if(innertheme)$
-\useinnertheme{$innertheme$}
-$endif$
-$if(outertheme)$
-\useoutertheme{$outertheme$}
-$endif$
-$endif$
-$-- User font settings (must come after default font and Beamer theme)
-$if(fontfamily)$
-\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
-$endif$
-\ifPDFTeX\else
- % xetex/luatex font selection
-$if(mainfont)$
- $if(mainfontfallback)$
- \ifLuaTeX
- \usepackage{luaotfload}
- \directlua{luaotfload.add_fallback("mainfontfallback",{
- $for(mainfontfallback)$"$mainfontfallback$"$sep$,$endfor$
- })}
- \fi
- $endif$
- \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$$if(mainfontfallback)$,RawFeature={fallback=mainfontfallback}$endif$]{$mainfont$}
-$endif$
-$if(sansfont)$
- $if(sansfontfallback)$
- \ifLuaTeX
- \usepackage{luaotfload}
- \directlua{luaotfload.add_fallback("sansfontfallback",{
- $for(sansfontfallback)$"$sansfontfallback$"$sep$,$endfor$
- })}
- \fi
- $endif$
- \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$$if(sansfontfallback)$,RawFeature={fallback=sansfontfallback}$endif$]{$sansfont$}
-$endif$
-$if(monofont)$
- $if(monofontfallback)$
- \ifLuaTeX
- \usepackage{luaotfload}
- \directlua{luaotfload.add_fallback("monofontfallback",{
- $for(monofontfallback)$"$monofontfallback$"$sep$,$endfor$
- })}
- \fi
- $endif$
- \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$if(monofontfallback)$,RawFeature={fallback=monofontfallback}$endif$]{$monofont$}
-$endif$
-$for(fontfamilies)$
- \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}
-$endfor$
-$if(mathfont)$
-$if(mathspec)$
- \ifXeTeX
- \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
- \else
- \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
- \fi
-$else$
- \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
-$endif$
-$endif$
-$if(CJKmainfont)$
- \ifXeTeX
- \usepackage{xeCJK}
- \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
- $if(CJKsansfont)$
- \setCJKsansfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKsansfont$}
- $endif$
- $if(CJKmonofont)$
- \setCJKmonofont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmonofont$}
- $endif$
- \fi
-$endif$
-$if(luatexjapresetoptions)$
- \ifLuaTeX
- \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}
- \fi
-$endif$
-$if(CJKmainfont)$
- \ifLuaTeX
- \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}
- \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
- \fi
-$endif$
-\fi
-$if(zero-width-non-joiner)$
-%% Support for zero-width non-joiner characters.
-\makeatletter
-\def\zerowidthnonjoiner{%
- % Prevent ligatures and adjust kerning, but still support hyphenating.
- \texorpdfstring{%
- \TextOrMath{\nobreak\discretionary{-}{}{\kern.03em}%
- \ifvmode\else\nobreak\hskip\z@skip\fi}{}%
- }{}%
-}
-\makeatother
-\ifPDFTeX
- \DeclareUnicodeCharacter{200C}{\zerowidthnonjoiner}
-\else
- \catcode`^^^^200c=\active
- \protected\def ^^^^200c{\zerowidthnonjoiner}
-\fi
-%% End of ZWNJ support
-$endif$
-% Use upquote if available, for straight quotes in verbatim environments
-\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
-\IfFileExists{microtype.sty}{% use microtype if available
- \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}
- \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
-}{}
-$if(indent)$
-$else$
-\makeatletter
-\@ifundefined{KOMAClassName}{% if non-KOMA class
- \IfFileExists{parskip.sty}{%
- \usepackage{parskip}
- }{% else
- \setlength{\parindent}{0pt}
- \setlength{\parskip}{6pt plus 2pt minus 1pt}}
-}{% if KOMA class
- \KOMAoptions{parskip=half}}
-\makeatother
-$endif$
-$if(verbatim-in-note)$
-\usepackage{fancyvrb}
-$endif$
\usepackage{xcolor}
$if(geometry)$
-$if(beamer)$
-\geometry{$for(geometry)$$geometry$$sep$,$endfor$}
-$else$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
-$endif$
-$if(beamer)$
-\newif\ifbibliography
-$endif$
-$if(listings)$
-\usepackage{listings}
-\newcommand{\passthrough}[1]{#1}
-\lstset{defaultdialect=[5.3]Lua}
-\lstset{defaultdialect=[x86masm]Assembler}
-$endif$
-$if(lhs)$
-\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
-$endif$
-$if(highlighting-macros)$
-$highlighting-macros$
-$endif$
-$if(tables)$
-\usepackage{longtable,booktabs,array}
-$if(multirow)$
-\usepackage{multirow}
-$endif$
-\usepackage{calc} % for calculating minipage widths
-$if(beamer)$
-\usepackage{caption}
-% Make caption package work with longtable
-\makeatletter
-\def\fnum@table{\tablename~\thetable}
-\makeatother
-$else$
-% Correct order of tables after \paragraph or \subparagraph
-\usepackage{etoolbox}
-\makeatletter
-\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
-\makeatother
-% Allow footnotes in longtable head/foot
-\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
-\makesavenoteenv{longtable}
-$endif$
-$endif$
-$if(graphics)$
-\usepackage{graphicx}
-\makeatletter
-\newsavebox\pandoc@box
-\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
- \sbox\pandoc@box{#1}%
- \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
- \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
- \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
- \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
- \else\usebox{\pandoc@box}%
- \fi%
-}
-% Set default figure placement to htbp
-\def\fps@figure{htbp}
-\makeatother
-$endif$
-$if(svg)$
-\usepackage{svg}
-$endif$
-$if(strikeout)$
-$-- also used for underline
-\ifLuaTeX
- \usepackage{luacolor}
- \usepackage[soul]{lua-ul}
-\else
- \usepackage{soul}
-$if(beamer)$
- \makeatletter
- \let\HL\hl
- \renewcommand\hl{% fix for beamer highlighting
- \let\set@color\beamerorig@set@color
- \let\reset@color\beamerorig@reset@color
- \HL}
- \makeatother
-$endif$
-$if(CJKmainfont)$
- \ifXeTeX
- % soul's \st doesn't work for CJK:
- \usepackage{xeCJKfntef}
- \renewcommand{\st}[1]{\sout{#1}}
- \fi
-$endif$
-\fi
-$endif$
-\setlength{\emergencystretch}{3em} % prevent overfull lines
-\providecommand{\tightlist}{%
- \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
-$if(numbersections)$
-\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
-$else$
-\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
-$endif$
-$if(subfigure)$
-\usepackage{subcaption}
-$endif$
-$if(beamer)$
-$else$
-$if(block-headings)$
-% Make \paragraph and \subparagraph free-standing
-\makeatletter
-\ifx\paragraph\undefined\else
- \let\oldparagraph\paragraph
- \renewcommand{\paragraph}{
- \@ifstar
- \xxxParagraphStar
- \xxxParagraphNoStar
- }
- \newcommand{\xxxParagraphStar}[1]{\oldparagraph*{#1}\mbox{}}
- \newcommand{\xxxParagraphNoStar}[1]{\oldparagraph{#1}\mbox{}}
-\fi
-\ifx\subparagraph\undefined\else
- \let\oldsubparagraph\subparagraph
- \renewcommand{\subparagraph}{
- \@ifstar
- \xxxSubParagraphStar
- \xxxSubParagraphNoStar
- }
- \newcommand{\xxxSubParagraphStar}[1]{\oldsubparagraph*{#1}\mbox{}}
- \newcommand{\xxxSubParagraphNoStar}[1]{\oldsubparagraph{#1}\mbox{}}
-\fi
-\makeatother
-$endif$
-$endif$
-$if(pagestyle)$
-\pagestyle{$pagestyle$}
-$endif$
-$if(csl-refs)$
-% definitions for citeproc citations
-\NewDocumentCommand\citeproctext{}{}
-\NewDocumentCommand\citeproc{mm}{%
- \begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
-\makeatletter
- % allow citations to break across lines
- \let\@cite@ofmt\@firstofone
- % avoid brackets around text for \cite:
- \def\@biblabel#1{}
- \def\@cite#1#2{{#1\if@tempswa , #2\fi}}
-\makeatother
-\newlength{\cslhangindent}
-\setlength{\cslhangindent}{1.5em}
-\newlength{\csllabelwidth}
-\setlength{\csllabelwidth}{3em}
-\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing
- {\begin{list}{}{%
- \setlength{\itemindent}{0pt}
- \setlength{\leftmargin}{0pt}
- \setlength{\parsep}{0pt}
- % turn on hanging indent if param 1 is 1
- \ifodd #1
- \setlength{\leftmargin}{\cslhangindent}
- \setlength{\itemindent}{-1\cslhangindent}
- \fi
- % set entry spacing
- \setlength{\itemsep}{#2\baselineskip}}}
- {\end{list}}
-\usepackage{calc}
-\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
-\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
-\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
-\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
-$endif$
-$if(lang)$
-\ifLuaTeX
-\usepackage[bidi=basic]{babel}
-\else
-\usepackage[bidi=default]{babel}
-\fi
-$if(babel-lang)$
-\babelprovide[main,import]{$babel-lang$}
-$if(mainfont)$
-\ifPDFTeX
-\else
-\babelfont{rm}[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$$if(mainfontfallback)$,RawFeature={fallback=mainfontfallback}$endif$]{$mainfont$}
-\fi
-$endif$
-$endif$
-$for(babel-otherlangs)$
-\babelprovide[import]{$babel-otherlangs$}
-$endfor$
-$for(babelfonts/pairs)$
-\babelfont[$babelfonts.key$]{rm}{$babelfonts.value$}
-$endfor$
-% get rid of language-specific shorthands (see #6817):
-\let\LanguageShortHands\languageshorthands
-\def\languageshorthands#1{}
-$if(selnolig-langs)$
-\ifLuaTeX
- \usepackage[$for(selnolig-langs)$$it$$sep$,$endfor$]{selnolig} % disable illegal ligatures
-\fi
-$endif$
-$endif$
+$fonts.latex()$
+$font-settings.latex()$
+$common.latex()$
$for(header-includes)$
$header-includes$
$endfor$
-$if(dir)$
-\ifPDFTeX
- \TeXXeTstate=1
- \newcommand{\RL}[1]{\beginR #1\endR}
- \newcommand{\LR}[1]{\beginL #1\endL}
- \newenvironment{RTL}{\beginR}{\endR}
- \newenvironment{LTR}{\beginL}{\endL}
-\fi
-$endif$
-$if(natbib)$
-\usepackage[$natbiboptions$]{natbib}
-\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
-$endif$
-$if(biblatex)$
-\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
-$for(bibliography)$
-\addbibresource{$bibliography$}
-$endfor$
-$endif$
-$if(nocite-ids)$
-\nocite{$for(nocite-ids)$$it$$sep$, $endfor$}
-$endif$
-$if(csquotes)$
-\usepackage{csquotes}
-$endif$
-\usepackage{bookmark}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\urlstyle{$if(urlstyle)$$urlstyle$$else$same$endif$}
-$if(links-as-notes)$
-% Make links footnotes instead of hotlinks:
-\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}
-$endif$
-$if(verbatim-in-note)$
-\VerbatimFootnotes % allow verbatim text in footnotes
-$endif$
-\hypersetup{
-$if(title-meta)$
- pdftitle={$title-meta$},
-$endif$
-$if(author-meta)$
- pdfauthor={$author-meta$},
-$endif$
-$if(lang)$
- pdflang={$lang$},
-$endif$
-$if(subject)$
- pdfsubject={$subject$},
-$endif$
-$if(keywords)$
- pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
-$endif$
-$if(colorlinks)$
- colorlinks=true,
- linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$},
- filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$},
- citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$},
- urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$},
-$else$
-$if(boxlinks)$
-$else$
- hidelinks,
-$endif$
-$endif$
- pdfcreator={LaTeX via pandoc}}
+$after-header-includes.latex()$
+$hypersetup.latex()$
$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$
$if(subtitle)$
-$if(beamer)$
-$else$
\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother
-$endif$
\subtitle{$subtitle$}
$endif$
\author{$for(author)$$author$$sep$ \and $endfor$}
\date{$date$}
-$if(beamer)$
-$if(institute)$
-\institute{$for(institute)$$institute$$sep$ \and $endfor$}
-$endif$
-$if(titlegraphic)$
-\titlegraphic{\includegraphics$if(titlegraphicoptions)$[$for(titlegraphicoptions)$$titlegraphicoptions$$sep$, $endfor$]$endif${$titlegraphic$}}
-$endif$
-$if(logo)$
-\logo{\includegraphics{$logo$}}
-$endif$
-$endif$
\begin{document}
$if(has-frontmatter)$
\frontmatter
$endif$
$if(title)$
-$if(beamer)$
-\frame{\titlepage}
-$else$
\maketitle
-$endif$
$if(abstract)$
\begin{abstract}
$abstract$
@@ -573,15 +59,6 @@ $if(toc)$
$if(toc-title)$
\renewcommand*\contentsname{$toc-title$}
$endif$
-$if(beamer)$
-\begin{frame}[allowframebreaks]
-$if(toc-title)$
- \frametitle{$toc-title$}
-$endif$
- \setcounter{tocdepth}{$toc-depth$}
- \tableofcontents
-\end{frame}
-$else$
{
$if(colorlinks)$
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
@@ -590,7 +67,6 @@ $endif$
\tableofcontents
}
$endif$
-$endif$
$if(lof)$
\listoffigures
$endif$
@@ -617,26 +93,12 @@ $else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
-$if(beamer)$
-\begin{frame}[allowframebreaks]{$biblio-title$}
- \bibliographytrue
-$endif$
- \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
-$if(beamer)$
-\end{frame}
-$endif$
+\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$endif$
$endif$
$if(biblatex)$
-$if(beamer)$
-\begin{frame}[allowframebreaks]{$biblio-title$}
- \bibliographytrue
- \printbibliography[heading=none]
-\end{frame}
-$else$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
-$endif$
$endif$
$for(include-after)$
diff --git a/data/templates/font-settings.latex b/data/templates/font-settings.latex
new file mode 100644
index 000000000..f9362b010
--- /dev/null
+++ b/data/templates/font-settings.latex
@@ -0,0 +1,103 @@
+$-- User font settings (must come after default font and Beamer theme)
+$if(fontfamily)$
+\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
+$endif$
+\ifPDFTeX\else
+ % xetex/luatex font selection
+$if(mainfont)$
+ $if(mainfontfallback)$
+ \ifLuaTeX
+ \usepackage{luaotfload}
+ \directlua{luaotfload.add_fallback("mainfontfallback",{
+ $for(mainfontfallback)$"$mainfontfallback$"$sep$,$endfor$
+ })}
+ \fi
+ $endif$
+ \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$$if(mainfontfallback)$,RawFeature={fallback=mainfontfallback}$endif$]{$mainfont$}
+$endif$
+$if(sansfont)$
+ $if(sansfontfallback)$
+ \ifLuaTeX
+ \usepackage{luaotfload}
+ \directlua{luaotfload.add_fallback("sansfontfallback",{
+ $for(sansfontfallback)$"$sansfontfallback$"$sep$,$endfor$
+ })}
+ \fi
+ $endif$
+ \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$$if(sansfontfallback)$,RawFeature={fallback=sansfontfallback}$endif$]{$sansfont$}
+$endif$
+$if(monofont)$
+ $if(monofontfallback)$
+ \ifLuaTeX
+ \usepackage{luaotfload}
+ \directlua{luaotfload.add_fallback("monofontfallback",{
+ $for(monofontfallback)$"$monofontfallback$"$sep$,$endfor$
+ })}
+ \fi
+ $endif$
+ \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$if(monofontfallback)$,RawFeature={fallback=monofontfallback}$endif$]{$monofont$}
+$endif$
+$for(fontfamilies)$
+ \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}
+$endfor$
+$if(mathfont)$
+$if(mathspec)$
+ \ifXeTeX
+ \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
+ \else
+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
+ \fi
+$else$
+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
+$endif$
+$endif$
+$if(CJKmainfont)$
+ \ifXeTeX
+ \usepackage{xeCJK}
+ \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
+ $if(CJKsansfont)$
+ \setCJKsansfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKsansfont$}
+ $endif$
+ $if(CJKmonofont)$
+ \setCJKmonofont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmonofont$}
+ $endif$
+ \fi
+$endif$
+$if(luatexjapresetoptions)$
+ \ifLuaTeX
+ \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}
+ \fi
+$endif$
+$if(CJKmainfont)$
+ \ifLuaTeX
+ \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}
+ \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
+ \fi
+$endif$
+\fi
+$if(zero-width-non-joiner)$
+%% Support for zero-width non-joiner characters.
+\makeatletter
+\def\zerowidthnonjoiner{%
+ % Prevent ligatures and adjust kerning, but still support hyphenating.
+ \texorpdfstring{%
+ \TextOrMath{\nobreak\discretionary{-}{}{\kern.03em}%
+ \ifvmode\else\nobreak\hskip\z@skip\fi}{}%
+ }{}%
+}
+\makeatother
+\ifPDFTeX
+ \DeclareUnicodeCharacter{200C}{\zerowidthnonjoiner}
+\else
+ \catcode`^^^^200c=\active
+ \protected\def ^^^^200c{\zerowidthnonjoiner}
+\fi
+%% End of ZWNJ support
+$endif$
+% Use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+\IfFileExists{microtype.sty}{% use microtype if available
+ \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}
+ \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+
diff --git a/data/templates/fonts.latex b/data/templates/fonts.latex
new file mode 100644
index 000000000..a1cebac09
--- /dev/null
+++ b/data/templates/fonts.latex
@@ -0,0 +1,27 @@
+\usepackage{amsmath,amssymb}
+$if(linestretch)$
+\usepackage{setspace}
+$endif$
+\usepackage{iftex}
+\ifPDFTeX
+ \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
+ \usepackage[utf8]{inputenc}
+ \usepackage{textcomp} % provide euro and other symbols
+\else % if luatex or xetex
+$if(mathspec)$
+ \ifXeTeX
+ \usepackage{mathspec} % this also loads fontspec
+ \else
+ \usepackage{unicode-math} % this also loads fontspec
+ \fi
+$else$
+ \usepackage{unicode-math} % this also loads fontspec
+$endif$
+ \defaultfontfeatures{Scale=MatchLowercase}$-- must come before Beamer theme
+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
+\fi
+$if(fontfamily)$
+$else$
+$-- Set default font before Beamer theme so the theme can override it
+\usepackage{lmodern}
+$endif$
diff --git a/data/templates/hypersetup.latex b/data/templates/hypersetup.latex
new file mode 100644
index 000000000..ff6765557
--- /dev/null
+++ b/data/templates/hypersetup.latex
@@ -0,0 +1,30 @@
+\hypersetup{
+$if(title-meta)$
+ pdftitle={$title-meta$},
+$endif$
+$if(author-meta)$
+ pdfauthor={$author-meta$},
+$endif$
+$if(lang)$
+ pdflang={$lang$},
+$endif$
+$if(subject)$
+ pdfsubject={$subject$},
+$endif$
+$if(keywords)$
+ pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
+$endif$
+$if(colorlinks)$
+ colorlinks=true,
+ linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$},
+ filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$},
+ citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$},
+ urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$},
+$else$
+$if(boxlinks)$
+$else$
+ hidelinks,
+$endif$
+$endif$
+ pdfcreator={LaTeX via pandoc}}
+
diff --git a/data/templates/passoptions.latex b/data/templates/passoptions.latex
new file mode 100644
index 000000000..c218b0d20
--- /dev/null
+++ b/data/templates/passoptions.latex
@@ -0,0 +1,9 @@
+% Options for packages loaded elsewhere
+\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
+\PassOptionsToPackage{hyphens}{url}
+$if(colorlinks)$
+\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
+$endif$
+$if(CJKmainfont)$
+\PassOptionsToPackage{space}{xeCJK}
+$endif$
diff --git a/pandoc.cabal b/pandoc.cabal
index b164c61e4..f4e78be7c 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -67,6 +67,7 @@ data-files:
data/templates/default.openxml
data/templates/default.icml
data/templates/default.opml
+ data/templates/default.beamer
data/templates/default.latex
data/templates/default.bibtex
data/templates/default.biblatex
@@ -103,6 +104,13 @@ data-files:
data/templates/default.typst
data/templates/definitions.typst
data/templates/template.typst
+ data/templates/common.latex
+ data/templates/hypersetup.latex
+ data/templates/passoptions.latex
+ data/templates/font-settings.latex
+ data/templates/fonts.latex
+ data/templates/after-header-includes.latex
+
-- translations
data/translations/*.yaml
-- entities
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index 122a33c66..fa921ae8b 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -112,7 +112,6 @@ getDefaultTemplate format = do
"html" -> getDefaultTemplate "html5"
"docbook" -> getDefaultTemplate "docbook5"
"epub" -> getDefaultTemplate "epub3"
- "beamer" -> getDefaultTemplate "latex"
"jats" -> getDefaultTemplate "jats_archiving"
"markdown_strict" -> getDefaultTemplate "markdown"
"multimarkdown" -> getDefaultTemplate "markdown"
diff --git a/test/command/9472.md b/test/command/9472.md
index 7da450ee9..273edde94 100644
--- a/test/command/9472.md
+++ b/test/command/9472.md
@@ -11,9 +11,9 @@ More text in English. ['Zitat auf Deutsch.']{lang=de}
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
-%
\documentclass[
]{article}
+\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
@@ -45,11 +45,6 @@ More text in English. ['Zitat auf Deutsch.']{lang=de}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
-\usepackage{xcolor}
-\setlength{\emergencystretch}{3em} % prevent overfull lines
-\providecommand{\tightlist}{%
- \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
-\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
@@ -63,6 +58,10 @@ More text in English. ['Zitat auf Deutsch.']{lang=de}
\ifLuaTeX
\usepackage[german]{selnolig} % disable illegal ligatures
\fi
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
diff --git a/test/writer.latex b/test/writer.latex
index 1cb69633f..a5ee8a04e 100644
--- a/test/writer.latex
+++ b/test/writer.latex
@@ -1,9 +1,9 @@
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
-%
\documentclass[
]{article}
+\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
@@ -36,7 +36,6 @@
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{fancyvrb}
-\usepackage{xcolor}
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex
index 3d12f0c1e..2a3e8242a 100644
--- a/test/writers-lang-and-dir.latex
+++ b/test/writers-lang-and-dir.latex
@@ -1,9 +1,9 @@
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
-%
\documentclass[
]{article}
+\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
@@ -35,11 +35,6 @@
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
-\usepackage{xcolor}
-\setlength{\emergencystretch}{3em} % prevent overfull lines
-\providecommand{\tightlist}{%
- \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
-\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
@@ -57,6 +52,10 @@
\ifLuaTeX
\usepackage[english,german]{selnolig} % disable illegal ligatures
\fi
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifPDFTeX
\TeXXeTstate=1
\newcommand{\RL}[1]{\beginR #1\endR}