Debian Codegraph @

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

raw
1 % Copyright 2003-2007 by Till Tantau
2 % Copyright 2010 by Vedran Mileti\'c
3 % Copyright 2012,2013,2015 by Vedran Mileti\'c, Joseph Wright
4 % Copyright 2017,2018 by Louis Stuart, Joseph Wright
5 % Copyright 2021-2026 by Joseph Wright, samcarter
6 %
7 % This file may be distributed and/or modified
8 %
9 % 1. under the LaTeX Project Public License and/or
10 % 2. under the GNU Public License.
11 %
12 % See the file LICENSE.md for more details.
13
14 \mode
15 <all>
16 {
17 \def\beamer@secgobble{\beamer@savemode\@ifnextchar*{\beamer@secstargobble}{\beamer@sec@gobbleoptional}}
18 \def\beamer@secstargobble*{\beamer@sec@gobbleoptional}
19 \newcommand\beamer@sec@gobbleoptional[2][]{\beamer@resumemode}
20 \def\secname{}
21 \def\subsecname{}
22 \def\subsubsecname{}
23 }
24
25 \mode
26 <presentation>
27
28 %
29 % Lecture Definitions
30 %
31 \newif\ifbeamer@inlecture
32 \beamer@inlecturetrue
33
34 \newcommand{\beamer@if@in@clist@TF}[2]{%
35 \def\beamer@if@in@clist@aux##1,#2,{}%
36 \expandafter\expandafter\expandafter\ifx
37 \expandafter\expandafter\expandafter\@nil
38 \expandafter\beamer@if@in@clist@aux\expandafter,#1,{}{},#2,\@nil
39 \expandafter\@secondoftwo
40 \else
41 \expandafter\@firstoftwo
42 \fi
43 }
44
45 \newcounter{lecture}
46 \renewcommand\thelecture{\@arabic\c@lecture}
47 \let\insertlecturenumber=\thelecture
48 \newrobustcmd*\lecture{\@dblarg\beamer@lecture}
49 \long\def\beamer@lecture[#1]#2#3{%
50 \beamer@savemode
51 \mode<all>%
52 \refstepcounter{lecture}%
53 \def\beamer@currentlecturelabel{#3}%
54 \@onelevel@sanitize\beamer@currentlecturelabel
55 \def\beamer@lecturename{#2}%
56 \def\beamer@shortlecturename{#1}%
57 \ifx\beamer@onlylecture\@empty
58 \else
59 \expandafter\beamer@if@in@clist@TF\expandafter\beamer@onlylecture
60 \expandafter{\beamer@currentlecturelabel}%
61 {\beamer@inlecturetrue}%
62 {\beamer@inlecturefalse}%
63 \fi
64 \beamer@atbeginlecture
65 \beamer@resumemode
66 }
67
68 \mode
69 <all>
70 {
71 \newrobustcmd\AtBeginLecture[1]{%
72 \def\beamer@atbeginlecture{#1}}
73 \AtBeginLecture{}
74
75 \newrobustcmd*\includeonlylecture[1]{%
76 \def\beamer@onlylecture{#1}%
77 \@onelevel@sanitize\beamer@onlylecture
78 }
79
80 \includeonlylecture{}
81 }
82
83 \newrobustcmd*\insertlecture{\beamer@lecturename}
84 \newrobustcmd*\insertshortlecture[1][]{%
85 \begingroup
86 \beamer@setupshort{#1}%
87 \beamer@insertshort{\beamer@shortlecturename}%
88 \endgroup}
89
90 \mode
91 <article>
92 {
93 \newrobustcmd*\lecture[3][]{\def\insertlecture{#2}\def\insertshortlecture{#1}}
94 }
95
96 %
97 % Part Definitions
98 %
99 \newcounter{part}
100 \renewcommand\thepart{\@arabic\c@part}
101 \beamer@partstartpage=1
102
103 \newcommand<>{\part}{\alt#1{\@dblarg\beamer@part}{\beamer@gobbleoptional}}
104 \long\def\beamer@part[#1]#2{%
105 \GetTitleString{#1}%
106 \let\@currentlabelname\GetTitleStringResult
107 \beamer@savemode
108 \mode<all>%
109 \ifbeamer@inlecture
110 \refstepcounter{part}%
111 \def\beamer@partname{#2}%
112 \def\beamer@partnameshort{#1}%
113 \addtocontents{nav}{\protect\headcommand{\protect\partentry{#2}{\the\c@part}}}%
114 \xdef\partlink{{Navigation\the\c@page}{\noexpand\beamer@partname}}%
115 \xdef\partlinkshort{{Navigation\the\c@page}{\noexpand\beamer@partnameshort}}%
116 \beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
117 \addtocontents{nav}{\protect\headcommand{%
118 \protect\beamer@partpages{\the\beamer@partstartpage}{\the\beamer@tempcount}}}%
119 \addtocontents{nav}{\protect\headcommand{%
120 \protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\the\beamer@tempcount}}}%
121 \addtocontents{nav}{\protect\headcommand{%
122 \protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}}%
123 \beamer@partstartpage=\c@page
124 \beamer@sectionstartpage=\c@page
125 \beamer@subsectionstartpage=\c@page
126 \setcounter{subsection}{0}%
127 \protected\def\insertsection{}%
128 \protected\def\insertsubsection{}%
129 \protected\def\insertsubsubsection{}%
130 \protected\def\insertsectionhead{}%
131 \protected\def\insertsubsectionhead{}%
132 \protected\def\insertsubsubsectionhead{}%
133 \def\lastsubsection{}%
134 \protected\def\insertpart{\expandafter\hyperlink\partlink}%
135 \Hy@writebookmark{\the\c@part}{#1}{Outline\the\c@part}{1}{toc}%
136 \hyper@anchorstart{Outline\the\c@part}\hyper@anchorend
137 \beamer@atbeginpart
138 \fi%
139 \beamer@resumemode}%
140 \def\insertpart{}
141 \def\partlinkshort{{Navigation1}{}}
142
143 \newrobustcmd*\insertromanpartnumber{\@Roman\c@part}
144 \newrobustcmd*\insertpartnumber{\@arabic\c@part}
145
146 \newrobustcmd*\insertshortpart[1][]{%
147 \begingroup
148 \beamer@setupshort{#1}%
149 \beamer@insertshort{\expandafter\hyperlink\partlinkshort}%
150 \endgroup}
151
152 \mode
153 <all>
154 {
155 \newrobustcmd\AtBeginPart[1]{%
156 \def\beamer@atbeginpart{#1}}
157 \AtBeginPart{}
158 }
159
160 \mode
161 <article>
162 {
163 \ifx\part\@undefined%
164 \else
165 \renewcommand<>{\part}{\alt#1{\beameroriginal\part}{\beamer@gobbleoptional}}
166 \fi
167 }
168
169 %
170 % Section Definitions
171 %
172 \def\sectionname{\translate{Section}}
173 \newcounter{section}
174 \renewcommand\thesection{\@arabic\c@section}
175 \beamer@sectionstartpage=1\relax
176 \beamer@tocsectionnumber=0\relax
177
178 \newcommand<>{\section}{\alt#1{\@ifnextchar[\beamer@section\beamer@@section}{\beamer@secgobble}}
179
180 \def\beamer@@section{\@ifnextchar*\beamer@@ssection\beamer@@@section}
181 \long\def\beamer@@ssection*#1{\beamer@section[{#1}]{}}
182 \long\def\beamer@@@section#1{\beamer@section[{#1}]{#1}}
183 \long\def\beamer@section[#1]#2{%
184 \GetTitleString{#1}%
185 \let\@currentlabelname\GetTitleStringResult
186 \beamer@savemode%
187 \mode<all>%
188 \ifbeamer@inlecture
189 \refstepcounter{section}%
190 \ifblank{#2}%
191 {\long\def\secname{#1}\long\def\lastsection{#1}}%
192 {\global\advance\beamer@tocsectionnumber by 1\relax%
193 \long\def\secname{#2}%
194 \long\def\lastsection{#1}%
195 \addtocontents{toc}{\protect\beamer@sectionintoc{\the\c@section}{#2}{\the\c@page}{\the\c@part}%
196 {\the\beamer@tocsectionnumber}}}%
197 {\let\\=\relax\xdef\sectionlink{{Navigation\the\c@page}{\noexpand\secname}}}%
198 \beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
199 \addtocontents{nav}{\protect\headcommand{\protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\the\beamer@tempcount}}}%
200 \addtocontents{nav}{\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}}%
201 \ifblank{#1}{}{%
202 \addtocontents{nav}{\protect\headcommand{\protect\sectionentry{\the\c@section}{#1}{\the\c@page}{\secname}{\the\c@part}}}%
203 }%
204 \beamer@sectionstartpage=\c@page%
205 \beamer@subsectionstartpage=\c@page%
206 \def\insertsection{\expandafter\hyperlink\sectionlink}%
207 \def\insertsubsection{}%
208 \def\insertsubsubsection{}%
209 % Deal with a defective patch in metropolis theme
210 \def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
211 \edef\insertsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{\unexpanded{#1}}}%
212 \def\insertsubsectionhead{}%
213 \def\insertsubsubsectionhead{}%
214 \def\lastsubsection{}%
215 \Hy@writebookmark{\the\c@section}{\secname}{Outline\the\c@part.\the\c@section}{2}{toc}%
216 \hyper@anchorstart{Outline\the\c@part.\the\c@section}\hyper@anchorend%
217 \ifblank{#2}{\beamer@atbeginsections}{\beamer@atbeginsection}%
218 \fi%
219 \beamer@resumemode}%
220 \def\insertsection{}
221 \def\insertsectionhead{}
222 \def\insertsectionnumber{\@arabic\c@section}
223
224 \def\breakhere{\protect\beamer@breakhere}
225 \def\beamer@breakhere{}
226
227
228 \mode
229 <all>
230 {
231 \newrobustcmd*\AtBeginSection{\@ifnextchar[{\beamer@AtBeginSection}{\beamer@@AtBeginSection}}
232 \long\def\beamer@@AtBeginSection#1{\beamer@AtBeginSection[{#1}]{#1}}
233 \long\def\beamer@AtBeginSection[#1]#2{%
234 \def\beamer@atbeginsection{#2}%
235 \def\beamer@atbeginsections{#1}%
236 }
237 \AtBeginSection{}
238 }
239
240 \mode
241 <article>
242 {
243 \renewcommand<>{\section}{\alt#1{\beameroriginal\section}{\beamer@secgobble}}
244 }
245
246
247 %
248 % Subsection Definitions
249 %
250 \def\subsectionname{\translate{Subsection}}
251 \newcounter{subsection}[section]
252 \renewcommand\thesubsection{\@arabic\c@subsection}
253
254 \beamer@subsectionstartpage=1
255
256 \newcommand<>{\subsection}{\alt#1{\@ifnextchar[\beamer@subsection\beamer@@subsection}{\beamer@secgobble}}
257
258 \def\beamer@@subsection{\@ifnextchar*\beamer@@ssubsection\beamer@@@subsection}
259 \long\def\beamer@@ssubsection*#1{\beamer@subsection[{#1}]{}}
260 \def\beamer@@@subsection#1{\beamer@subsection[{#1}]{#1}}
261 \def\beamer@subsection[#1]#2{%
262 \GetTitleString{#1}%
263 \let\@currentlabelname\GetTitleStringResult
264 \beamer@savemode%
265 \mode<all>%
266 \ifbeamer@inlecture%
267 \refstepcounter{subsection}%
268 \ifblank{#2}{\long\def\subsecname{#1}\long\def\lastsubsection{#1}}
269 {%
270 \long\def\subsecname{#2}%
271 \long\def\lastsubsection{#1}%
272 \addtocontents{toc}{\protect\beamer@subsectionintoc{\the\c@section}{\the\c@subsection}{#2}{\the\c@page}{\the\c@part}{\the\beamer@tocsectionnumber}}%
273 }%
274 \beamer@tempcount=\c@page\advance\beamer@tempcount by -1%
275 \addtocontents{nav}{\protect\headcommand{\protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\the\beamer@tempcount}}}
276 \ifblank{#1}{}{%
277 \addtocontents{nav}{\protect\headcommand{\protect\beamer@subsectionentry{\the\c@part}{\the\c@section}{\the\c@subsection}{\the\c@page}{\lastsubsection}}}
278 }%
279 \beamer@subsectionstartpage=\c@page%
280 \edef\subsectionlink{{Navigation\the\c@page}{\noexpand\subsecname}}%
281 \def\insertsubsection{\expandafter\hyperlink\subsectionlink}%
282 \def\insertsubsubsection{}%
283 % Deal with a faulty patch in metropolis theme
284 \def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}%
285 \edef\insertsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{\unexpanded{#1}}}%
286 \def\insertsubsubsectionhead{}%
287 \Hy@writebookmark{\the\c@subsection}{\subsecname}{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@page}{3}{toc}%
288 \hyper@anchorstart{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@page}\hyper@anchorend%
289 \ifblank{#2}{\beamer@atbeginsubsections}{\beamer@atbeginsubsection}%
290 \fi%
291 \beamer@resumemode}
292 \def\insertsubsection{}
293 \def\insertsubsectionnumber{\@arabic\c@subsection}
294 \def\insertsubsectionhead{}
295 \def\lastsubsection{}
296
297 \mode
298 <all>
299 {
300 \newrobustcmd*\AtBeginSubsection{\@ifnextchar[{\beamer@AtBeginSubsection}{\beamer@@AtBeginSubsection}}
301 \long\def\beamer@@AtBeginSubsection#1{\beamer@AtBeginSubsection[{#1}]{#1}}
302 \long\def\beamer@AtBeginSubsection[#1]#2{%
303 \def\beamer@atbeginsubsection{#2}%
304 \def\beamer@atbeginsubsections{#1}}
305 \AtBeginSubsection{}
306 }
307
308 \mode
309 <article>
310 {
311 \renewcommand<>{\subsection}{\alt#1{\beameroriginal\subsection}{\beamer@secgobble}}
312 }
313
314
315 %
316 % Subsubsection Definitions
317 %
318 \newcounter{subsubsection}[subsection]
319 \renewcommand\thesubsubsection{\@arabic\c@subsubsection}
320
321 \beamer@subsectionstartpage=1
322
323 \newcommand<>{\subsubsection}{\alt#1{\@ifnextchar[\beamer@subsubsection\beamer@@subsubsection}{\beamer@secgobble}}
324
325 \def\beamer@@subsubsection{\@ifnextchar*\beamer@@ssubsubsection\beamer@@@subsubsection}
326 \long\def\beamer@@ssubsubsection*#1{\beamer@subsubsection[{#1}]{}}
327 \def\beamer@@@subsubsection#1{\beamer@subsubsection[{#1}]{#1}}
328 \def\beamer@subsubsection[#1]#2{%
329 \GetTitleString{#1}%
330 \let\@currentlabelname\GetTitleStringResult
331 \beamer@savemode%
332 \mode<all>%
333 \ifbeamer@inlecture%
334 \refstepcounter{subsubsection}%
335 \ifblank{#2}{\long\def\subsubsecname{#1}\long\def\lastsubsubsection{#1}}
336 {%
337 \long\def\subsubsecname{#2}%
338 \long\def\lastsubsubsection{#1}%
339 \addtocontents{toc}{\protect\beamer@subsubsectionintoc%
340 {\the\c@section}{\the\c@subsection}{\the\c@subsubsection}{#2}{\the\c@page}{\the\c@part}{\the\beamer@tocsectionnumber}}%
341 }%
342 \ifblank{#1}{}{%
343 \addtocontents{nav}{\protect\headcommand{\protect\beamer@subsubsectionentry%
344 {\the\c@part}{\the\c@section}{\the\c@subsection}{\the\c@subsubsection}{\the\c@page}{\lastsubsubsection}}}%
345 }
346 \edef\subsubsectionlink{{Navigation\the\c@page}{\noexpand\subsubsecname}}%
347 \def\insertsubsubsection{\expandafter\hyperlink\subsubsectionlink}%
348 \edef\insertsubsubsectionhead{\noexpand\hyperlink{Navigation\the\c@page}{\unexpanded{#1}}}
349 \Hy@writebookmark{\the\c@subsubsection}{\subsubsecname}{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@subsubsection.\the\c@page}{4}{toc}%
350 \hyper@anchorstart{Outline\the\c@part.\the\c@section.\the\c@subsection.\the\c@subsubsection.\the\c@page}\hyper@anchorend%
351 \ifblank{#2}{\beamer@atbeginsubsubsections}{\beamer@atbeginsubsubsection}%
352 \fi%
353 \beamer@resumemode}
354 \def\insertsubsubsection{}
355 \def\insertsubsubsectionnumber{\@arabic\c@subsubsection}
356 \def\insertsubsubsectionhead{}
357
358 \mode
359 <all>
360 {
361 \newrobustcmd*\AtBeginSubsubsection{\@ifnextchar[{\beamer@AtBeginSubsubsection}{\beamer@@AtBeginSubsubsection}}
362 \long\def\beamer@@AtBeginSubsubsection#1{\beamer@AtBeginSubsubsection[{#1}]{#1}}
363 \long\def\beamer@AtBeginSubsubsection[#1]#2{%
364 \def\beamer@atbeginsubsubsection{#2}%
365 \def\beamer@atbeginsubsubsections{#1}}
366 \AtBeginSubsubsection{}
367 }
368
369 \mode
370 <article>
371 {
372 \renewcommand<>{\subsubsection}{\alt#1{\beameroriginal\subsubsection}{\beamer@secgobble}}
373 }
374
375
376 %
377 % Appendix stuff
378 %
379
380 \newif\ifbeamer@inappendix
381
382 \newcommand<>\beamer@appendix{}
383 \def\beamer@resetappendix{\global\let\appendix\beamer@appendix}
384 \def\beamer@appendixwrite{%
385 \immediate\write\@auxout{\string\@writefile{nav}%
386 {\noexpand\headcommand{\noexpand\gdef\noexpand\insertmainframenumber{\the\c@framenumber}}}}%
387 \addtocontents{nav}{\protect\headcommand{\protect\beamer@appendixpages{\the\c@page}}}%
388 }
389
390 \newcommand<>\appendix{%
391 \beamer@inappendixtrue%
392 \only#1{%
393 \part{\appendixname}%
394 \beamer@appendixwrite%
395 \beamer@resetappendix%
396 }%
397 }
398
399 \def\insertappendixframenumber{\the\numexpr\inserttotalframenumber-\insertmainframenumber\relax}
400 \def\insertframenumberinappendix{\ifbeamer@inappendix\the\numexpr\insertframenumber-\insertmainframenumber\relax\else0\fi}
401
402 \mode
403 <article>
404 {
405 \ifx\appendix\@undefined
406 \else
407 \renewcommand<>{\appendix}{\only#1{\beameroriginal\appendix}}
408 \fi
409 }
410
411
412 \mode
413 <all>