| 1 |
% \iffalse meta-comment |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% memoize-ext-talk.dtx |
| 4 |
% Additions and changes Copyright (C) 2024-2026 Clea F. Rees. |
| 5 |
% Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below). |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in |
| 11 |
% https://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2008-05-04 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status 'muaintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is Clea F. Rees. |
| 18 |
% |
| 19 |
% This work consists of all files listed in manifest.txt. |
| 20 |
% |
| 21 |
% The file memoize-ext-talk.dtx is a derived work under the terms of the |
| 22 |
% LPPL. It is based on version 2.4 of skeleton.dtx which is part of |
| 23 |
% dtxtut by Scott Pakin. A copy of dtxtut, including the |
| 24 |
% unmodified version of skeleton.dtx is available from |
| 25 |
% https://www.ctan.org/pkg/dtxtut and released under the LPPL. |
| 26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 27 |
% \fi |
| 28 |
% |
| 29 |
% \iffalse |
| 30 |
%<*driver> |
| 31 |
\GetIdInfo $Id: memoize-ext-talk.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize} |
| 32 |
\ProvidesExplFile{\ExplFileName}{\ExplFileDate}{v0.3.5 \ExplFileVersion}{\ExplFileDescription} |
| 33 |
\begin{document} |
| 34 |
\let\MakePrivateLetters\MyMakePrivateLetters |
| 35 |
\DocInput{\filename} |
| 36 |
\end{document} |
| 37 |
%</driver> |
| 38 |
% \fi |
| 39 |
% |
| 40 |
% |
| 41 |
% \title{\ExplFileName} |
| 42 |
% \date{\ExplFileVersion~\ExplFileDate} |
| 43 |
% \maketitle |
| 44 |
% |
| 45 |
% |
| 46 |
% \begin{abstract} |
| 47 |
% \noindent\pkg{memoize-ext-talk} enables memoization of \cls{ltx-talk} presentations \autocite{joseph-talk}. |
| 48 |
% The package is part of \pkg{memoize-ext}. |
| 49 |
% |
| 50 |
% \pkg{memoize-ext-talk} is essentially a ‘translation’ of \pkg{memoize}'s support for \pkg{beamer}, together with modifications for differences in the way the classes implement overlays and changes to the implementation of opacity when \pkg{pdfmanagement-testphase} \autocite{latex-project-pdfmanagement-testphase} is loaded. |
| 51 |
% |
| 52 |
% The package tries to avoid utilising the internals of either \pkg{memoize} or \cls{ltx-talk}, but it was not entirely possible to do so without making the code both more fragile and unduly convoluted. |
| 53 |
% See the main manual for \pkg{memoize-ext} for details. |
| 54 |
% |
| 55 |
% The user interface is identical to that provided by \pkg{memoize} for \cls{beamer} \autocite{saso-memoize}. |
| 56 |
% \end{abstract} |
| 57 |
% |
| 58 |
% \tableofcontents |
| 59 |
% |
| 60 |
% \MaybeStop{% |
| 61 |
% \PrintChanges |
| 62 |
% \PrintIndex |
| 63 |
% } |
| 64 |
% |
| 65 |
% ^^A \section{Implementation} |
| 66 |
% |
| 67 |
%<*sty> |
| 68 |
%<@@=mmzx> |
| 69 |
% \begin{macrocode} |
| 70 |
\GetIdInfo $Id: memoize-ext-talk.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize for tagged ltx-talk} |
| 71 |
%<!debug> \ProvidesExplPackage{\ExplFileName}{\ExplFileDate} |
| 72 |
%<!debug> {v0.3.5 \ExplFileVersion}{\ExplFileDescription} |
| 73 |
%<debug> \ProvidesExplPackage{\ExplFileName-debug}{\ExplFileDate} |
| 74 |
%<debug> {v0.3.5 \ExplFileVersion}{\ExplFileDescription} |
| 75 |
% |
| 76 |
%<!debug> \disable@package@load {memoize-ext-talk-debug} |
| 77 |
%<debug> \disable@package@load {memoize-ext-talk} |
| 78 |
{ Only~one~of~memoize-ext-talk~and~memoize-ext-talk-debug~ |
| 79 |
should~be~loaded. |
| 80 |
Since~ |
| 81 |
%<!debug> memoize-ext-talk |
| 82 |
%<debug> memoize-ext-talk-debug |
| 83 |
~has~been~loaded,~I~will~ignore~your~request~for~ |
| 84 |
%<debug> memoize-ext-talk |
| 85 |
%<!debug> memoize-ext-talk-debug |
| 86 |
.} |
| 87 |
% \end{macrocode} |
| 88 |
% \changes{v0.3}{2026-03-02}{Load \pkg{memoize-ext-tag}/\pkg{memoize-ext-tag-debug} and hope \cs{DocumentMetadata} is sufficient in case tagging is off.} |
| 89 |
% We have to load this (I think) prior to \cs{documentclass}, so cannot use \verb|tag_if_active:TF| here. |
| 90 |
% We could test for \cs{DocumentMetadata}, but \cls{ltx-talk} already requires that. |
| 91 |
% But maybe I should be testing that anyway? |
| 92 |
% \begin{macrocode} |
| 93 |
%<!debug> \RequirePackage{memoize-ext-tag} |
| 94 |
%<debug> \RequirePackage{memoize-ext-tag-debug} |
| 95 |
% \end{macrocode} |
| 96 |
% We don't want inconsistent names in hooks. |
| 97 |
% \begin{macrocode} |
| 98 |
\SetDefaultHookLabel{memoize-ext} |
| 99 |
% \end{macrocode} |
| 100 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 101 |
% BEGIN ltx-talk |
| 102 |
% addaswyd o memoize-beamer.code.tex \& other memoize code |
| 103 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 104 |
% \begin{macrocode} |
| 105 |
\hook_gput_code:nnn {class/ltx-talk/after}{.} |
| 106 |
{ |
| 107 |
%<debug> \@@_debug:n {Enabling~ltx-talk~support.} |
| 108 |
\mmzset{ |
| 109 |
per~overlay/.code={}, |
| 110 |
talk~mode~to~prefix/.style={ |
| 111 |
prefix=\mmz@prefix@dir\mmz@prefix@name\l_@@_talk_mode_str -, |
| 112 |
}, |
| 113 |
} |
| 114 |
% \end{macrocode} |
| 115 |
% \begin{macrocode} |
| 116 |
% \end{macrocode} |
| 117 |
% \begin{var}{\g__@@_talk_opacity_seq, |
| 118 |
% \g_@@_talk_saved_opacity_seq, |
| 119 |
% \l_@@_talk_opacity_tl, |
| 120 |
% } |
| 121 |
% \mbox{} |
| 122 |
% \begin{macrocode} |
| 123 |
\seq_new:N \g_@@_talk_opacity_seq |
| 124 |
\seq_new:N \g_@@_talk_saved_opacity_seq |
| 125 |
\tl_new:N \l_@@_talk_opacity_tl |
| 126 |
% \end{macrocode} |
| 127 |
% \end{var} |
| 128 |
% \begin{macro}{% |
| 129 |
% \g_@@_talk_frame_int, |
| 130 |
% \g_@@_talk_slide_int, |
| 131 |
% \g_@@_talk_pauses_int, |
| 132 |
% \l_@@_talk_mode_str, |
| 133 |
% } |
| 134 |
% \begin{macrocode} |
| 135 |
|
| 136 |
\cs_new_eq:NN \g_@@_talk_frame_int \c@frame |
| 137 |
\cs_new_eq:NN \g_@@_talk_slide_int \c@slide |
| 138 |
\cs_new_eq:NN \g_@@_talk_pauses_int \c@pauses |
| 139 |
\cs_new_eq:NN \l_@@_talk_mode_str \l__talk_mode_str |
| 140 |
% \end{macrocode} |
| 141 |
% \end{macro} |
| 142 |
% \begin{fn}{% |
| 143 |
% \opacity_select:V, |
| 144 |
% } |
| 145 |
% \pkg{ltx-talk} does this too late (at least, I get an error) |
| 146 |
% \begin{macrocode} |
| 147 |
\cs_generate_variant:Nn \opacity_select:n {V} |
| 148 |
% \end{macrocode} |
| 149 |
% \end{fn} |
| 150 |
% Initialise sequence. |
| 151 |
% \begin{macrocode} |
| 152 |
\seq_gpush:Nn \g_@@_talk_opacity_seq {1} |
| 153 |
% \end{macrocode} |
| 154 |
% \begin{fn}{\@@_talk_opacity_save:,} |
| 155 |
% \mbox{} |
| 156 |
% \begin{macrocode} |
| 157 |
\cs_new_protected_nopar:Npn \@@_talk_opacity_save: |
| 158 |
{ |
| 159 |
\seq_gset_eq:NN \g_@@_talk_opacity_saved_seq \g_@@_talk_opacity_seq |
| 160 |
\seq_get:NN \g_@@_talk_opacity_seq \l_@@_talk_opacity_tl |
| 161 |
\exp_args:NV \tl_if_eq:NNTF \l_@@_talk_opacity_tl \q_no_value |
| 162 |
{ |
| 163 |
\seq_gpush:Nn \g_@@_talk_opacity_saved_seq {1} |
| 164 |
\opacity_select:n {1} |
| 165 |
} { |
| 166 |
\seq_gpush:NV \g_@@_talk_opacity_saved_seq \l_@@_talk_opacity_tl |
| 167 |
\opacity_select:V \l_@@_talk_opacity_tl |
| 168 |
} |
| 169 |
} |
| 170 |
% \end{macrocode} |
| 171 |
% \end{fn} |
| 172 |
% \begin{fn}{\@@_talk_opacity_restore:,} |
| 173 |
% \mbox{} |
| 174 |
% \begin{macrocode} |
| 175 |
\cs_new_protected_nopar:Npn \@@_talk_opacity_restore: |
| 176 |
{ |
| 177 |
\seq_gpop:NN \g_@@_talk_opacity_saved_seq \l_@@_talk_opacity_tl |
| 178 |
\opacity_select:V \l_@@_talk_opacity_tl |
| 179 |
\seq_gset_eq:NN \g_@@_talk_opacity_seq \g_@@_talk_opacity_saved_seq |
| 180 |
} |
| 181 |
% \end{macrocode} |
| 182 |
% \end{fn} |
| 183 |
% \begin{macro}{\mmzSingleExternDriver} |
| 184 |
% Redefine driver |
| 185 |
% Even if this does not have an internal name, the redefinition uses internals in spades \dots. |
| 186 |
% We could define a new one \& I guess that's what should be done \dots |
| 187 |
% \begin{macrocode} |
| 188 |
\long\def\mmzSingleExternDriver#1{ |
| 189 |
\xtoksapp\mmzCCMemo{\mmz@maybe@quitvmode} |
| 190 |
\setbox\mmz@box\mmz@capture{ |
| 191 |
\@@_talk_opacity_save: |
| 192 |
#1 |
| 193 |
\@@_talk_opacity_restore: |
| 194 |
} |
| 195 |
\mmzExternalizeBox\mmz@box\mmz@temptoks |
| 196 |
\xtoksapp\mmzCCMemo{\the\mmz@temptoks} |
| 197 |
\mmz@maybe@quitvmode\box\mmz@box |
| 198 |
} |
| 199 |
% \end{macrocode} |
| 200 |
% \end{macro} |
| 201 |
% The code below is iffy, I guess, since the begin/end thing here is rather illusory \dots |
| 202 |
% \begin{macrocode} |
| 203 |
\hook_gset_rule:nnnn {begindocument} {ltx-talk} {<} {.} |
| 204 |
\hook_gput_code_with_args:nnn {cmd/opacity_select:n/before} {.} |
| 205 |
{ |
| 206 |
\seq_gpush:Nn \g_@@_talk_opacity_seq {#1} |
| 207 |
} |
| 208 |
\hook_gput_code:nnn {cmd/opacity_end:/after}{.} |
| 209 |
{ |
| 210 |
%<debug> \@@_debug:n{Opacity~after} |
| 211 |
\seq_gpop:NN \g_@@_talk_opacity_seq \l_tmpa_tl |
| 212 |
%<debug> \seq_log:N \g_@@_talk_opacity_seq |
| 213 |
} |
| 214 |
\mmzset{ |
| 215 |
at~begin~memoization={ |
| 216 |
\socket_use:n {mmzx/talk/memoization/begin} |
| 217 |
}, |
| 218 |
at~end~memoization={ |
| 219 |
\socket_use:n {mmzx/talk/memoization/end} |
| 220 |
}, |
| 221 |
per~overlay/.style={ |
| 222 |
/mmz/context={ |
| 223 |
overlay=\csname theslide\endcsname, |
| 224 |
pauses=\ifmemoizing |
| 225 |
\mmzxTalkPauses |
| 226 |
\else |
| 227 |
\expandafter\the\csname c@pauses\endcsname |
| 228 |
\fi |
| 229 |
}, |
| 230 |
/utils/exec={ |
| 231 |
\str_if_eq:eeF {peroverlay} |
| 232 |
{\@@_socket_assigned_plug:n {mmzx/talk/memoization/begin}} |
| 233 |
{ |
| 234 |
\socket_assign_plug:nn {mmzx/talk/memoization/begin}{peroverlay} |
| 235 |
\socket_assign_plug:nn {mmzx/talk/memoization/end}{peroverlay} |
| 236 |
% \end{macrocode} |
| 237 |
% This is required to allow per overlay to be used in the options for |
| 238 |
% \env{tikzpicture}s etc. |
| 239 |
% \begin{macrocode} |
| 240 |
\legacy_if:nT {memoizing} { |
| 241 |
\socket_use:n {mmzx/talk/memoization/begin} |
| 242 |
} |
| 243 |
} |
| 244 |
}, |
| 245 |
% \end{macrocode} |
| 246 |
% Is resetting the style meant to prevent duplication in memos etc.? |
| 247 |
% Because it obviously won't \dots? |
| 248 |
% \begin{macrocode} |
| 249 |
/mmz/per~overlay/.code={}, |
| 250 |
}, |
| 251 |
} |
| 252 |
% \end{macrocode} |
| 253 |
% \begin{socket}{mmzx/talk/memoization/begin,mmzx/talk/memoization/end} |
| 254 |
% \changes{v0.3}{2026-03-05}{Use sockets to try to keep memos cleaner.} |
| 255 |
% Sockets. |
| 256 |
% \begin{macrocode} |
| 257 |
\socket_new:nn {mmzx/talk/memoization/begin}{0} |
| 258 |
\socket_new:nn {mmzx/talk/memoization/end}{0} |
| 259 |
% \end{macrocode} |
| 260 |
% \end{socket} |
| 261 |
% \begin{plug}{mmzx/talk/memoization/begin~peroverlay,mmzx/talk/memoization/end~peroverlay} |
| 262 |
% \changes{v0.3}{2026-03-05}{What is a socket without a plug?} |
| 263 |
% Plugs. |
| 264 |
% \begin{macrocode} |
| 265 |
\socket_new_plug:nnn {mmzx/talk/memoization/begin}{peroverlay} |
| 266 |
{ |
| 267 |
%<debug> \@@_debug:n {Executing~plug~peroverlay~in~socket~ |
| 268 |
%<debug> mmzx/talk/memoization/begin.} |
| 269 |
\xdef\mmzxTalkPauses{ |
| 270 |
\int_to_arabic:n {\g_@@_talk_pauses_int} |
| 271 |
} |
| 272 |
\xtoksapp\mmzCMemo{ |
| 273 |
\noexpand\mmzxSetTalkOverlays{\mmzxTalkPauses}{ |
| 274 |
\int_to_arabic:n {\g_@@_talk_slide_int} |
| 275 |
} |
| 276 |
} |
| 277 |
\gtoksapp\mmzCCMemo{ |
| 278 |
\only<all:\mmzxTalkOverlays>{} |
| 279 |
} |
| 280 |
\seq_get:NNTF \g_@@_talk_opacity_seq \l_@@_opacity_tl |
| 281 |
{ |
| 282 |
\fp_gset:NV \l_@@_tmpa_fp \l_@@_opacity_tl |
| 283 |
} { |
| 284 |
\fp_gset:Nn \l_@@_tmpa_fp {1} |
| 285 |
} |
| 286 |
\xtoksapp\mmzContextExtra{ |
| 287 |
opacity=\fp_to_decimal:N \l_@@_tmpa_fp |
| 288 |
} |
| 289 |
} |
| 290 |
\socket_new_plug:nnn {mmzx/talk/memoization/end}{peroverlay} |
| 291 |
{ |
| 292 |
%<debug> \@@_debug:n {Executing~plug~peroverlay~in~socket~ |
| 293 |
%<debug> mmzx/talk/memoization/end.} |
| 294 |
\xtoksapp\mmzCCMemo{ |
| 295 |
\exp_not:N \setcounter{pauses} |
| 296 |
{\int_to_arabic:n {\g_@@_talk_pauses_int}} |
| 297 |
} |
| 298 |
} |
| 299 |
% \end{macrocode} |
| 300 |
% \end{plug} |
| 301 |
% ^^A % \begin{fn}{\@@_talk_per_overlay_begin:, |
| 302 |
% ^^A % \@@_talk_per_overlay_end:, |
| 303 |
% ^^A % \@@_talk_per_overlay_end:, |
| 304 |
% ^^A % } |
| 305 |
% ^^A % \changes{v0.3}{2026-03-05}{This isn't done for \pkg{beamer}, but try to streamline memos.} |
| 306 |
% ^^A % Not done for \pkg{beamer} and not technically required, but keeps the memos and hooks a bit cleaner. |
| 307 |
% ^^A % \begin{macrocode} |
| 308 |
% ^^A \cs_new_nopar:Npn \@@_talk_per_overlay: |
| 309 |
% ^^A { |
| 310 |
% ^^A } |
| 311 |
% ^^A % \end{macrocode} |
| 312 |
% ^^A % \end{fn} |
| 313 |
% \begin{macro}{\mmzxSetTalkOverlays} |
| 314 |
% Note the addition of code to set \verb|g__talk_slide_continue_bool|. |
| 315 |
% This isn't necessary for \pkg{beamer} and is not ‘allowed’ for \pkg{ltx-talk}, but is necessary for frames with overlay specifications in memoized content. |
| 316 |
% \begin{macrocode} |
| 317 |
\cs_new_nopar:Npn \mmzxSetTalkOverlays#1#2{ |
| 318 |
%<debug> \@@_debug:e {Executing~\cs_to_str:N \mmzxSetTalkOverlays} |
| 319 |
\int_compare:nNnTF {\g_@@_talk_pauses_int} = {#1} |
| 320 |
{ |
| 321 |
\gdef\mmzxTalkOverlays{#2} |
| 322 |
\int_compare:nNnTF {\g_@@_talk_slide_int} < {#2} |
| 323 |
{ |
| 324 |
\bool_set_true:N \l_@@_tmpa_bool |
| 325 |
}{ |
| 326 |
\bool_set_false:N \l_@@_tmpa_bool |
| 327 |
} |
| 328 |
}{ |
| 329 |
\bool_set_true:N \l_@@_tmpa_bool |
| 330 |
} |
| 331 |
\bool_if:NT \l_@@_tmpa_bool |
| 332 |
{ |
| 333 |
\bool_gset_true:N \g__talk_slide_continue_bool |
| 334 |
\appto\mmzAtBeginMemoization{ |
| 335 |
\gtoksapp\mmzCMemo{\mmzxSetTalkOverlays{#1}{#2}} |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
% \end{macrocode} |
| 340 |
% \end{macro} |
| 341 |
% \begin{macrocode} |
| 342 |
} |
| 343 |
% \end{macrocode} |
| 344 |
%</sty> |
| 345 |
% |
| 346 |
%\Finale |
| 347 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 348 |
%^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>: |