diff --git a/slides_template/trantor.sty b/slides_template/trantor.sty index 0ea0ef0..bee92c0 100644 --- a/slides_template/trantor.sty +++ b/slides_template/trantor.sty @@ -13,12 +13,8 @@ \RequirePackage{tikz} \RequirePackage{pifont} -% -- Fonts. Upstream sets Libertinus here and loads lum-euler for maths. -% Both are left to the document instead: this template ships OpenSans and -% RobotoMono, and lum-euler is not packaged in Debian's TeX Live. The document -% is expected to \setsansfont, \setmonofont and load a Unicode maths font -% before using anything below. \headerfont is what the theme uses for titles -% and other display text; redefine it if you want titles in a second face. +% -- Fonts. Upstream sets Libertinus and loads lum-euler; both are left to the +% document, which must \setsansfont, \setmonofont and load a maths font. \renewcommand{\familydefault}{\sfdefault} \linespread{1.18} \providecommand\headerfont{\sffamily} @@ -34,17 +30,15 @@ \setlength\belowdisplayshortskip{5pt plus 2pt minus 1pt}% } -% -- Palette. Four colours drive everything the theme draws. Override any of -% them in the preamble, before or after loading trantor: -% -% \definecolor{accent}{HTML}{BF1238} -% \colorlet{TrantorDark}{makopurple1} -% -% accent progress bars and emphasis -% TrantorDark header band, section dividers, standout panels, frame numbers -% TrantorLight text on dark, and anything that has to read against it -% TrantorMuted affiliations, footlines, arxiv tags. This is the lightest grey -% that still meets WCAG AA contrast (4.5:1) on white (~4.54:1). +% -- Colours. Set your own accent anywhere in the preamble with, e.g., +% \definecolor{accent}{HTML}{BF1238} +% \definecolor{TrantorDark}{HTML}{23373B} +% Four colour palette: +% 1. accent progress bars, title rule +% 2. TrantorDark headings, section dividers, standout panels, frame numbers +% 3. TrantorLight text set against TrantorDark +% 4. TrantorMuted affiliation, footline, arxiv. Lightest grey that still meets +% WCAG AA contrast (4.5:1) on white (~4.54:1). \providecolor{accent}{HTML}{2A7AE2} \providecolor{TrantorDark}{HTML}{000000} \providecolor{TrantorLight}{HTML}{FFFFFF} @@ -55,11 +49,8 @@ \AddToHook{begindocument}{\colorlet{structure}{TrantorDark}} % -- Header bar carrying the frame title (hidden on plain pages). -% The band is a rule of height (header height - headsep) with depth headsep, so -% headsep is the only thing that puts space under the title. geometry owns it. +% headsep is what pads under the title; the height key alone only pads above. \geometry{headsep=10pt} - - \AddToHook{begindocument}{% \EditInstance{header}{std}{ background-color = TrantorDark, @@ -105,28 +96,21 @@ \href{https://arxiv.org/abs/#1}{{\headerfont\scriptsize\color{TrantorMuted}arXiv:#1}}% } -% -- \appendix, which ltx-talk does not provide. Frames after it keep counting -% but are left out of the total, so the denominator is the last frame of the -% talk proper. This is what appendixnumberbeamer does for beamer. The count is -% carried through the aux file, so it settles on the second run. +% -- \appendix: frames after it are numbered among themselves and left out of +% the total. The count travels through the aux file, so it settles on the +% second run. \newif\iftrantorAppendix \trantorAppendixfalse \newcommand\trantorMainFrames{\@totalframes} -% Appendix frames are numbered among themselves, as appendixnumberbeamer does, -% but by subtracting an offset rather than resetting the counter. The class -% records a property per frame keyed on that counter, so resetting it collides -% with ltx-talk's own frame. labels and breaks \ref to a frame. Properly -% this belongs in the class, which could renumber and relabel together. \NewDocumentCommand \appendix { } {% \global\trantorAppendixtrue \protected@write\@auxout{}{% \string\gdef\string\trantorMainFrames{\the\value{frame}}}% } -% Numerator and denominator for the frame counter and the progress bars. These -% are count registers rather than macros because pgfmath expands its argument -% while parsing, and a macro carrying a conditional sends it into a loop. +% Count registers, not macros: pgfmath expands while parsing, and a macro +% carrying a conditional loops. \newcount\trantor@n \newcount\trantor@d @@ -140,10 +124,11 @@ \fi } -\newcommand\trantorFrameNumber{\trantor@setcounts\the\trantor@n} -\newcommand\trantorTotalFrames{\trantor@setcounts\the\trantor@d} - +% Fraction of the way through the talk, shared by the footer bar and +% \trantorProgressBar. The zero test must stay outside pgfmath, which +% evaluates both arms of a ternary. \newcommand\trantor@setratio{% + \trantor@setcounts \ifnum\trantor@d>0 \pgfmathsetmacro{\trantorratio}{min(\the\trantor@n / \the\trantor@d, 1)}% \else @@ -151,6 +136,21 @@ \fi } +% \trantorProgressBar{}: a rule of the given width, filled to the +% current position and grey the rest of the way. +\newlength\trantor@barwidth +\newlength\trantor@barfill + +\NewDocumentCommand \trantorProgressBar { m } {% + \setlength\trantor@barwidth{#1}% + \trantor@setratio + % dimen = , so \trantorratio scales the width + \setlength\trantor@barfill{\trantorratio\trantor@barwidth}% + \textcolor{TrantorAccent}{\rule{\trantor@barfill}{0.6pt}}% + \textcolor{TrantorDark!20}{% + \rule{\dimexpr\trantor@barwidth-\trantor@barfill\relax}{0.6pt}}% +} + % -- Bottom progress bar + frame counter (hidden on plain pages). \newif\iftrantorPlainPage \trantorPlainPagefalse @@ -159,22 +159,20 @@ \iftrantorPlainPage\else \trantorArtifactBegin \begin{tikzpicture}[remember picture, overlay] - \trantor@setcounts \trantor@setratio \fill[TrantorAccent] (current page.south west) rectangle ([xshift=\trantorratio\paperwidth, yshift=1pt] current page.south west); - \node[anchor=south east, inner sep=5pt, font=\scriptsize, text=TrantorDark] - at (current page.south east) - {\the\trantor@n\,/\,\the\trantor@d}; + \node[anchor=south east, inner sep=5pt, font=\tiny, text=TrantorDark] + at (current page.south east) {\the\trantor@n\,/\,\the\trantor@d}; \end{tikzpicture}% \trantorArtifactEnd \fi \global\trantorPlainPagefalse } -% -- Remember the current section title, and dim the others in the mini-TOC. +% -- Remember the section and subsection titles, for the dividers. \ExplSyntaxOn \tl_new:N \g__trantor_section_tl @@ -187,8 +185,8 @@ \cs_new_protected:Npn \__trantor_print_section: { \tl_use:N \g__trantor_section_tl } \cs_set_eq:NN \trantorSectionTitle \__trantor_print_section: -% Likewise the subsection, for \subsectionpage. Cleared at each new section so -% that a stale subsection title cannot leak into the next one. +% Likewise the subsection, for \subsectionpage. Cleared when a new section +% starts so a stale title cannot leak into the next one. \tl_new:N \g__trantor_subsection_tl \AddToHook{section/begin}{ \tl_gclear:N \g__trantor_subsection_tl } @@ -209,29 +207,9 @@ { \cs_if_exist:NT \tag_suspend:n { \tag_suspend:n { trantor } } } \cs_new_protected:Npn \trantorArtifactEnd { \cs_if_exist:NT \tag_resume:n { \tag_resume:n { trantor } } } - -% Soften the dimming of inactive TOC entries on the section page (0.2 -> 0.7). -% ltx-talk exposes no key for this yet, so we override the class-private -% \__talk_toc_dest:w. Revisit if a supported interface appears or the internal -% changes. -\cs_set_protected:Npn \__talk_toc_dest:w #1 . #2 . #3 . #4 . #5 \q_stop #6 - { - \bool_lazy_or:nnTF - { - \bool_lazy_and_p:nn - { \int_compare_p:nNn { \value { section } } = {#2} } - { \int_compare_p:nNn { \value { subsection } } = 0 } - } - { - \bool_lazy_and_p:nn - { \int_compare_p:nNn { \value { section } } = {#2} } - { \int_compare_p:nNn { \value { subsection } } = {#3} } - } - {#6} - { \opacity_begin:n { 0.7 } #6 \opacity_end: } - } \ExplSyntaxOff + % -- Title page. Drop a logo.png next to your slides, or redefine \titlelogo. \newcommand{\titlelogo}{% \IfFileExists{logo.png} @@ -277,52 +255,9 @@ \end{frame}% } -% -- Divider pages, following metropolis: on the ordinary light background, a -% block set in the middle of the slide holding the section title over a -% progress bar, and for a subsection the subsection title beneath that. The -% bar is the same progress the footer bar shows, drawn at half width. The -% footer bar and frame number stay, so these are not plain pages in the sense -% the shipout hook means. -\newlength\trantor@barwidth -\newlength\trantor@barfill - -% \trantorProgressBar{}: filled to the current position, grey after. -\NewDocumentCommand \trantorProgressBar { m } {% - \setlength\trantor@barwidth{#1}% - \trantor@setcounts - \trantor@setratio - \setlength\trantor@barfill{\trantorratio\trantor@barwidth}% - \textcolor{TrantorDark}{\rule{\trantor@barfill}{0.6pt}}% - \textcolor{TrantorDark!20}{% - \rule{\dimexpr\trantor@barwidth-\trantor@barfill\relax}{0.6pt}}% -} - -\NewDocumentCommand \trantor@divider { m } {% - \begin{frame}{}% - \thispagestyle{plain}% - \vfill - \centering - \begin{minipage}{0.52\linewidth}% - \raggedright - {\headerfont\Large\bfseries\trantorSectionTitle\par}% - \vspace{0.4em}% - \trantorProgressBar{\linewidth}% - \IfBlankF{#1}{% - \par\vspace{0.8em}% - {\headerfont\large\bfseries #1\par}% - }% - \end{minipage}% - \par - \vfill - \end{frame}% -} - -\NewDocumentCommand \sectionpage { } { \trantor@divider {} } -\NewDocumentCommand \subsectionpage { } { \trantor@divider {\trantorSubsectionTitle} } - -% \standout{...}: a full frame with the same dark panel as \sectionpage, -% and the given text centred on it. -\NewDocumentCommand \standout { +m } {% +% -- A full-bleed dark panel with the given body centred in a minipage of the +% given width. +\NewDocumentCommand \trantor@panel { m +m } {% \global\trantorPlainPagetrue \begin{frame}{}% \thispagestyle{plain}% @@ -335,14 +270,47 @@ (\dimexpr\paperwidth-\Gm@lmargin\relax, -\paperheight); \node[text=TrantorLight, anchor=center, inner sep=0pt] at (0.5\linewidth, -0.5\textheight) {% - \begin{minipage}{0.8\linewidth} + \begin{minipage}{#1} \centering - \headerfont\LARGE\bfseries - #1 + #2 \end{minipage}% }; \end{tikzpicture}% \end{frame}% } +% -- Divider pages: the section title over a progress bar, set on the ordinary +% light background. Not plain pages: the footer bar and frame number stay. +\NewDocumentCommand \trantor@divider { +m } {% + \begin{frame}{}% + \thispagestyle{plain}% + \vfill + \centering + \begin{minipage}{0.52\linewidth}% + \raggedright + {\headerfont\Large\bfseries\trantorSectionTitle\par}% + \vspace{0.4em}% + \trantorProgressBar{\linewidth}% + #1% + \end{minipage}% + \par + \vfill + \end{frame}% +} + +\NewDocumentCommand \sectionpage { } { \trantor@divider{} } + +% The subsection divider is the same, naming the subsection under the bar. +\NewDocumentCommand \subsectionpage { } {% + \trantor@divider{% + \par\vspace{0.8em}% + {\headerfont\large\bfseries\trantorSubsectionTitle\par}% + }% +} + +% \standout{...}: a full-bleed dark panel with the given text centred on it. +\NewDocumentCommand \standout { +m } {% + \trantor@panel{0.8\linewidth}{\headerfont\LARGE\bfseries #1}% +} + \makeatother