| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: ltx-talk-frame-structure.dtx Copyright (C) 2025,2026 Joseph Wright |
| 4 |
% |
| 5 |
% It may be distributed and/or modified under the conditions of the |
| 6 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 7 |
% license or (at your option) any later version. The latest version |
| 8 |
% of this license is in the file |
| 9 |
% |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% This file is part of the "ltx-talk bundle" (The Work in LPPL) |
| 13 |
% and all files in that bundle must be distributed together. |
| 14 |
% |
| 15 |
% The released version of this bundle is available from CTAN. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/josephwright/ltx-talk |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
% ----------------------------------------------------------------------- |
| 26 |
% |
| 27 |
%<*driver> |
| 28 |
\documentclass{l3doc} |
| 29 |
% Additional commands needed in this source |
| 30 |
\NewDocumentCommand\email{m}{\href{mailto:#1}{\nolinkurl{#1}}} |
| 31 |
\begin{document} |
| 32 |
\DocInput{\jobname.dtx} |
| 33 |
\end{document} |
| 34 |
%</driver> |
| 35 |
% \fi |
| 36 |
% |
| 37 |
% ^^A As we are dealing with a class, this has to be done manually |
| 38 |
% \def\filedate{2026-04-30} |
| 39 |
% \def\fileversion{v0.5.0} |
| 40 |
% |
| 41 |
% \title{^^A |
| 42 |
% \pkg{ltx-talk-frame} -- The structure of frames^^A |
| 43 |
% \thanks{This file describes \fileversion, |
| 44 |
% last revised \filedate.}^^A |
| 45 |
% } |
| 46 |
% |
| 47 |
% \author{^^A |
| 48 |
% Joseph Wright^^A |
| 49 |
% \thanks{^^A |
| 50 |
% E-mail: \email{[email protected]}^^A |
| 51 |
% }^^A |
| 52 |
% } |
| 53 |
% |
| 54 |
% \date{Released \filedate} |
| 55 |
% |
| 56 |
% \maketitle |
| 57 |
% |
| 58 |
% \begin{documentation} |
| 59 |
% |
| 60 |
% \end{documentation} |
| 61 |
% |
| 62 |
% \begin{implementation} |
| 63 |
% |
| 64 |
% \section{\pkg{ltx-talk-frame-structure} implementation} |
| 65 |
% |
| 66 |
% Start the \pkg{DocStrip} guards. |
| 67 |
% \begin{macrocode} |
| 68 |
%<*class> |
| 69 |
% \end{macrocode} |
| 70 |
% |
| 71 |
% Identify the internal prefix. |
| 72 |
% \begin{macrocode} |
| 73 |
%<@@=talk> |
| 74 |
% \end{macrocode} |
| 75 |
% |
| 76 |
% \subsection{Columns} |
| 77 |
% |
| 78 |
% \begin{macrocode} |
| 79 |
\keys_define:nn { talk } |
| 80 |
{ columns .inherit:n = talk / column } |
| 81 |
% \end{macrocode} |
| 82 |
% |
| 83 |
% \begin{variable}{\l_@@_columns_wd_tl} |
| 84 |
% We store the requested width for columns in a \texttt{tl} as this means |
| 85 |
% that the key value will make sense even if it depends on the current |
| 86 |
% \cs{textwidth}. |
| 87 |
% \begin{macrocode} |
| 88 |
\keys_define:nn { talk / columns } |
| 89 |
{ width .tl_set:N = \l_@@_columns_wd_tl } |
| 90 |
\keys_set:nn { talk / columns } |
| 91 |
{ width = \textwidth } |
| 92 |
% \end{macrocode} |
| 93 |
% \end{variable} |
| 94 |
% |
| 95 |
% \begin{variable}{\l_@@_column_int, \g_@@_column_int} |
| 96 |
% For tracking which column we are in, and allowing for nesting. |
| 97 |
% \begin{macrocode} |
| 98 |
\int_new:N \l_@@_column_int |
| 99 |
\int_new:N \g_@@_column_int |
| 100 |
% \end{macrocode} |
| 101 |
% \end{variable} |
| 102 |
% |
| 103 |
% \begin{environment}{columns} |
| 104 |
% Columns are block-like environments so we start and end with a \cs{par} to |
| 105 |
% ensure correct tagging. |
| 106 |
% \begin{macrocode} |
| 107 |
\NewDocumentEnvironment { columns } { D <> { all } O { } } |
| 108 |
{ |
| 109 |
\@@_action_begin:n {#1} |
| 110 |
\par |
| 111 |
\int_set_eq:NN \l_@@_column_int \g_@@_column_int |
| 112 |
\int_gzero:N \g_@@_column_int |
| 113 |
\keys_set:nn { talk / columns } {#2} |
| 114 |
\hbox_set_to_wd:Nnw \l_@@_tmp_box { \l_@@_columns_wd_tl } |
| 115 |
\dim_set:Nn \textwidth { \l_@@_columns_wd_tl } |
| 116 |
\dim_set_eq:NN \columnwidth \textwidth |
| 117 |
\ignorespaces |
| 118 |
} |
| 119 |
{ |
| 120 |
\unskip |
| 121 |
\hbox_set_end: |
| 122 |
\box_use_drop:N \l_@@_tmp_box |
| 123 |
\int_gset_eq:NN \g_@@_column_int \l_@@_column_int |
| 124 |
\par |
| 125 |
\@@_action_end: |
| 126 |
} |
| 127 |
% \end{macrocode} |
| 128 |
% \end{environment} |
| 129 |
% |
| 130 |
% \begin{variable}{\l_@@_column_alignment_tl} |
| 131 |
% \begin{macrocode} |
| 132 |
\keys_define:nn { talk / column } |
| 133 |
{ |
| 134 |
b .meta:n = |
| 135 |
{ vertical-alignment = bottom } , |
| 136 |
b .value_forbidden:n = true , |
| 137 |
c .meta:n = |
| 138 |
{ vertical-alignment = center } , |
| 139 |
c .value_forbidden:n = true , |
| 140 |
t .meta:n = |
| 141 |
{ vertical-alignment = top } , |
| 142 |
t .value_forbidden:n = true , |
| 143 |
vertical-alignment .choices:nn = |
| 144 |
{ bottom , center , top } |
| 145 |
{ |
| 146 |
\tl_set_eq:NN \l_@@_column_alignment_tl |
| 147 |
\l_keys_value_tl |
| 148 |
} |
| 149 |
} |
| 150 |
\tl_new:N \l_@@_column_alignment_tl |
| 151 |
\keys_set:nn { talk / column } |
| 152 |
{ |
| 153 |
vertical-alignment = center |
| 154 |
} |
| 155 |
% \end{macrocode} |
| 156 |
% \end{variable} |
| 157 |
% |
| 158 |
% \begin{macro} |
| 159 |
% { |
| 160 |
% \@@_column_align_bottom:n , |
| 161 |
% \@@_column_align_center:n , |
| 162 |
% \@@_column_align_top:n |
| 163 |
% } |
| 164 |
% Most of this will appear in the kernel in due course. |
| 165 |
% \begin{macrocode} |
| 166 |
\cs_new_protected:Npn \@@_column_align_bottom:n #1 |
| 167 |
{ \vbox:n {#1} } |
| 168 |
\cs_new_protected:Npn \@@_column_align_center:n #1 |
| 169 |
{ |
| 170 |
\check@mathfonts |
| 171 |
\vbox_set:Nn \l_@@_tmp_box {#1} |
| 172 |
\box_set_ht:Nn \l_@@_tmp_box |
| 173 |
{ |
| 174 |
0.5 \box_ht:N \l_@@_tmp_box |
| 175 |
+ 0.5 \box_dp:N \l_@@_tmp_box |
| 176 |
+ ( \l_@@_vcenter_offset_tl ) |
| 177 |
} |
| 178 |
\box_set_dp:Nn \l_@@_tmp_box |
| 179 |
{ |
| 180 |
\box_ht:N \l_@@_tmp_box |
| 181 |
- ( \l_@@_vcenter_offset_tl ) * 2 |
| 182 |
} |
| 183 |
\box_use_drop:N \l_@@_tmp_box |
| 184 |
} |
| 185 |
\cs_new_protected:Npn \@@_column_align_top:n #1 |
| 186 |
{ \vbox_top:n {#1} } |
| 187 |
% \end{macrocode} |
| 188 |
% \end{macro} |
| 189 |
% \begin{variable}{\l_@@_vcenter_offset_tl} |
| 190 |
% Vertical offset based on text mode values: done as a variable \texttt{tl} |
| 191 |
% so that a reset to math mode parameters is possible. |
| 192 |
% \begin{macrocode} |
| 193 |
\tl_new:N \l_@@_vcenter_offset_tl |
| 194 |
\tl_set:Nn \l_@@_vcenter_offset_tl |
| 195 |
{ ( \fontcharht \font `\( - \fontchardp \font `\) ) / 2 } |
| 196 |
% \end{macrocode} |
| 197 |
% \end{variable} |
| 198 |
% |
| 199 |
% \begin{environment}{column} |
| 200 |
% A cut-down version of a minipage: we want to be clear on the semantic |
| 201 |
% meaning. the action is applied inside the box after starting horizontal |
| 202 |
% mode to avoid spacing issues when switching whatsits in and out. |
| 203 |
% \begin{macrocode} |
| 204 |
\NewDocumentEnvironment { column } { D <> { all } O { } m } |
| 205 |
{ |
| 206 |
\par |
| 207 |
\int_gincr:N \g_@@_column_int |
| 208 |
\int_compare:nNnF \g_@@_column_int = 1 |
| 209 |
{ \hfil } |
| 210 |
\keys_set:nn { talk / column } {#2} |
| 211 |
\vbox_set_to_wd:Nnw \l_@@_tmp_box {#3} |
| 212 |
\dim_set:Nn \textwidth {#3} |
| 213 |
\dim_set_eq:NN \columnwidth \textwidth |
| 214 |
\@parboxrestore |
| 215 |
\leavevmode |
| 216 |
\raggedright |
| 217 |
\@@_action_begin:n {#1} |
| 218 |
\ignorespaces |
| 219 |
} |
| 220 |
% \end{macrocode} |
| 221 |
% The \cs{@ignore} here means that any spaces after |\end{column}| are |
| 222 |
% suppressed by a \tn{ignorespaces} inserted by the kernel. The \cs{par} |
| 223 |
% before \cs{@@_action_end:} is needed as the group formed for actions |
| 224 |
% would otherwise trap for example alignment changes. |
| 225 |
% \begin{macrocode} |
| 226 |
{ |
| 227 |
\par |
| 228 |
\@@_action_end: |
| 229 |
\vbox_set_end: |
| 230 |
\use:c { @@_column_align_ \l_@@_column_alignment_tl :n } |
| 231 |
{ \vbox_unpack_drop:N \l_@@_tmp_box } |
| 232 |
\par |
| 233 |
\@ignoretrue |
| 234 |
} |
| 235 |
% \end{macrocode} |
| 236 |
% \end{environment} |
| 237 |
% |
| 238 |
% \subsection{Floats} |
| 239 |
% |
| 240 |
% Well really \enquote{not floats at all} but the idea is clear. |
| 241 |
% |
| 242 |
% \begin{variable}{\l_@@_float_alignment_tl} |
| 243 |
% We only worry about horizontal alignment here. |
| 244 |
% \begin{macrocode} |
| 245 |
\tl_new:N \l_@@_float_alignment_tl |
| 246 |
% \end{macrocode} |
| 247 |
% \end{variable} |
| 248 |
% |
| 249 |
% A bit similar to the current approach to lists: we need a template at |
| 250 |
% the start but a common function at the end. The |float-placement| key is |
| 251 |
% at present just there to allow mopping up of any argument that is given |
| 252 |
% by accident, hence maps to a temporary variable. |
| 253 |
% \begin{macrocode} |
| 254 |
\NewTemplateType { floatenv } { 2 } |
| 255 |
\DeclareTemplateInterface { floatenv } { talk } { 2 } |
| 256 |
{ |
| 257 |
float-placement : tokenlist , |
| 258 |
horizontal-alignment : choice { left , center , right } = left |
| 259 |
} |
| 260 |
\DeclareTemplateCode { floatenv } { talk } { 2 } |
| 261 |
{ |
| 262 |
float-placement = \l_@@_tmp_tl , |
| 263 |
horizontal-alignment = |
| 264 |
{ |
| 265 |
left = \tl_set:Nn \l_@@_float_alignment_tl { flushleft } , |
| 266 |
center = \tl_set:Nn \l_@@_float_alignment_tl { center } , |
| 267 |
right = \tl_set:Nn \l_@@_float_alignment_tl { flushright } |
| 268 |
} |
| 269 |
} |
| 270 |
% \end{macrocode} |
| 271 |
% The use of \cs{@skiphyperreftrue} here is needed as we do not want targets |
| 272 |
% creating for \enquote{floats}. We may need a better interface for this: |
| 273 |
% the switch is essentially internal. The structure role shuffle is needed |
| 274 |
% so that the entire unit is treated as a \texttt{Float} for tagging, but |
| 275 |
% we do not loose other information. |
| 276 |
% \begin{macrocode} |
| 277 |
{ |
| 278 |
\SetTemplateKeys { floatenv } { talk } {#1} |
| 279 |
\begin { minipage } { \columnwidth } |
| 280 |
\use:e |
| 281 |
{ |
| 282 |
\AssignStructureRole { para / semantic } { float } |
| 283 |
\begin { \l_@@_float_alignment_tl } |
| 284 |
\AssignStructureRole{ para / semantic } |
| 285 |
{ \UseStructureName { para / semantic } } |
| 286 |
} |
| 287 |
\cs_set_nopar:Npn \@captype {#2} |
| 288 |
\@skiphyperreftrue |
| 289 |
} |
| 290 |
\DeclareInstance { floatenv } { std } { talk } { horizontal-alignment = left } |
| 291 |
% \end{macrocode} |
| 292 |
% \begin{macro}{\endfloatenv} |
| 293 |
% And the common end function. |
| 294 |
% \begin{macrocode} |
| 295 |
\cs_new_protected:Npn \endfloatenv |
| 296 |
{ |
| 297 |
\exp_args:Ne \end { \l_@@_float_alignment_tl } |
| 298 |
\end { minipage } |
| 299 |
} |
| 300 |
% \end{macrocode} |
| 301 |
% \end{macro} |
| 302 |
% |
| 303 |
% \begin{environment}{figure, table} |
| 304 |
% Unlike \cls{beamer}, we allow for overlays for the environments as a whole. |
| 305 |
% \begin{macrocode} |
| 306 |
\clist_map_inline:nn { figure , table } |
| 307 |
{ |
| 308 |
\NewDocumentEnvironment {#1} { D <> { all } = { float-placement } O { } } |
| 309 |
{ |
| 310 |
\@@_action_begin:n {##1} |
| 311 |
\UseInstance { floatenv } { std } {##2} {#1} |
| 312 |
} |
| 313 |
{ |
| 314 |
\endfloatenv |
| 315 |
\@@_action_end: |
| 316 |
} |
| 317 |
% \end{macrocode} |
| 318 |
% \end{environment} |
| 319 |
% \begin{variable}{\c@figure, \thefigure, \c@table, \thetable} |
| 320 |
% \begin{variable}{\figurename, \tableename} |
| 321 |
% \begin{variable}{\fnum@figure, \fnum@table} |
| 322 |
% The standard variables needed to make captions work (nothing for list |
| 323 |
% of floats, as at present those are not offered). For the \enquote{number}, |
| 324 |
% we currently only show the name: \enquote{floats} in presentations really |
| 325 |
% should not be numbered. |
| 326 |
% \begin{macrocode} |
| 327 |
\newcounter {#1} |
| 328 |
\tl_new:c { #1 name } |
| 329 |
\tl_set:ce { #1 name } { \text_titlecase_first:n {#1} } |
| 330 |
\tl_new:c { fnum@ #1 } |
| 331 |
\tl_set_eq:cc { fnum@ #1 } { #1 name } |
| 332 |
} |
| 333 |
% \end{macrocode} |
| 334 |
% \end{variable} |
| 335 |
% \end{variable} |
| 336 |
% \end{variable} |
| 337 |
% |
| 338 |
% The spacing values needed for the standard function. |
| 339 |
% \begin{macrocode} |
| 340 |
\newlength \abovecaptionskip |
| 341 |
\newlength \belowcaptionskip |
| 342 |
\setlength \abovecaptionskip { 7pt } |
| 343 |
\setlength \belowcaptionskip { 7pt } |
| 344 |
% \end{macrocode} |
| 345 |
% |
| 346 |
% \begin{macro}{\@caption} |
| 347 |
% This is a copy of the kernel version of the function, but with writing to |
| 348 |
% the list of whatever file removed. It is very likely this needs to be |
| 349 |
% reworked as a template, but that will likely come from the kernel. |
| 350 |
% \begin{macrocode} |
| 351 |
\cs_set_protected:Npn \@caption #1 [ #2 ] #3 |
| 352 |
{ |
| 353 |
\par |
| 354 |
\begingroup |
| 355 |
\@parboxrestore |
| 356 |
\if@minipage \@setminipage \fi |
| 357 |
\normalsize |
| 358 |
\@makecaption { \csname fnum@ #1 \endcsname } { \ignorespaces #3 } |
| 359 |
\par |
| 360 |
\endgroup |
| 361 |
} |
| 362 |
% \end{macrocode} |
| 363 |
% \end{macro} |
| 364 |
% |
| 365 |
% \subsection{Footnotes} |
| 366 |
% |
| 367 |
% \begin{variable}{\g_@@_footnote_box} |
| 368 |
% Holds footnotes as they are constructed. |
| 369 |
% \begin{macrocode} |
| 370 |
\box_new:N \g_@@_footnote_box |
| 371 |
% \end{macrocode} |
| 372 |
% \end{variable} |
| 373 |
% |
| 374 |
% \begin{variable}{\g_@@_footnote_overlay_seq} |
| 375 |
% For tracking the overlays to apply. |
| 376 |
% \begin{macrocode} |
| 377 |
\seq_new:N \g_@@_footnote_overlay_seq |
| 378 |
% \end{macrocode} |
| 379 |
% \end{variable} |
| 380 |
% |
| 381 |
% \begin{macro}{\stdfootnote} |
| 382 |
% \begin{macrocode} |
| 383 |
\NewCommandCopy \stdfootnote \footnote |
| 384 |
% \end{macrocode} |
| 385 |
% \end{macro} |
| 386 |
% |
| 387 |
% \begin{macro}{\footnote} |
| 388 |
% Sort-of overlay aware! |
| 389 |
% \begin{macrocode} |
| 390 |
\RenewDocumentCommand \footnote { D <> { all } o +m } |
| 391 |
{ |
| 392 |
\seq_gpush:Nn \g_@@_footnote_overlay_seq {#1} |
| 393 |
\IfNoValueTF {#2} |
| 394 |
{ \stdfootnote {#3} } |
| 395 |
{ \stdfootnote [ {#2} ] {#3} } |
| 396 |
} |
| 397 |
% \end{macrocode} |
| 398 |
% \end{macro} |
| 399 |
% |
| 400 |
% This socket receives all of the footnote content: in the standard setup it |
| 401 |
% would be an insert. Hence this is the best place to grab the entire content. |
| 402 |
% Notice that the footnote rule is only inserted when the box is used, if |
| 403 |
% it turns out it's needed. The overlay code is added here as it needs to be |
| 404 |
% inside the box used to collect the footnotes but around all of the content: |
| 405 |
% currently there's not a \enquote{tighter} place to target. |
| 406 |
% \begin{macrocode} |
| 407 |
\NewSocketPlug { fntext / process } { talk } |
| 408 |
{ |
| 409 |
\vbox_gset:Nn \g_@@_footnote_box |
| 410 |
{ |
| 411 |
\vbox_unpack:N \g_@@_footnote_box |
| 412 |
\seq_gpop_left:NN \g_@@_footnote_overlay_seq |
| 413 |
\l_@@_tmp_tl |
| 414 |
\exp_args:NV \@@_decode_parse:n \l_@@_tmp_tl |
| 415 |
\@@_action_uncover:N \l_@@_decode_overlays_bool |
| 416 |
#1 |
| 417 |
\@@_action_uncover_end:N \l_@@_decode_overlays_bool |
| 418 |
} |
| 419 |
} |
| 420 |
\AssignSocketPlug { fntext / process } { talk } |
| 421 |
% \end{macrocode} |
| 422 |
% |
| 423 |
% \begin{macro}{\@makefntext} |
| 424 |
% Use a copy of the standard setup. |
| 425 |
% \begin{macrocode} |
| 426 |
\cs_new_eq:NN \@makefntext \fnote_makefntext:n |
| 427 |
% \end{macrocode} |
| 428 |
% \end{macro} |
| 429 |
% |
| 430 |
% \begin{macrocode} |
| 431 |
%</class> |
| 432 |
% \end{macrocode} |
| 433 |
% |
| 434 |
% \end{implementation} |
| 435 |
% |
| 436 |
% \PrintIndex |