From 516931f4b5615fbdbd78928cf239c31c0794a176 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 23 Oct 2024 19:17:51 -0700 Subject: [PATCH] LaTeX/Beamer template changes. - Split fonts.latex partial into two parts: fonts.latex and font-settings.latex. - In beamer template, load beamer theme between fonts.latex and font-settings.latex. This allows a theme (such as metropolis) to set its own default font, while still allowing the user to override it. This fixes a regression in pandoc 3.5. Users who have custom templates based on pandoc 3.5 templates will need to add `font-settings.latex()` after `fonts.latex()` in the latex template. In a beamer template, the beamer theme-setting code needs to be moved between these two partials. Closes #10297. --- data/templates/default.beamer | 37 ++++++------ data/templates/default.latex | 1 + data/templates/fonts.latex | 103 ---------------------------------- 3 files changed, 20 insertions(+), 121 deletions(-) diff --git a/data/templates/default.beamer b/data/templates/default.beamer index ddce9f749350..9fcbcf57a4f0 100644 --- a/data/templates/default.beamer +++ b/data/templates/default.beamer @@ -62,6 +62,24 @@ $endif$ $for(beameroption)$ \setbeameroption{$beameroption$} $endfor$ +% Prevent slide breaks in the middle of a paragraph +\widowpenalties 1 10000 +\raggedbottom +$if(section-titles)$ +\AtBeginPart{ + \frame{\partpage} +} +\AtBeginSection{ + \ifbibliography + \else + \frame{\sectionpage} + \fi +} +\AtBeginSubsection{ + \frame{\subsectionpage} +} +$endif$ +$fonts.latex()$ $-- Set Beamer theme before user font settings so they can override theme $if(theme)$ \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} @@ -81,24 +99,7 @@ $endif$ $if(outertheme)$ \useoutertheme[$for(outerthemeoptions)$$outerthemeoptions$$sep$,$endfor$]{$outertheme$} $endif$ -% Prevent slide breaks in the middle of a paragraph -\widowpenalties 1 10000 -\raggedbottom -$if(section-titles)$ -\AtBeginPart{ - \frame{\partpage} -} -\AtBeginSection{ - \ifbibliography - \else - \frame{\sectionpage} - \fi -} -\AtBeginSubsection{ - \frame{\subsectionpage} -} -$endif$ -$fonts.latex()$ +$font-settings.latex()$ $common.latex()$ $for(header-includes)$ $header-includes$ diff --git a/data/templates/default.latex b/data/templates/default.latex index 34b93c813b2f..58337066a97f 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -27,6 +27,7 @@ $else$ \setcounter{secnumdepth}{-\maxdimen} % remove section numbering $endif$ $fonts.latex()$ +$font-settings.latex()$ $common.latex()$ $for(header-includes)$ $header-includes$ diff --git a/data/templates/fonts.latex b/data/templates/fonts.latex index 3faf41d572d8..53a8e3c84390 100644 --- a/data/templates/fonts.latex +++ b/data/templates/fonts.latex @@ -21,106 +21,3 @@ $else$ $-- Set default font before Beamer theme so the theme can override it \usepackage{lmodern} $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 -}{} -