summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/optex/base/slides.opm
blob: 5ee4346674af974e137b93baa3ab97bb5f6997c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
% This is part of the OpTeX project, see http://petr.olsak.net/optex

\_codedecl \slideshow {Slides style for OpTeX <2021-01-16>} % loaded on demand by \slides

   \_doc -----------------------------
   Default margins and design is declared here.
   The `\_ttfont` is scaled by `mag1.15` in order to balance the
   ex height of Helvetica (Heros) and LM fonts Typewriter.
   The `\begtt`...`\endtt` verbatim is printed by smaller text.
   \_cod -----------------------------

\_margins/1 a5l (14,14,10,3)mm  % landscape A5 format
\_def\_wideformat{\_margins/1 (263,148) (16,16,10,3)mm } % 16:9 format

\_ifx\_fontnamegen\_undefined \_fontfam[Heros]
   \_let\_ttfont=\_undefined \_famvardef\_ttfont{\_setfontsize{mag1.15}\_tt}
\_fi
\_typosize[16/19]
\_def\_urlfont{}
\_everytt={\_typosize[13/16] \_advance\_hsize by10mm}
\_fontdef\_fixbf{\_bf}

\_nopagenumbers
\_parindent=0pt
\_ttindent=5mm
\_parskip=5pt plus 4pt minus2pt
\_rightskip=0pt plus 1fil
\_ttindent=10pt
\_def\_ttskip{\_smallskip}

\_onlyrgb   % RGB color space is better for presentations

   \_doc -----------------------------
   The bottom margin is set to 3\,mm. If we use 1\,mm, then the baseline of
   `\footline` is 2\,mm from the bottom page. This is the depth of the `\Grey`
   rectangle used for page numbers. It is r-lapped to `\hoffset` width because left
   margin = `\hoffset` = right margin. It is 14\,mm for narrow pages or
   16\,mm for wide pages.
   \_cod -----------------------------

\_footlinedist=1mm
\_footline={\_hss \_rlap{%
   \_rlap{\Grey\_kern.2\_hoffset\_vrule height6mm depth2mm width.8\_hoffset}%
                      \_hbox to\_hoffset{\White\_hss\_folio\_kern3mm}}}

   \_doc -----------------------------
   The \`\subtit` is defined analogically like `\tit`.
   \_cod -----------------------------

\_eoldef\_subtit#1{\_vskip20pt {\_leftskip=0pt plus1fill \_rightskip=\_leftskip
   \_subtitfont #1\_nbpar}}

   \_doc -----------------------------
   The \`\pshow``<num>` prints the text in invisible
   (transparent) font when \^`\layernum`\code{<}`<num>`.
   The transparency is set by `\pdfpageresoyrces` primitive.
   \_cod -----------------------------

\pdfpageresources{/ExtGState << /Invisible << /Type /ExtGState /ca 0 /CA 0 >>
                                /Visible   << /Type /ExtGState /ca 1 /CA 1 >> >>}
\addto\_morepgresources{/Invisible << /Type /ExtGState /ca 0 /CA 0 >>
                        /Visible   << /Type /ExtGState /ca 1 /CA 1 >>}
\def\Invisible {\_pdfliteral{/Invisible gs}}
\def\Visible   {\_pdfliteral{/Visible gs}}
\def\Transparent {\Invisible \_aftergroup \Visible}

\_def\_use#1#2{\_ifnum\_layernum#1\_relax#2\_fi}
\_def\_pshow#1{\_use{=#1}\Red \_use{<#1}\Transparent \_ignorespaces}

   \_doc -----------------------------
   The main level list of items is activated here. The `\_item:X` and
   `\_item:x` are used and are re-defined here.
   If we are in a nested level of items and `\pg+` is used then
   `\egroups` macro expands to the right number of `\egroup`s
   to close the page correctly. The level of nested item lists
   is saved to the `\_ilevel` register and used when we start again
   the next text after `\pg+`.
   \_cod -----------------------------

