Debian Codegraph @

texmf-dist/source/latex/notebeamer/notebeamer.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: notebeamer.dtx
4 % -----------------------------------------------------------------------
5 % Copyright (C) 2023-2026 by Mingyu Xia <[email protected]> *
6 % -----------------------------------------------------------------------
7 % This work may be distributed and/or modified under the conditions *
8 % of the LaTeX Project Public License (LPPL), either version 1.3c of *
9 % this license or (at your option) any later version. *
10 % The latest version of this license is in *
11 % *
12 % http://www.latex-project.org/lppl.txt *
13 % *
14 % and version 1.3c or later is part of all distributions of LaTeX *
15 % version 2008 or later. *
16 % *
17 % This work has the LPPL maintenance status `maintained'. *
18 % *
19 % The Current Maintainer of this work is Mingyu Xia. *
20 % -----------------------------------------------------------------------
21 % This work consists of the files notebeamer.dtx, *
22 % notebeamer.ins, *
23 % the derived files notebeamer.sty, *
24 % the documentation files notebeamer.pdf, *
25 % and README.md. *
26 % -----------------------------------------------------------------------
27 % *
28 % Any modification of this file should ensure that the copyright and *
29 % license information is placed in the derived files. *
30 % *
31 % -----------------------------------------------------------------------
32 %
33 %<*internal>
34 \iffalse
35 %</internal>
36 %
37 %<*readme>
38 [![CTAN Version](https://img.shields.io/ctan/v/notebeamer)](https://ctan.org/pkg/notebeamer)
39 [![GitHub Release](https://img.shields.io/github/v/release/myhsia/notebeamer)](https://github.com/myhsia/notebeamer/releases/latest)
40 [![GitHub Last Commit](https://img.shields.io/github/last-commit/myhsia/notebeamer)](https://github.com/myhsia/notebeamer/commits)
41 [![Actions Status](https://github.com/myhsia/notebeamer/workflows/Automated%20testing/badge.svg)](https://github.com/myhsia/notebeamer/actions)
42 [![GitHub Repo stars](https://img.shields.io/github/stars/myhsia/notebeamer)](https://github.com/myhsia/notebeamer)
43
44 The `notebeamer` Package
45 ========================
46
47 The `notebeamer` package provides a method for inputting slides on note
48 papers quickly.
49
50 Overview
51 --------
52
53 The package provides the `\includebeamer` macro
54
55 \includebeamer [<keys>] {<filename>} [<keys>]
56
57 to set the format that how the slides is arranged on note papers.
58
59 See `notebeamer.pdf` for more. Happy TeXing!
60
61 Issues
62 ------
63
64 The issue tracker for `notebeamer` is currently located
65 [on GitHub](https://github.com/myhsia/notebeamer/issues).
66
67 Build status
68 ------------
69
70 This project uses [GitHub Actions](https://github.com/features/actions)
71 as a hosted continuous integration service. For each commit, the build status
72 is tested using the current release of TeX Live.
73
74 _Current build status:_ ![build status](https://github.com/myhsia/notebeamer/actions/workflows/main.yaml/badge.svg?branch=main)
75
76 Copyright and License
77 ---------------------
78
79 Copyright (C) 2023-2026 by Mingyu Xia \<[email protected]\>
80
81 This work may be distributed and/or modified under the conditions
82 of the LaTeX Project Public License (LPPL), either version 1.3c of
83 this license or (at your option) any later version.
84 The latest version of this license is in
85
86 http://www.latex-project.org/lppl.txt
87
88 and version 1.3c or later is part of all distributions of LaTeX
89 version 2008 or later.
90
91 This work has the LPPL maintenance status `maintained'.
92
93 The Current Maintainer of this work is **Mingyu Xia**.
94 %</readme>
95 %
96 %<*internal>
97 \fi
98 %</internal>
99 %
100 %<*driver>
101 \documentclass[svgnames]{l3doc}
102 \usepackage{notebeamer, pdfpages}
103 \usepackage[osf, mono = false]{libertine}
104 \ExplSyntaxOn \makeatletter
105 \newcommand \mail[1]{\href{mailto:#1}{\ttfamily #1}}
106 \DeclareDocumentCommand \key { s m }
107 {
108 \IfBooleanTF {#1} { \textcolor{red}{\ttfamily \bfseries #2} }
109 {
110 \group_begin: \ttfamily
111 \seq_set_from_clist:Nn \l_tmpa_seq {#2}
112 \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
113 { \exp_not:n { \textcolor{red}{\bfseries ##1} } }
114 \seq_use:Nn \l_tmpb_seq { ,~ } \:=\:
115 \group_end:
116 }
117 }
118 \DeclareCommandCopy \val \meta
119 \def \TTF {\textup{\textbf{true}\makebox[0pt][r]{^^A
120 \underline {\phantom{\bfseries true}\kern-0.1em}}\textbar}false}
121 \def \TFF {true\textup{\textbar\textbf{false}\makebox[0pt][r]{^^A
122 \underline {\phantom{\bfseries false}\kern-0.1em}}}}
123 \makeatother \ExplSyntaxOff
124 \newlist{keyval}{itemize}{10}
125 \setlist[keyval]{leftmargin = 0pt, labelsep = 0pt}
126 \makeindex
127 \begin{document}
128 \DocInput{\jobname.dtx}
129 \end{document}
130 %</driver>
131 % \fi
132 %
133 % \title{^^A
134 % The \pkg{notebeamer} Package\thanks{^^A
135 % \url{https://github.com/myhsia/notebeamer},
136 % \url{https://ctan.org/pkg/notebeamer}^^A
137 % }^^A
138 % }
139 %
140 % \author{Mingyu Xia\thanks{\mail{[email protected]}}}
141 %
142 % \date{Released 2026-02-07\quad \texttt{v4.6A}}
143 %
144 % \maketitle
145 %
146 % \begin{documentation}
147 %
148 % \section{Introduction}
149 %
150 % The \pkg{notebeamer} package provides an easy way to print slides on note
151 % pages quickly, developed by \pkg{expl3} based on \pkg{tikz}.
152 % It supports various compilation methods, such as
153 % \hologo{pdfLaTeX}, \hologo{XeLaTeX}, \hologo{ApLaTeX}, \hologo{LuaLaTeX}, etc.
154 %
155 % \section{Usage}
156 %
157 % To load this package, write the line
158 % \begin{quote}
159 % |\usepackage{notebeamer}|
160 % \end{quote}
161 %
162 % \begin{function}{\includebeamer}
163 % \begin{syntax}
164 % \cs{includebeamer} \oarg{keyvals} \marg{filename} \oarg{keyvals}
165 % \end{syntax}
166 % The \cs{includebeamer} command can create pages with note lines, and import
167 % the specific pages of the \file{.pdf} file on the left side of the note
168 % pages. The mandatory argument can set the \file{.pdf} file that will be
169 % inserted. The optional argument accepts the following keys
170 % \begin{keyval}
171 % \item [\key{color}] \val{str} can set the note lines' color
172 % (Default: black), this key's name could be omitted.
173 % \item [\key{ratio}] \val{fp num} can set imported slides' ratio and empty
174 % area's width (Default: |0.5|).
175 % \item [\key{sep}] \val{dim} can set the vertical space between slides
176 % (Default: |2ex|).
177 % \item [\key{nup}] \val{int} can set the number of slides on every page
178 % (Default: |3|).
179 % \item [\key{pages}] \val{comma-separated list} can select pages to insert.
180 % The list could contain ranges of page numbers.
181 % (Default: |1|).
182 % \item [\key{lines}] \val{int} can set the number of lines on every page.
183 % \item [\key{lineno}] \val{\TFF} can set whether to show the line numbers
184 % (Default: |false|).
185 % \item [\key{lhead, rhead}] \val{str} can set the left / right header of
186 % the pages.
187 % \end{keyval}
188 % \end{function}
189 %
190 % \section{Working Example}
191 %
192 % Macros like \cs[no-index]{newgeometry}, and \cs[no-index]{pagecolor}, etc.,
193 % could be used for assistance.
194 %
195 % \verbatiminput{notebeamer-demo.tex}
196 % \noindent
197 % The effect of the above example is exhibited on the next page.
198 %
199 % \includepdf[pages = -, nup = 2x2, frame]{notebeamer-demo.pdf}
200 %
201 % \end{documentation}
202 %
203 % \begin{implementation}
204 %
205 % \section{The Source Code}
206 %
207 % \begin{macrocode}
208 %<*package>
209 % \end{macrocode}
210 %
211 % \begin{macrocode}
212 %<@@=ntbm>
213 % \end{macrocode}
214 %
215 % \begin{macrocode}
216 \def \ntbm@date {2026-02-07}
217 \def \ntbm@version {v4.6A}
218 \ProvidesExplPackage {notebeamer} {\ntbm@date} {\ntbm@version}
219 {Package for printing slides on note pages}
220 % \end{macrocode}
221 %
222 % \begin{macrocode}
223 \cs_if_exist:NF \graphics_include:nn { \RequirePackage{l3graphics} }
224 \RequirePackage{tikz, tikzpagenodes}
225 % \end{macrocode}
226 %
227 % \subsection{User's Interface}
228 %
229 % \begin{macro}{\includebeamer}
230 % Define the \cs{includebeamer} command.
231 % \begin{macrocode}
232 \NewDocumentCommand \includebeamer { O{} m O{} }
233 {
234 \group_begin:
235 \keys_set:nn { notebeamer / includebeamer } { #1, #3 }
236 \@@_include_aux:n {#2}
237 \group_end:
238 }
239 % \end{macrocode}
240 % \begin{variable}
241 % {
242 % \l_@@_include_pos_tl, \l_@@_include_color_tl , \l_@@_include_pages_tl,
243 % \l_@@_include_nup_int, \l_@@_include_lines_int, \l_@@_include_ratio_fp,
244 % \l_@@_include_sep_dim, \l_@@_include_lhead_tl, \l_@@_include_rhead_tl
245 % }
246 % Key--value definitions for the \cs{includebeamer} command.
247 % \begin{macrocode}
248 \keys_define:nn { notebeamer / includebeamer }
249 {
250 pos .tl_set:N = \l_@@_include_pos_tl,
251 pos .initial:n = left,
252 color .tl_set:N = \l_@@_include_color_tl,
253 color .initial:n = black,
254 pages .tl_set:N = \l_@@_include_pages_tl,
255 pages .initial:n = 1,
256 nup .int_set:N = \l_@@_include_nup_int,
257 nup .initial:n = 3,
258 lines .int_set:N = \l_@@_include_lines_int,
259 lineno .bool_set:N = \l_@@_include_lineno_bool,
260 lineno .initial:n = false,
261 lineno .default:n = true,
262 ratio .fp_set:N = \l_@@_include_ratio_fp,
263 ratio .initial:n = .5,
264 sep .dim_set:N = \l_@@_include_sep_dim,
265 sep .initial:n = 2ex,
266 lhead .tl_set:N = \l_@@_include_lhead_tl,
267 rhead .tl_set:N = \l_@@_include_rhead_tl,
268 unknown .code:n = \tl_if_novalue:nF {#1}
269 { \tl_set_eq:NN \l_@@_include_color_tl \l_keys_key_tl }
270 }
271 % \end{macrocode}
272 % \end{variable}
273 % \end{macro}
274 %
275 % \subsection{Internal Auxiliary}
276 %
277 % \begin{variable}{\l_@@_nup_dim, \l_@@_include_ratio_dim}
278 % Store the heights and widths of the logical pages in a specific nup.
279 % \begin{macrocode}
280 \dim_new:N \l_@@_nup_dim
281 \dim_new:N \l_@@_include_ratio_dim
282 % \end{macrocode}
283 % \end{variable}
284 % \newpage
285 % \begin{variable}{\l_@@_pages_total_int, \l_@@_pages_residue_int}
286 % Store the number of total physical pages and residue logical pages.
287 % \begin{macrocode}
288 \int_new:N \l_@@_pages_total_int
289 \int_new:N \l_@@_pages_residue_int
290 % \end{macrocode}
291 % \end{variable}
292 %
293 % \begin{variable}{\l_@@_tmpa_clist}
294 % Store the results of \cs{@@_range_to_list:nN}.
295 % \begin{macrocode}
296 \clist_new:N \l_@@_tmpa_clist
297 % \end{macrocode}
298 % \end{variable}
299 %
300 % \begin{macro}{\@@_include_aux:n}
301 % Define the auxiliary command for \cs{includebeamer}.
302 % \begin{macrocode}
303 \cs_new_protected_nopar:Npn \@@_include_aux:n #1
304 {
305 \graphics_get_pagecount:nN {#1} \l_@@_include_filepages_int
306 \dim_set:Nn \l_@@_nup_dim { \textheight/\l_@@_include_nup_int }
307 \dim_set:Nn \l_@@_include_ratio_dim
308 { \fp_use:N \l_@@_include_ratio_fp \textwidth }
309 \tl_if_eq:NnTF \l_@@_include_pages_tl { - }
310 {
311 \@@_range_to_list:nN
312 { 1 - \l_@@_include_filepages_int } \l_@@_tmpa_clist
313 }
314 {
315 \exp_args:NV \@@_range_to_list:nN
316 { \l_@@_include_pages_tl } \l_@@_tmpa_clist
317 }
318 \int_set:Nn \l_@@_pages_total_int
319 {
320 \fp_eval:n
321 { ceil
322 ( \clist_count:N \l_@@_tmpa_clist/
323 \l_@@_include_nup_int, 0
324 ) - 1
325 }
326 }
327 \int_set:Nn \l_@@_pages_residue_int
328 {
329 \int_eval:n
330 {
331 \clist_count:N \l_@@_tmpa_clist -
332 \l_@@_include_nup_int * \l_@@_pages_total_int
333 }
334 }
335 \int_step_inline:nn { \int_use:N \l_@@_pages_total_int }
336 {
337 \clearpage
338 \@@_empty_note_aux:
339 \int_step_inline:nn { \l_@@_include_nup_int }
340 {
341 \tikz [ remember~picture, overlay ]
342 \node [ xshift = \l_@@_include_ratio_dim/2,
343 yshift = \fp_eval:n { -####1 + .5 } \l_@@_nup_dim
344 ] at (current~page~text~area.north~west)
345 {
346 \includegraphics
347 [ height = \dim_eval:n
348 { \l_@@_nup_dim - \l_@@_include_sep_dim },
349 page = \clist_item:Nn \l_@@_tmpa_clist
350 { ####1 + \l_@@_include_nup_int * ( ##1 - 1 ) }
351 ] {#1}
352 };
353 }
354 \clearpage
355 }
356 \@@_empty_note_aux:
357 \int_step_inline:nn { \int_use:N \l_@@_pages_residue_int }
358 {
359 \tikz [ remember~picture, overlay ]
360 \node [ xshift = \l_@@_include_ratio_dim/2,
361 yshift = \fp_eval:n {( -##1 + .5 )} \l_@@_nup_dim
362 ] at (current~page~text~area.north~west)
363 {
364 \includegraphics
365 [ height = \dim_eval:n
366 { \l_@@_nup_dim - \l_@@_include_sep_dim },
367 page = \clist_item:Nn \l_@@_tmpa_clist
368 {
369 \l_@@_include_nup_int *
370 \l_@@_pages_total_int + ##1
371 }
372 ] {#1}
373 };
374 }
375 \clearpage
376 }
377 % \end{macrocode}
378 % \end{macro}
379 %
380 % \begin{macro}{\@@_empty_note_aux:}
381 % Define the auxiliary command for creating empty note line page.
382 % \begin{macrocode}
383 \cs_new_protected_nopar:Nn \@@_empty_note_aux:
384 {
385 \begin { tikzpicture } [ remember~picture, overlay ]
386 \draw [ very~thick, \l_@@_include_color_tl, opacity = .8 ]
387 (current~page~text~area.north~west) --
388 (current~page~text~area.north~east)
389 node [ at~start, above~right, font = \Large \bfseries ]
390 { \l_@@_include_lhead_tl }
391 node [ above~left, font = \Large \bfseries ]
392 { \l_@@_include_rhead_tl };
393 \draw [ very~thick, \l_@@_include_color_tl, opacity = .8 ]
394 (current~page~text~area.south~west) --
395 (current~page~text~area.south~east);
396 \int_step_inline:nn { \l_@@_include_lines_int - 1 }
397 {
398 \draw [ thick, \l_@@_include_color_tl, opacity = .6 ]
399 ([xshift = \l_@@_include_ratio_dim,
400 yshift = -\textheight/\l_@@_include_lines_int * ##1
401 ]current~page~text~area.north~west) --++
402 (\dim_eval:n { \textwidth - \l_@@_include_ratio_dim },0);
403 \bool_if:nT \l_@@_include_lineno_bool
404 {
405 \node [ font = \footnotesize, \l_@@_include_color_tl,
406 opacity = .4, right ] at
407 ([xshift = \textwidth,
408 yshift = -\textheight/\l_@@_include_lines_int * (##1 - .5)
409 ]current~page~text~area.north~west)
410 { \int_eval:n { ##1 } };
411 }
412 }
413 \node [ font = \footnotesize, \l_@@_include_color_tl,
414 opacity = .4, right ] at
415 ([xshift = \textwidth,
416 yshift = -\textheight + \textheight/\l_@@_include_lines_int * .5
417 ]current~page~text~area.north~west)
418 { \int_eval:n { \l_@@_include_lines_int } };
419 \end { tikzpicture }
420 \pagestyle { empty }
421 }
422 % \end{macrocode}
423 % \end{macro}
424 %
425 % \begin{variable}{\l_@@_tmpa_seq, \l_@@_tmpb_seq}
426 % Store the results of 2D array segmentation.
427 % \begin{macrocode}
428 \seq_new:N \l_@@_tmpa_seq
429 \seq_new:N \l_@@_tmpb_seq
430 % \end{macrocode}
431 % \end{variable}
432 %
433 % \begin{macro}{\@@_range_to_list:nN}
434 % Convert the combination of number and number range to a list.
435 % \begin{macrocode}
436 \cs_new_protected_nopar:Npn \@@_range_to_list:nN #1#2
437 {
438 \clist_clear:N #2
439 \seq_set_split:Nnn \l_@@_tmpa_seq { , } {#1}
440 \seq_map_inline:Nn \l_@@_tmpa_seq
441 {
442 \tl_if_in:nnTF {##1} { - }
443 {
444 \seq_set_split:Nnn \l_@@_tmpb_seq { - } {##1}
445 \int_step_inline:nnn
446 { \seq_item:Nn \l_@@_tmpb_seq { 1 } }
447 { \seq_item:Nn \l_@@_tmpb_seq { 2 } }
448 { \clist_put_right:Nn #2 {####1} }
449 } { \clist_put_right:Nn #2 {##1} }
450 }
451 }
452 % \end{macrocode}
453 % \end{macro}
454 %
455 % \begin{macrocode}
456 %</package>
457 % \end{macrocode}
458 %
459 % \end{implementation}
460 %
461 % \PrintIndex