Debian Codegraph @

texmf-dist/source/latex/ltx-talk/ltx-talk.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: ltx-talk.dtx Copyright (C) 2023-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} -- Overall set up^^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} 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{Set up}
77 %
78 % Identify the package and give the over all version information.
79 % \begin{macrocode}
80 \ProvidesExplClass {ltx-talk} {2026-04-30} {0.5.0}
81 {A class for typesetting presentations}
82 % \end{macrocode}
83 %
84 % Get the right type of message.
85 % \begin{macrocode}
86 \prop_gput:Nnn \g_msg_module_name_prop { talk } { ltx-talk }
87 \prop_gput:Nnn \g_msg_module_type_prop { talk } { Class }
88 % \end{macrocode}
89 %
90 % Require the latest \LaTeX{} structures.
91 % \begin{macrocode}
92 \IfFormatAtLeastF { 2025-11-01 }
93 {
94 \msg_new:nnnn { ltx-talk } { kernel-too-old }
95 { The~ltx-talk~class~requires~LaTeX~2025-11-01~or~later. }
96 {
97 You~have~tried~to~use~the~ltx-talk~class~with~a~LaTeX~kernel~release~
98 prior~to~2025-11-01;~the~required~functionality~is~missing.
99 }
100 \msg_fatal:nn { ltx-talk } { kernel-too-old }
101 }
102 \NeedsDocumentMetadata
103 % \end{macrocode}
104 %
105 % Warn if not an engine that is tested.
106 % \begin{macrocode}
107 \bool_lazy_or:nnF
108 { \sys_if_engine_luatex_p: }
109 { \sys_if_engine_pdftex_p: }
110 {
111 \msg_new:nnn { ltx-talk } { unsupported-engine }
112 {
113 The~engine~"\c_sys_engine_str"~
114 is~not~supported~by~the~ltx-talk~class.
115 }
116 \msg_warning:nn { ltx-talk } { unsupported-engine }
117 }
118 % \end{macrocode}
119 %
120 % \subsection{Additions for \pkg{expl3}}
121 %
122 % Like \cs{vcoffin_set:Nnn}, so should be an easy enough addition.
123 % \begin{macrocode}
124 \cs_gset_protected:Npn \vbox_set_to_wd:Nnn #1#2#3
125 {
126 \tex_setbox:D #1 \tex_vbox:D
127 {
128 \tex_hsize:D \__box_dim_eval:n {#2}
129 \color_group_begin: #3 \par \color_group_end:
130 }
131 \box_dp:N #1 \__box_dim_eval:n {#2}
132 }
133 \cs_gset_protected:Npn \vbox_set_to_wd:Nnw #1#2
134 {
135 \cs_set_protected:Npn \__box_set_to_wd:
136 { \box_wd:N #1 \__box_dim_eval:n {#2} }
137 \tex_setbox:D #1 \tex_vbox:D
138 \c_group_begin_token
139 \tex_hsize:D \__box_dim_eval:n {#2}
140 \group_insert_after:N \__box_set_to_wd:
141 \color_group_begin:
142 }
143 % \end{macrocode}
144 %
145 % Some things from \pkg{xbox} that would be useful.
146 % \begin{macrocode}
147 \cs_gset_protected:Npn \rule:nnn #1#2#3
148 {
149 \tex_vrule:D
150 height \dim_eval:n {#2} \exp_stop_f:
151 depth \dim_eval:n {#3} \exp_stop_f:
152 width \dim_eval:n {#1} \exp_stop_f:
153 \scan_stop:
154 }
155 % \end{macrocode}
156 %
157 % Some extensions are needed to opacity support: this should only be here for a
158 % short period.
159 % \begin{macrocode}
160 \cs_gset_protected:Npn \opacity_begin:n #1
161 { \__opacity_select:nN {#1} \__opacity_backend_begin:n }
162 \cs_gset_protected:Npn \opacity_end:
163 { \__opacity_backend_end: }
164 \AddToHook { begindocument }
165 {
166 \cs_gset_protected:Npe \__opacity_backend_begin:n #1
167 {
168 \bool_lazy_any:nTF
169 {
170 { \sys_if_engine_pdftex_p: }
171 { \sys_if_engine_luatex_p: }
172 { \sys_if_engine_xetex_p: }
173 }
174 {
175 \tl_set:Nn \exp_not:N \l__opacity_backend_fill_tl {#1}
176 \tl_set:Nn \exp_not:N \l__opacity_backend_stroke_tl {#1}
177 \pdfmanagement_add:nnn { Page / Resources / ExtGState }
178 { opacity #1 }
179 { << /ca ~ #1 /CA ~ #1 >> }
180 \sys_if_engine_xetex:TF
181 { \__kernel_backend_literal_pdf:n }
182 {
183 \__kernel_color_backend_stack_push:nn
184 \exp_not:N \c__opacity_backend_stack_int
185 }
186 { /opacity #1 ~ gs }
187 }
188 {
189 \__opacity_backend:nnn {#1} { fill } { ca }
190 \__opacity_backend:nnn {#1} { stroke } { ca }
191 }
192 }
193 \cs_gset_protected:Npe \__opacity_backend_end:
194 {
195 \bool_lazy_any:nTF
196 {
197 { \sys_if_engine_pdftex_p: }
198 { \sys_if_engine_luatex_p: }
199 { \sys_if_engine_xetex_p: }
200 }
201 { \__opacity_backend_reset: }
202 {
203 \__opacity_backend_reset_fill:
204 \__opacity_backend_reset_stroke:
205 }
206 }
207 }
208 % \end{macrocode}
209 %
210 % \subsection{Extra variants}
211 %
212 % \begin{macrocode}
213 \cs_generate_variant:Nn \clist_set:Nn { cv }
214 \cs_generate_variant:Nn \hook_gput_code:nnn { nne }
215 \exp_args_generate:n { nVv }
216 \cs_generate_variant:Nn \color_select:n { V }
217 \cs_generate_variant:Nn \dim_compare:nNnTF { v }
218 \cs_generate_variant:Nn \dim_compare_p:nNn { vNv }
219 \cs_generate_variant:Nn \dim_max:nn { v }
220 \cs_generate_variant:Nn \str_replace_all:Nnn { NnV }
221 \cs_generate_variant:Nn \text_purify:n { v }
222 \cs_generate_variant:Nn \vbox_to_ht:nn { v }
223 % \end{macrocode}
224 %
225 % \subsection{Scratch space}
226 %
227 % \begin{macro}{\@@_tmp:w}
228 % For one-off processing.
229 % \begin{macrocode}
230 \cs_new_protected:Npn \@@_tmp:w { }
231 % \end{macrocode}
232 % \end{macro}
233 %
234 % \begin{variable}{\l_@@_tmp_box}
235 % \begin{macrocode}
236 \box_new:N \l_@@_tmp_box
237 % \end{macrocode}
238 % \end{variable}
239 %
240 % \begin{variable}{\l_@@_tmp_tl}
241 % \begin{macrocode}
242 \tl_new:N \l_@@_tmp_tl
243 % \end{macrocode}
244 % \end{variable}
245 %
246 % \subsection{Option handling}
247 %
248 % \begin{variable}
249 % {
250 % \l_@@_aspect_ratio_str ,
251 % \l_@@_fontsize_dim ,
252 % \l_@@_frame_title_bool ,
253 % \l_@@_mode_str
254 % }
255 % \begin{macrocode}
256 \keys_define:nn { talk }
257 {
258 aspect-ratio .str_set:N =
259 \l_@@_aspect_ratio_str ,
260 font-size .dim_set:N =
261 \l_@@_fontsize_dim ,
262 frame-title-arg .bool_set:N =
263 \l_@@_frame_title_bool ,
264 handout .code:n =
265 { \str_set:Nn \l_@@_mode_str { handout } } ,
266 handout .value_forbidden:n = true ,
267 mode .choices:nn =
268 { handout , projector }
269 { \str_set:NV \l_@@_mode_str \l_keys_choice_tl }
270 }
271 \str_new:N \l_@@_mode_str
272 % \end{macrocode}
273 % \end{variable}
274 %
275 % Scope for options.
276 % \begin{macrocode}
277 \keys_define:nn { talk }
278 {
279 aspect-ratio .usage:n = load ,
280 font-size .usage:n = load ,
281 frame-title-arg .usage:n = load ,
282 mode .usage:n = load
283 }
284 % \end{macrocode}
285 %
286 % Compatibility keys for classical font size setting.
287 % \begin{macrocode}
288 \clist_map_inline:nn { 10pt , 11pt , 12pt }
289 {
290 \keys_define:nn { talk }
291 {
292 #1 .meta:n = { font-size = #1 } ,
293 #1 .value_forbidden:n = true ,
294 #1. usage:n = load
295 }
296 }
297 % \end{macrocode}
298 %
299 % Initial values.
300 % \begin{macrocode}
301 \keys_set:nn { talk }
302 {
303 aspect-ratio = 16:9 ,
304 font-size = 11pt ,
305 frame-title-arg = false ,
306 mode = projector
307 }
308 % \end{macrocode}
309 %
310 % \begin{macrocode}
311 \ProcessKeyOptions [ talk ]
312 % \end{macrocode}
313 %
314 % \subsection{Setting up}
315 %
316 % Load the font size setup if available, otherwise fall back on scaling.
317 % \begin{macrocode}
318 \file_if_exist_input:nF { size \dim_to_decimal:n \l_@@_fontsize_dim .clo }
319 {
320 \file_input:n { size10.clo }
321 \RequirePackage { relsize }
322 \hook_gput_code:nne { begindocument } { talk }
323 { \exp_not:N \relsize { \fp_eval:n { \l_@@_fontsize_dim / 10pt } } }
324 }
325 % \end{macrocode}
326 %
327 % \begin{variable}
328 % {
329 % \c_@@_paper_height_dim ,
330 % \c_@@_paper_width_dim
331 % }
332 % As \pkg{geometry} is being used to set the paper size with no previous
333 % value, we have to use the optional argument rather than waiting to
334 % apply \cs{geometry}.
335 % \begin{macrocode}
336 \dim_const:Nn \c_@@_paper_height_dim { 100mm }
337 \use:e
338 {
339 \cs_set_protected:Npn \exp_not:N \@@_tmp:w
340 #1 \tl_to_str:n { : } #2 \tl_to_str:n { : } #3 \exp_not:N \q_stop
341 {
342 \dim_const:Nn \exp_not:N \c_@@_paper_width_dim
343 {
344 \exp_not:N \fp_to_dim:n
345 { (#1 / #2) * \exp_not:N \c_@@_paper_height_dim }
346 }
347 }
348 \exp_not:N \@@_tmp:w \l_@@_aspect_ratio_str
349 \tl_to_str:n { : } 100 \exp_not:N \q_stop
350 }
351 \use:e
352 {
353 \exp_not:N \RequirePackage
354 [
355 papersize =
356 {
357 \dim_use:N \c_@@_paper_width_dim ,
358 \dim_use:N \c_@@_paper_height_dim
359 } ,
360 tmargin = 10mm ,
361 bmargin = 8mm ,
362 lmargin = 10mm ,
363 rmargin = 10mm ,
364 headheight = 10mm ,
365 headsep = 2mm ,
366 footskip = 6mm
367 ]
368 { geometry }
369 }
370 % \end{macrocode}
371 % \end{variable}
372 %
373 % Turn off justification
374 % \begin{macrocode}
375 \raggedright
376 % \end{macrocode}
377 %
378 % \subsection{Math support}
379 %
380 % We always require \pkg{amsmath}: this is forced anyway by \pkg{unicode-math}
381 % for Lua\TeX{}.
382 % \begin{macrocode}
383 \RequirePackage { amsmath }
384 % \end{macrocode}
385 %
386 % \subsection{Font selection}
387 %
388 % The aim here is to minimize change from the standard font setup but at the
389 % same time provide a sans-serif default. Since \cls{beamer} was released,
390 % better sans-serif math mode fonts have become available. For OpenType
391 % engines,requiring \pkg{(lua-)unicode-math} is the most sensible approach; we
392 % also load \pkg{mathtools} as that has to be before \pkg{unicode-math}. The
393 % New Computer Modern font provides a reasonable initial set of glyphs. It
394 % comes with a wrapper package, but that does various other things: if the user
395 % wants these, they can choose to load themselves. For 8-bit engines, switching
396 % the text font to be sans-serif is easy. For math mode, the
397 % \pkg{sansmathfonts} package does a good job: here, using the package rather
398 % than adjusting directly is the sensible option.
399 % \begin{macrocode}
400 \sys_if_engine_opentype:TF
401 {
402 \RequirePackage { fontspec }
403 \RequirePackage { mathtools }
404 \sys_if_engine_luatex:TF
405 {
406 \RequirePackage { lua-unicode-math }
407 \tagpdfsetup { math / mathml / luamml / load = true }
408 }
409 { \RequirePackage { unicode-math } }
410 \setmainfont { NewCMSans10-Regular.otf }
411 \setsansfont { NewCMSans10-Regular.otf }
412 \setmathfont { NewCMSansMath-Regular.otf }
413 }
414 {
415 \RequirePackage { sansmathfonts }
416 \RequirePackage [ nomath ] { lmodern }
417 \cs_set_eq:NN \rmdefault \sfdefault
418 }
419 % \end{macrocode}
420 %
421 % \subsection{Text scripts}
422 %
423 % Newer kernel releases allow us to use real text sub- and superscripts:
424 % we set up the appropriate data here.
425 %
426 % \begin{macro}
427 % {
428 % \textsubscript@offset ,
429 % \textsubscript@space ,
430 % \textsuperscript@offset ,
431 % \textsuperscript@space
432 % }
433 % Offset values as in Con\TeX{}t, no additional spacing added after
434 % script items.
435 % \begin{macrocode}
436 \cs_set_nopar:Npn \textsubscript@offset { 0.48ex }
437 \cs_set_nopar:Npn \textsubscript@space { }
438 \cs_set_nopar:Npn \textsuperscript@offset { 0.86ex }
439 \cs_set_nopar:Npn \textsuperscript@space { }
440 % \end{macrocode}
441 % \end{macro}
442 %
443 % \subsection{Hyperlinks}
444 %
445 % \begin{variable}{\thepage}
446 % We define \cs{thepage} here: this is checked for by \pkg{hyperref} so has
447 % to come early.
448 % \begin{macrocode}
449 \cs_new:Npn \thepage { \@arabic \c@page }
450 % \end{macrocode}
451 % \end{variable}
452 %
453 % A requirement.
454 % \begin{macrocode}
455 \RequirePackage { hyperref }
456 \hypersetup { hidelinks }
457 % \end{macrocode}
458 %
459 % \subsection{Tagging}
460 %
461 % We need to extend the standard tagging model to work with slides and so on.
462 % \begin{macrocode}
463 \tagpdfsetup
464 {
465 role / user-NS = ltx-talk ,
466 role / new-tag = frame / Sect ,
467 role / new-tag = frametitle / H4
468 }
469 % \end{macrocode}
470 %
471 % \begin{macrocode}
472 %</class>
473 % \end{macrocode}
474 %
475 % \end{implementation}
476 %
477 % \PrintIndex