Debian Codegraph @

texmf-dist/tex/latex/beamer/beamerbasedecode.sty

raw
1 % Copyright 2003--2007 by Till Tantau
2 % Copyright 2010 by Vedran Mileti\'c
3 % Copyright 2015 by Vedran Mileti\'c, Joseph Wright
4 % Copyright 2017,2018 by Louis Stuart, Joseph Wright
5 %
6 % This file may be distributed and/or modified
7 %
8 % 1. under the LaTeX Project Public License and/or
9 % 2. under the GNU Public License.
10 %
11 % See the file LICENSE.md for more details.
12
13 % To track which slide we are on in a frame
14 \newcount\beamer@slideinframe
15 \newcount\beamer@minimum
16
17 % Indicate whether another slide needs to be processed in this frame
18 \newif\ifbeamer@anotherslide
19 \newif\ifbeamer@localanotherslide
20
21 % Used to know that beamerpauses needs to be used in substitution
22 \newif\ifbeamer@plusencountered
23
24 % The main decoding macro tolerates a range of active characters, which
25 % require a little set up. In particular, as an active space is allowed
26 % all of the lines here have to be terminated with "%". The two-step
27 % setup for \beamer@@@temp makes sure everything is expanded and removes
28 % all of the spaces at this stage.
29 \newbox\beamer@decode@box
30 \begingroup
31 \catcode`\|=\active
32 \catcode`\:=\active
33 \catcode`\,=\active
34 \catcode`\.=\active
35 \catcode`\+=\active
36 \catcode`\-=\active
37 \catcode`\(=\active
38 \catcode`\)=\active
39 \catcode`\ =\active
40 \xdef\beamer@masterdecode#1{%
41 \noexpand\beamer@localanotherslidefalse%
42 \setbox\beamer@decode@box=\hbox{%
43 \unexpanded{%
44 \ifnum\catcode`\|=\active\edef|{\string|}\fi%
45 \ifnum\catcode`\:=\active\edef:{\string:}\fi%
46 \ifnum\catcode`\,=\active\edef,{\string,}\fi%
47 \ifnum\catcode`\.=\active\edef.{\string.}\fi%
48 \ifnum\catcode`\+=\active\edef+{\string+}\fi%
49 \ifnum\catcode`\-=\active\edef-{\string-}\fi%
50 \ifnum\catcode`\(=\active\edef({\string(}\fi%
51 \ifnum\catcode`\)=\active\edef){\string)}\fi%
52 \ifnum\catcode`\ =\active\edef {\string }\fi}%
53 \edef\noexpand\beamer@@@temp{#1\string|stop\string:0\string|}%
54 \edef\noexpand\beamer@@@temp{\unexpanded{\expandafter\zap@space\beamer@@@temp}%
55 \space\noexpand\@empty}%
56 \unexpanded{\expandafter\beamer@decode\beamer@@@temp%
57 \ifbeamer@localanotherslide\aftergroup\beamer@localanotherslidetrue\fi}%
58 }%
59 }%
60 \endgroup
61
62 % Sets dowhat to doif, if \beamer@slideinframe is in the specified
63 % interval. Example: 5-7,-3,9,11,13- would mean pages
64 % 1,2,3,5,6,7,9,11,13,14,15,16,...
65 %
66 % As a side effect, \@another is called whenever the there is a number
67 % in the list that is larger than the current serialnumber
68
69 \def\beamer@allsign{*}
70
71 % The main decoding routine starts by initialising the starting a search
72 % for everything up to "|": to allow for the simple case of overlays in
73 % slides for presentations there is a need to insert "beamer:". Notice
74 % that \beamer@@decodefind may be called multiple times, hence being set
75 % up as an auxiliary.
76 \def\beamer@decode{%
77 \beamer@plusencounteredfalse
78 \global\beamer@minimum=10000\relax
79 \gdef\beamer@decaction{}%
80 \global\let\beamer@decodefound=\beamer@allsign
81 \beamer@@decodefind}
82 \def\beamer@@decodefind#1|{\beamer@@@decodefind#1:|}
83 \def\beamer@@@decodefind#1:#2|{%
84 \ifblank{#2}%
85 {\beamer@decodefind beamer:#1:}%
86 {\beamer@decodefind #1:#2}}
87
88 % A list of possible overlay modes
89 \def\beamer@default{default}
90 \def\beamer@articlemode{article}
91 \def\beamer@secondmode{second}
92 \def\beamer@beamermode{beamer}
93 \def\beamer@presentationmode{presentation}
94 \def\beamer@modeall{all}
95 \def\beamer@ovmodestop{stop}
96
97 % The main parsing function for each sub-part starts by splitting at any
98 % "@" and then checking the spec for various cases: keywords, "+", ".".
99 % After that, there is some cleanup to do before potentially looping.
100 \def\beamer@decodefind#1:#2:{%
101 \def\beamer@ovmode{#1}%
102 \beamer@decodeaction{#2}%
103 \expandafter\futurelet\expandafter\next\expandafter
104 \beamer@checkcat\beamer@spec:%
105 \expandafter\beamer@decodeplus\beamer@spec+:%
106 \expandafter\beamer@decodedot\beamer@spec.:%
107 \ifx\beamer@ovmode\beamer@ovmodestop
108 \expandafter\beamer@@decode\beamer@decodefound,!%
109 \let\beamer@next=\relax
110 \ifbeamer@plusencountered\stepcounter{beamerpauses}\fi
111 \else
112 \ifx\beamer@ovmode\beamer@currentmode
113 \beamer@@decodefound
114 \else
115 \ifx\beamer@ovmode\beamer@modeall
116 \beamer@@decodefound
117 \else
118 \ifx\beamer@ovmode\beamer@presentationmode
119 \ifx\beamer@currentmode\beamer@articlemode
120 \else
121 \beamer@@decodefound
122 \fi
123 \else
124 \ifx\beamer@ovmode\beamer@beamermode
125 \ifx\beamer@currentmode\beamer@secondmode
126 \beamer@@decodefound
127 \fi
128 \fi
129 \fi
130 \fi
131 \fi
132 \let\beamer@next=\beamer@@decodefind
133 \fi
134 \beamer@next}
135
136 % The aim here is to find any "<action>@" spec, and to split it off the
137 % action from the rest. That uses a pretty stand search approach.
138 \edef\beamer@decodeaction#1{%
139 \noexpand\beamer@@decodeaction#1\string @\string @:}
140 \begingroup
141 \edef\beamer@@@temp{%
142 \endgroup
143 \def\noexpand\beamer@@decodeaction##1\string @##2\string @##3:{%
144 \noexpand\ifblank{##2}%
145 {%
146 \def\noexpand\beamer@action{default}%
147 \def\noexpand\beamer@spec{##1}%
148 }%
149 {%
150 \def\noexpand\beamer@action{##1}%
151 \def\noexpand\beamer@spec{##2}%
152 }%
153 }%
154 }%
155 \beamer@@@temp
156
157 % Search for the case where the specification is a keyword, and if it
158 % is set the overlay mode and spec.
159 \def\beamer@checkcat#1:{%
160 \ifcat\next a%
161 \gdef\beamer@ovmode{#1}%
162 \ifx\beamer@decodefound\beamer@allsign
163 \gdef\beamer@decodefound{0}%
164 \fi
165 \def\beamer@spec{1-}%
166 \fi}
167
168 \def\beamer@decodeplus{%
169 \def\beamer@spec{}\beamer@@decodeplus}
170 \def\beamer@@decodeplus#1+#2:{%
171 \edef\beamer@spec{\beamer@spec#1}% everything up to a +
172 \ifblank{#2}{}
173 {% ok, check if followed by number:
174 \beamer@plusencounteredtrue
175 \beamer@@@decodeplus#2:}}
176 \def\beamer@@@decodeplus{%
177 \kernel@ifnextchar(%)
178 {\beamer@relnumber}{\beamer@relnumber(0)}}
179 \def\beamer@relnumber(#1){%
180 \beamer@plusencounteredtrue
181 \@tempcnta=\numexpr #1 + \value{beamerpauses}\relax%
182 \ifnum\@tempcnta<0\@tempcnta=0\fi%
183 \edef\beamer@spec
184 {\beamer@spec\number\@tempcnta}%
185 \beamer@@decodeplus}
186
187 \def\beamer@decodedot{%
188 \def\beamer@spec{}\beamer@@decodedot}
189 \def\beamer@@decodedot#1.#2:{%
190 \edef\beamer@spec{\beamer@spec#1}% everything up to first .
191 \ifblank{#2}{}{\beamer@@@decodedot#2:}}
192 \def\beamer@@@decodedot{%
193 \kernel@ifnextchar(%)
194 {\beamer@relnumberdot}{\beamer@relnumberdot(0)}}
195 \def\beamer@relnumberdot(#1){%
196 \@tempcnta=\numexpr #1 + \value{beamerpauses} -1\relax%
197 \ifnum\@tempcnta<0\@tempcnta=0\fi%
198 \edef\beamer@spec
199 {\beamer@spec\number\@tempcnta}%
200 \beamer@@decodedot}
201
202 \def\beamer@@decodefound{%
203 \ifx\beamer@action\beamer@default
204 \xdef\beamer@decodefound{\beamer@spec}%
205 \else
206 \xdef\beamer@decaction{\beamer@decaction{\beamer@action<\beamer@spec>}}%
207 \fi}
208 \def\beamer@currentaction{default}
209
210 \def\beamer@doifnotinframe{}
211
212 % A set of macros to deal with what can form the basis of an action
213 % spec once we know the basic shape: the key concepts are whether there
214 % are more slides to do and how many there are in total.
215 \def\beamer@@decode{%
216 \kernel@ifnextchar!%
217 {\beamer@decodeend}%
218 {%
219 \kernel@ifnextchar*%
220 {\beamer@decodeall}{%
221 \kernel@ifnextchar-%
222 {\beamer@decodeuntil}%
223 {\beamer@decodenumber}}}}
224 \def\beamer@decodeend!{}
225 \def\beamer@decodeall*,{%
226 \ifnum1<\beamer@minimum
227 \global\beamer@minimum=1\relax
228 \fi
229 \ifnum1>\beamer@slideinframe
230 \global\beamer@anotherslidetrue\beamer@localanotherslidetrue
231 \fi
232 \gdef\beamer@doifnotinframe{\beamer@doifinframe}%
233 \beamer@@decode}
234 \def\beamer@decodeuntil-#1,{%
235 \ifnum1<\beamer@minimum
236 \global\beamer@minimum=1\relax
237 \fi
238 \ifnum#1>\beamer@slideinframe
239 \global\beamer@anotherslidetrue\beamer@localanotherslidetrue
240 \fi
241 \ifnum\beamer@slideinframe>#1\relax
242 \else
243 \gdef\beamer@doifnotinframe{\beamer@doifinframe}%
244 \fi
245 \beamer@@decode}
246 \def\beamer@decodenumber#1{%
247 \kernel@ifnextchar,%
248 {\beamer@decodeone{#1}}%
249 {\kernel@ifnextchar-%
250 {\beamer@decodenumberto{#1}}%
251 {\beamer@decodegobble{#1}}}}
252 \def\beamer@decodegobble#1#2{%
253 \beamer@decodenumber{#1#2}}
254 \def\beamer@decodenumberto#1-{%
255 \kernel@ifnextchar,%
256 {\beamer@decodeto{#1}}%
257 {\beamer@decodebetween{#1}}}
258 \def\beamer@decodeto#1,{%
259 \ifnum#1<\beamer@minimum
260 \global\beamer@minimum=#1\relax
261 \fi
262 \ifnum#1>\beamer@slideinframe
263 \global\beamer@anotherslidetrue\beamer@localanotherslidetrue
264 \fi
265 \ifnum#1>\beamer@slideinframe
266 \else
267 \gdef\beamer@doifnotinframe{\beamer@doifinframe}%
268 \fi
269 \beamer@@decode}
270 \def\beamer@decodebetween#1#2,{%
271 \ifnum#1<\beamer@minimum
272 \global\beamer@minimum=#1\relax
273 \fi
274 \ifnum#1>\beamer@slideinframe
275 \global\beamer@anotherslidetrue\beamer@localanotherslidetrue
276 \fi
277 \ifnum#2>\beamer@slideinframe
278 \global\beamer@anotherslidetrue\beamer@localanotherslidetrue
279 \fi
280 \ifnum#1>\beamer@slideinframe
281 \else
282 \ifnum#2<\beamer@slideinframe
283 \else
284 \gdef\beamer@doifnotinframe{\beamer@doifinframe}%
285 \fi
286 \fi
287 \beamer@@decode}
288 \def\beamer@decodeone#1,{%
289 \ifnum#1<\beamer@minimum
290 \global\beamer@minimum=#1\relax
291 \fi
292 \ifnum#1>\beamer@slideinframe
293 \global\beamer@anotherslidetrue\beamer@localanotherslidetrue
294 \fi
295 \ifnum#1=\beamer@slideinframe
296 \gdef\beamer@doifnotinframe{\beamer@doifinframe}%
297 \fi
298 \beamer@@decode}
299
300 \def\beamer@donow{\beamer@doifnotinframe}