\_newcount\_gilevel
\_def\*{*}
\_adef*{\_startitem}
\_sdef{_item:X}{\Blue\_raise.2ex\_fullrectangle{.8ex}\_kern.5em}
\_sdef{_item:x}{\Blue\_raise.3ex\_fullrectangle{.6ex}\_kern.4em}
\_style X
\_def\_egroups{\_par\_global\_gilevel=\_ilevel \_egroup}
\_everylist={\_novspaces \_ifcase\_ilevel \_or \_style x \_else \_style - \_fi
   \_addto\_egroups{\_egroup}}

   \_doc -----------------------------
   The default values of \`\pg`, i.\,e.\ `\pg;`, `\pg+` and `\pg.` are very simple.
   They are used when `\showslides` is not specified.
   \_cod -----------------------------

\_def\_pg#1{\_cs{_spg:#1}}
\_sdef{_spg:;}{\_vfil\_break \_lfnotenumreset}
\_sdef{_spg:.}{\_endslides}
\_sdef{_spg:+}{\_par}

   \_doc -----------------------------
   The \`\_endslides` is defined as `\_end` primitive, but
   slide-designer can redefine it. For example,
   \ulink[http://petr.olsak.net/optex/optex-tricks.html\#slider]{OpTeX trick 0029}
   shows how to define clickable navigation to the pages and how to check
   the data integrity at the end of the document using `\_endslides`.

   The `\bye` macro is redefined here as an alternative to `\pg.`.
   \_cod -----------------------------

\_def\_endslides{\_end}
\_def\bye{\_pg.}

   \_doc -----------------------------
   We need no numbers and no table of contents when using slides.
   The \^`\_printsec` macro is redefined in order the title is centered
   and typeset in `\Blue`.
   \_cod -----------------------------

\_def\_titfont{\_typosize[42/60]\_bf \Blue}
\_def\_subtitfont{\_typosize[20/30]\_bf}
\_def\_secfont{\_typosize[25/30]\_bf \Blue}

\_nonum \_notoc \_let\_resetnonumnotoc=\_relax
\_def\_printsec#1{\_par
   \_abovetitle{\_penalty-400}\_bigskip
   {\_secfont \_noindent \_leftskip=0pt plus1fill \_rightskip=\_leftskip
     \_printrefnum[@\_quad]#1\_nbpar}\_insertmark{#1}%
   \_nobreak \_belowtitle{\_medskip}%
}

   \_doc -----------------------------
   When \`\slideshow` is active then each page is opened
   by `\setbox\_slidepage=\vbox\bgroup` (roughly speaking)
   and closed by `\egroup`. The material is
   `\unvbox`ed and saved for the usage in the next usage if `\pg+` is in process.
   The \`\_slidelayer` is incremented instead `\pageno` if `\pg+`.
   This counter is equal to `\count1`, so it is printed to the terminal and
   log file next to `\pageno`.

   The code is somewhat more complicated when \^`\layers` is used. Then
   `<layered-text>` is saved to the \`\_layertext` macro, the material before
   it is in \`\_slidepage` box and the material after it is in `\_slidepageB`
   box. The pages are completed in the `\loop` which increments the
   \`\layernum` register.
   \_cod -----------------------------

\_newbox\_slidepage  \_newbox\_slidepageB
\_countdef\_slidelayer=1
\_def\_decr#1{\_global\_advance#1 by-1 }

\_def\_slideshow{\_slidelayer=1 \_slideshowactive \_setbox\_slidepage=\_vbox\_bgroup}

\_def\_slideshowactive{%
   \_sdef{_spg:;}{\_closepage \_global\_slidelayer=1 \_resetpage \_openslide}
   \_sdef{_spg:.}{\_closepage \_endslides}
   \_sdef{_spg:+}{\_closepage \_incr\_slidelayer \_decr\_pageno \_openslide}
   \_let\_layers=\_layersactive
   \_destboxslide % to prevent hyperlink-dests duplication
}
\_def\_destboxslide{\_def\_destbox[##1:##2]{\_isequal{##1}{ref}\_iffalse \_destboxori[##1:##2]\_fi}}

\_def\_openslide{\_setbox\_slidepage=\_vbox\_bgroup \_setilevel
   \_ifvoid\_slidepage \_else \_unvbox\_slidepage \_nointerlineskip\_lastbox \_fi}
\_def\_setilevel{\_loop \_decr\_gilevel \_ifnum\_gilevel<0 \_else \_begitems \_repeat}

\_def\_closepage{\_egroups
   \_ifnum \_maxlayers=0 \_unvcopy\_slidepage \_vfil\_break
   \_else \_begingroup \_setwarnslides \_layernum=0
      \_loop
         \_ifnum\_layernum<\_maxlayers \_advance\_layernum by1
            \_printlayers \_vfil\_break
            \_ifnum\_layernum<\_maxlayers \_incr\_slidelayer \_decr\_pageno \_fi
      \_repeat
      \_global\_maxlayers=0
      \_incr\_layernum \_global\_setbox\_slidepage=\_vbox{\_printlayers}%
      \_endgroup
   \_fi}
\_def\_resetpage{%
   \_global\_setbox\_slidepage=\_box\_voidbox \_global\_setbox\_slidepageB=\_box\_voidbox
   \_lfnotenumreset
}
\_def\_setwarnslides{%
   \_def\pg##1{\_opwarning{\_string\pg##1 \_layersenv}\_def\pg####1{}}%
   \_def\layers##1 {\_opwarning{\_string\layers\_space \_layersenv}\_def\layers####1{}}%
}
\_def\_layersenv{cannot be inside \_string\layers...\_string\endlayers, ignored}

\_def\_printlayers{\_unvcopy\_slidepage \_nointerlineskip\_lastbox
   \_layertext \_endgraf
   \_ifdim\_prevdepth>-1000pt \_kern-\_prevdepth \_kern\_dp\_strutbox \_fi
   \_vskip\_parskip
   \_unvcopy\_slidepageB
}
\_let\_destboxori=\_destbox

\_newcount\_layernum \_newcount\_maxlayers
\_maxlayers=0

\_long\_def\_layersactive #1 #2\endlayers{%
   \_par\_penalty0\_egroup
   \_gdef\_layertext{#2}%
   \_global\_maxlayers=#1
   \_setbox\_slidepageB=\_vbox\_bgroup
}
\_public \subtit \slideshow \pg \wideformat \use \pshow \layernum ;

   \_doc -----------------------------
   Default \`\layers` `<num>` macro (when \^`\slideshow` is not activated) is simple.
   It prints the `<layered-text>` with `\layernum=<num>+1` because we need the
   result after last layer is processed.
   \_cod -----------------------------

\_def\_layers #1 {\_par\_layernum=\_numexpr#1+1\_relax}
\_let\endlayers=\_relax

\_def\layers{\_layers}

   \_doc -----------------------------
   We must to redefine \`\fnotenumpages` because the data from `.ref` file
   are less usable for implementing such a feature: the
   footnote should be in more layers repeatedly. But we can suppose that
   each page starts by `\pg;` macro, so we can reset the footnote counter by
   this macro.
   \_cod -----------------------------

\_def \_fnotenumpages {\_def\_fnotenum{\_the\_lfnotenum}\_pgfnotefalse
   \_def\_lfnotenumreset{\_global\_lfnotenum=0 }}
\_let \_lfnotenumreset=\_relax
\_public \fnotenumpages ;

\_endcode % ----------------------------------------------

The user manual of \OpTeX/ slides are in `op-slides.tex` file.

2021-01-16 \layers at empty page raises error: problem fixed
2020-03-19 slides introduced