Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % Package beamersubframe
4 % Copyright (c) 2011 Mike Kaufmann, all rights reserved
5 %
6 % This program is provided under the terms of the
7 % LaTeX Project Public License distributed from CTAN
8 % archives in directory macros/latex/base/lppl.txt.
9 %
10 % Author: Mike Kaufmann
11 % [email protected]
12 % \fi
13 %% \CharacterTable
14 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
15 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
16 %% Digits \0\1\2\3\4\5\6\7\8\9
17 %% Exclamation \! Double quote \" Hash (number) \#
18 %% Dollar \$ Percent \% Ampersand \&
19 %% Acute accent \' Left paren \( Right paren \)
20 %% Asterisk \* Plus \+ Comma \,
21 %% Minus \- Point \. Solidus \/
22 %% Colon \: Semicolon \; Less than \<
23 %% Equals \= Greater than \> Question mark \?
24 %% Commercial at \@ Left bracket \[ Backslash \\
25 %% Right bracket \] Circumflex \^ Underscore \_
26 %% Grave accent \` Left brace \{ Vertical bar \|
27 %% Right brace \} Tilde \~}
28 %%
29 % \CheckSum{922}
30 %
31 % \iffalse meta-comment
32 %
33 %<*package>
34 %%
35 \def\fileversion{0.2}
36 \def\filedate{2011/08/07}
37
38 %</package>
39 %
40 %<*driver>
41 \documentclass{ltxdoc}
42 \usepackage{hypdoc}
43 \usepackage{graphicx}
44 %\usepackage[pdfborder=0,colorlinks,linkcolor=blue]{hyperref}
45 \usepackage[all]{hypcap}
46 \setcounter{IndexColumns}{2}
47 \EnableCrossrefs
48 \CodelineIndex
49 %\RecordChanges
50 %\OnlyDescription
51 \makeatletter
52 % new, like ...Env... commands from doc.sty)
53 \let\PrintDescribeOpt\PrintDescribeEnv
54 \let\PrintOptName\PrintEnvName
55 \def\DescribeOpt{\leavevmode\@bsphack\begingroup\MakePrivateLetters
56 \Describe@Opt}
57 \def\Describe@Opt#1{\endgroup
58 \marginpar{\raggedleft\PrintDescribeOpt{#1}}%
59 \SpecialOptIndex{#1}\@esphack\ignorespaces}
60 \def\SpecialOptIndex#1{\@bsphack
61 \index{#1\actualchar{\protect\ttfamily#1}
62 (option)\encapchar usage}%
63 \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar
64 usage}\@esphack}
65 % new (like \SpecialEnvIndex from hypdoc.sty)
66 \let\HDorg@SpecialOptIndex\SpecialOptIndex
67 \renewcommand*\SpecialOptIndex[1]{%
68 \@bsphack
69 \begingroup
70 \HD@target
71 \let\HDorg@encapchar\encapchar
72 \edef\encapchar usage{%
73 \HDorg@encapchar hdclindex{\the\c@HD@hypercount}{usage}%
74 }%
75 \HDorg@SpecialOptIndex{#1}%
76 \endgroup
77 \@esphack
78 }
79 % redefinition (from doc.sty)
80 \def\macro{\begingroup
81 \catcode`\\12
82 \MakePrivateLetters \m@cro@ \z@}
83 \def\environment{\begingroup
84 \catcode`\\12
85 \MakePrivateLetters \m@cro@ \@ne}
86 % new, environment 'option', like 'environment', but index entries with
87 % '(option)'
88 \def\option{\begingroup
89 \catcode`\\12
90 \MakePrivateLetters \m@cro@ \tw@}
91 % redefinition (from doc.sty)
92 \long\def\m@cro@#1#2{\endgroup \topsep\MacroTopsep \trivlist
93 \edef\saved@macroname{\string#2}%
94 \def\makelabel##1{\llap{##1}}%
95 \if@inlabel
96 \let\@tempa\@empty \count@\macro@cnt
97 \loop \ifnum\count@>\z@
98 \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
99 \edef\makelabel##1{\llap{\vtop to\baselineskip
100 {\@tempa\hbox{##1}\vss}}}%
101 \advance \macro@cnt \@ne
102 \else \macro@cnt\@ne \fi
103 \edef\@tempa{\noexpand\item[%
104 \ifcase #1%
105 \noexpand\PrintMacroName
106 \or
107 \noexpand\PrintEnvName
108 \or
109 \noexpand\PrintOptName
110 \fi
111 {\string#2}]}%
112 \@tempa
113 \global\advance\c@CodelineNo\@ne
114 \ifcase #1%
115 \SpecialMainIndex{#2}\nobreak
116 \DoNotIndex{#2}%
117 \or
118 \SpecialMainEnvIndex{#2}\nobreak
119 \or
120 \SpecialMainOptIndex{#2}\nobreak
121 \fi
122 \global\advance\c@CodelineNo\m@ne
123 \ignorespaces}
124 % new
125 \let\endoption\endmacro
126 \def\SpecialMainOptIndex#1{\@bsphack\special@index{%
127 #1\actualchar
128 {\string\ttfamily\space#1}
129 (option)%
130 \encapchar main}%
131 \special@index{options:\levelchar#1\actualchar{%
132 \string\ttfamily\space#1}\encapchar
133 main}\@esphack}
134 \makeatother
135 \begin{document}
136 \DocInput{beamersubframe.dtx}
137 \end{document}
138 %</driver>
139 %
140 %<*package>
141 % \fi
142 %
143 % \DoNotIndex{\^}
144 % \DoNotIndex{\@auxout}
145 % \DoNotIndex{\@@end,\@empty}
146 % \DoNotIndex{\@gobble,\@gobbletwo}
147 % \DoNotIndex{\@ifclassloaded,\@ifnextchar,\@ifundefined}
148 % \DoNotIndex{\@makeother}
149 % \DoNotIndex{\@nameuse}
150 % \DoNotIndex{\@tempa,\@tempb,\@tempcnta,\@tempcntb}
151 % \DoNotIndex{\@writefile,\@nameuse}
152 % \DoNotIndex{\advance,\active,\addtocontents,\addtocounter}
153 % \DoNotIndex{\AtBeginDocument,\AtEndDocument}
154 % \DoNotIndex{\begin,\begingroup}
155 % \DoNotIndex{\beamer@endpageofdocument,\beamer@endpageofframe}
156 % \DoNotIndex{\beamer@endpageofpart,\beamer@endpageofsection}
157 % \DoNotIndex{\beamer@endpageofsubsection}
158 % \DoNotIndex{\beamer@frameendpage,\beamer@framepages,\beamer@framestartpage}
159 % \DoNotIndex{\beamer@startpageofpart,\beamer@startpageofsection}
160 % \DoNotIndex{\beamer@startpageofsubsection,\beamer@subsectionstartpage}
161 % \DoNotIndex{\beamer@partstartpage,\beamer@sectionstartpage}
162 % \DoNotIndex{\beamer@ifempty,\beamer@notesactions,\beamer@tempcount}
163 % \DoNotIndex{\c@framenumber,\c@page,\c@part}
164 % \DoNotIndex{\c@section,\c@subsection,\c@subsectionslide}
165 % \DoNotIndex{\catcode,\clearpage,\closeout,\csname}
166 % \DoNotIndex{\DeclareOption,\def,\do,\dospecials}
167 % \DoNotIndex{\edef,\else,\end,\endgroup,\endcsname,\endinput,\ExecuteOption}
168 % \DoNotIndex{\expandafter,\ExecuteOptions}
169 % \DoNotIndex{\fi,\filedate,\fileversion}
170 % \DoNotIndex{\gdef,\global}
171 % \DoNotIndex{\headcommand,\hyperlink}
172 % \DoNotIndex{\if@filesw}
173 % \DoNotIndex{\if,\ifcase,\ifcat,\ifdim,\ifnum,\ifx,\InputIfFileExists}
174 % \DoNotIndex{\immediate,\input}
175 % \DoNotIndex{\insertpartheadnumber,\insertsectionhead,\insertsubsectionhead}
176 % \DoNotIndex{\insertsectionheadnumber,\insertsubsectionheadnumber}
177 % \DoNotIndex{\jobname}
178 % \DoNotIndex{\let,\lastsubsection}
179 % \DoNotIndex{\MessageBreak}
180 % \DoNotIndex{\NeedsTeXFormat,\newcommand,\newcount,\newdimen,\newif}
181 % \DoNotIndex{\newenvironment,\newtoks,\newwrite,\noexpand}
182 % \DoNotIndex{\openout}
183 % \DoNotIndex{\PackageError,\PackageWarning,\PackageInfo}
184 % \DoNotIndex{\ProcessOptions,\ProvidesPackage}
185 % \DoNotIndex{\protect}
186 % \DoNotIndex{\relax,\RequirePackage}
187 % \DoNotIndex{\setcounter,\slideentry,\space,\string}
188 % \DoNotIndex{\the}
189 % \DoNotIndex{\verbatim@,\verbatim@line,\verbatim@processline}
190 % \DoNotIndex{\write}
191 % \DoNotIndex{\xdef,\z@}
192 %
193 % \changes{0.1}{2011/06/29}{initial release}
194 % \changes{0.2}{2011/08/07}{proper package, manual and documentation}
195 % \changes{0.2}{2011/08/07}{appendix tested}
196 % \changes{0.2}{2011/08/07}{fixed navigation bar}
197 % \changes{0.2}{2011/08/07}{total number of frames not counting appended frames}
198 % \changes{0.2}{2011/08/07}{new environment lastframe}
199 % \changes{0.2}{2011/08/07}{subslideentry}
200 % \changes{0.2}{2011/08/07}{inserttotalframenumberwithsub}
201 % \changes{0.2}{2011/08/07}{new option nominiframes}
202 % \changes{0.2}{2011/08/07}{defaults for [email protected]... macros}
203 % \changes{0.2}{2011/08/07}{checking .sfp file}
204 %
205 % \newcommand{\BSF}{\textsf{BeamerSubFrame}}
206 %
207 % \title{The \BSF\ Package\\[1ex]
208 % Reordering frames in the PDF file without reordering the source}
209 % \author{Mike Kaufmann\\\href{mailto:[email protected]}{\texttt{[email protected]}}}
210 % \date{\filedate\ (v\fileversion)}
211 % ^^A--------------------------------------------------------------------------
212 % \maketitle
213 % \begin{abstract}
214 % The \BSF\ package provides a method to reorder frames in the
215 % PDF file without reordering the source. Mainly, it is meant to embed or
216 % append frames with details on some subject.
217 % \end{abstract}
218 %
219 % \tableofcontents
220 %
221 % ^^A--------------------------------------------------------------------------
222 % \section{Introduction}
223 % \subsection{Why this Package}
224 % Of course, usually a presentation is prepared for one occasion.
225 % But sometimes a presentation is used more then once, and the audience
226 % and/or the available time differs.
227 %
228 % For me, there are two kinds of audience. The first group are the
229 % sales people, who for the most part only want to know the features
230 % of a new product I developed. And the second group are the technicians,
231 % who want to know everything.
232 %
233 % So basically, on one time I have to give a presentation in half an hour,
234 % covering only the basics. But there might be questions, where I need to
235 % show some details. In this case it's nice to have the necessary frames.
236 % And an another time, I have to give a presentation in one hour, covering
237 % also the details.
238 %
239 % In both cases, it would be nice to have a presentation, where normally
240 % only the cursor keys are needed for navigation, and without the necessity
241 % of clicking on links.
242 %
243 % With Beamer, one would have to create two presentation. One with the
244 % frames containing details at the end, and another one with the details
245 % between the other frames.
246 %
247 % Now here the \BSF\ package comes in handy. After some changes to the source
248 % of the presentation with the details embedded, both version can be compiled
249 % out of the same source. To select the version, only one option must be
250 % changed.
251 %
252 % ^^A---------------------------------------------
253 % \subsection{A Warning}
254 % This package is in an early state of development (it's version
255 % \fileversion). It is already useful, but there are some restrictions (see
256 % \autoref{sec:restrictions}). And although it's not planned, the user
257 % interface may change in the future.
258 %
259 % ^^A---------------------------------------------
260 % \subsection{Feeback and Testing}
261 % Because this package is very new and still under development, any feedback
262 % is appreciated. A good location for a discussion would be the newsgroup
263 % \texttt{comp.text.tex} (or \texttt{de.comp.text.tex}).
264 %
265 % And since Beamer offers a lot of features and it is hard to test the
266 % \BSF\ package with all of them, it would be nice, if some people would
267 % do some additional testing and/or provide some presentation for testing.
268 %
269 % ^^A---------------------------------------------
270 % \subsection{Dependencies}
271 % The \BSF\ package can only be used with the Beamer class (article mode
272 % is not supported yet).
273 %
274 % Additionally, it needs the |verbatim| package.
275 %
276 % ^^A---------------------------------------------
277 % \subsection{Legal Stuff}
278 % This program is provided under the terms of the
279 % \LaTeX\ Project Public License distributed from CTAN
280 % archives in directory macros/latex/base/lppl.txt.
281 %
282 % ^^A--------------------------------------------------------------------------
283 % \section{Using the Packages}
284 % \subsection{Package Options}
285 % The \BSF\ package has three options.
286 %
287 % \DescribeOpt{embed}
288 % The option |embed| is used to put frames with details between the other
289 % frames.
290 %
291 % \DescribeOpt{append}
292 % The option |append| is used to remove the frames with details from the other
293 % frames and append them at the end of the PDF file.
294 %
295 % If none of these two options is given, |embed| is used as default. Both
296 % options are mutually exclusive. If both are given, the last one wins.
297 %
298 % \DescribeOpt{nominiframes}
299 % In themes with miniframes, there are also frame symbols for appended frames
300 % with details by default. If the option |nominiframes| is given, these frame
301 % symbols will disappear. This option has only an effect, if the |append| option
302 % is given too.
303 %
304 % ^^A---------------------------------------------
305 % \subsection{The \texttt{subframe} Environment}
306 % \DescribeEnv{subframe}
307 % For frames which should be embedded or appended contitionally (i.e.\ frames
308 % with details), the |subframe| environment must be used instead of the |frame|
309 % environment. Basically, it works the same way as the |frame| environment,
310 % i.e.\ it has the same options and arguments.
311 %
312 % For typesetting, the |frame| environment is used internally. In embed mode
313 % (i.e.\ the |embed| option is given) it inserts the option |environment=subframe|
314 % to enable the use of verbatim material in the frames. In append mode the contents
315 % of the frame is written to a file. Before the contents, |\begin{frame}|, with
316 % all arguments of the |subframe| environment appended, is inserted. And after
317 % the contents |\end{frame}| is inserted.
318 %
319 % For copying the contents, the |verbatim| package is used. So in append mode
320 % the |subframe| environment is treated as a |verbatim|
321 % environment,\footnote{Because of this, the phrase \texttt{\bslash
322 % end\{subframe\}} cannot be used in a \texttt{subframe} environment.} but
323 % without typesetting anything.
324 %
325 % There should be no parts, sections, or subsections only containing subframes,
326 % because in append mode, they would have no contents. Since it is not the
327 % intention of the \BSF\ package, to move parts, sections, or subsections, this
328 % was not even tested.
329 %
330 % ^^A---------------------------------------------
331 % \subsection{Appending Frames}
332 % \DescribeMacro\appendsubframes
333 % To append the subframes, the macro |\appendsubframes| must be called before
334 % |\end{document}|. In embed mode, the command simply does nothing. In append
335 % mode it inputs the file written by the |subframe| environments.
336 %
337 % The command is only allowed once and it can only appear right before
338 % |\end{document}|.\footnote{Both restrictions are not tested by the package yet.}
339 % Disregarding this may lead to some strange errors.
340 %
341 % The command can be omitted to remove the subframes from the PDF file in append
342 % mode. But links to them will then produce warnigs and will lead somewhere else.
343 % In themes with miniframes, the links of the miniframe symbols for subframes
344 % will lead to page 1.
345 %
346 % ^^A---------------------------------------------
347 % \subsection{Conditional Execution}
348 % \DescribeMacro\ifappend
349 % To execute some macros or insert some text according to the mode of the
350 % \BSF\ package, the marco |\ifappend| can be used. It has two arguments.
351 %
352 % \vspace{1ex}
353 % |\ifappend{|\meta{material for append mode}|}{|\meta{material for embed mode}|}|
354 %
355 % \vspace{1ex}
356 % \noindent
357 % The first argument is inserted only in append mode and the second one only in
358 % embed mode.
359 %
360 % The macro is intended for conditional links in frames and subframes. It can
361 % be used in own macros. To do something only in one mode, the argument for the
362 % other mode can be left empty.
363 %
364 % ^^A---------------------------------------------
365 % \subsection{The \texttt{lastframe} Environment}
366 % \DescribeEnv{lastframe}
367 % Normally, a presentation has a last frame, containing something like ``Thanks
368 % for listening'' (at least I learned it this way). But using a |frame|
369 % environmet, the navigation (sidebar, miniframes, and so on) appears as if the
370 % frame belongs to the last (sub)section.
371 %
372 % Using the |lastframe| environment, the navigation has the same appearance as
373 % on the title frame.
374 %
375 % It has the same options and arguments as the |frame| environment, which is
376 % used internally with all given arguments.. To enable the use of verbatim
377 % contents, it additionally inserts the option |environment=lastframe|.
378 %
379 % The |lastframe| environment must be used only for the last frame (before the
380 % |\appendsubframes| command), because it sets the counters for parts, sections,
381 % and subsections to 0. So after a ``lastframe'', sectioning will not work
382 % properly anymore.
383 %
384 % ^^A---------------------------------------------
385 % \subsection{Inserts}
386 % \DescribeMacro\inserttotalframenumber
387 % Beamers |\inserttotalframenumber| was changed. In append mode it now contains
388 % the number of frames without the subframes. In embed mode it contains the
389 % number of frames as usual.
390 %
391 % \DescribeMacro\inserttotalframenumberwithsub
392 % Additionally, the insert |\inserttotalframenumberwithsub| is available. It
393 % inserts the total number of frames including appended subframes in append mode.
394 % It is also defined in embed mode. Then it just contains the total number of
395 % frames (so the same as |\inserttotalframenumber|).
396 %
397 % ^^A---------------------------------------------
398 % \subsection{Files written}
399 % The \BSF\ package writes two files.
400 % \begin{description}
401 % \item[\texttt{\bslash jobname.sfr}] contains the contents of all subframes.
402 % The package inputs this file before the end of the document with the
403 % |\appendsubframes| command. The file is written regardless of |\nofiles|.
404 % \item[\texttt{\bslash jobname.sfp}] contains the information necessary for
405 % miniframes. It is written indirectly, using the |.aux| file. So if
406 % |\nofiles| is used, the |.sfp| file is not written too.
407 % \end{description}
408 % Both files are only written and used in append mode.
409 %
410 % ^^A---------------------------------------------
411 % \subsection{Warnings and Errors}
412 % Currently, there is one warning and one error in the \BSF\ package.
413 %
414 % When loading the package, it checks, if the Beamer class is loaded. If not,
415 % an error message will be displayed and the package is not loaded. Disregarding
416 % this error will therefore lead to additional errors.
417 %
418 % The |.sfp| file is checked at the end of the document. If it is missing,
419 % corrupted or incomplete, a warning is given out. In this case some links of
420 % miniframe symbols for subframes will lead to page 1. Of course this applies
421 % only to themes with miniframes.
422 %
423 % ^^A---------------------------------------------
424 % \subsection{Conditional Execution (2)}
425 % \DescribeMacro\ifsubframe
426 % This macro is intended to be used in themes, to make things appear differently
427 % on normal frames and subframes. This could be used to set some marker on
428 % subframes.\footnote{There is an example in the example file, which can be
429 % generated from \texttt{beamersubframe.dtx}.} The command works regardless of
430 % the mode.
431 %
432 % \vspace{1ex}
433 % |\ifsubframe{|\meta{material for subframes}|}{|\meta{material for normal frames}|}|
434 %
435 % \vspace{1ex}
436 % \noindent
437 % The first argument is inserted only in subframes and the second one only in
438 % normal frames. An unused argument may be left empty.
439 %
440 % ^^A---------------------------------------------
441 % \subsection{The \texttt{subslideentry}}
442 % \label{sec:man-subse}
443 % \DescribeMacro\subslideentry
444 % This is not a macro for normal users. It may be useful for people who want to
445 % write their own theme, willing to do more, then defining and using templates.
446 % If you are not one of these people, just skip this section.
447 %
448 % In append mode, the \BSF\ package writes a |\subslideentry| instead of a
449 % |\slideentry| for subframes to the |.nav| file. The |\subslideentry| has the
450 % same arguments as the |\slideentry|. By default, it just passes its arguments
451 % to |\slideentry|. This way it does the same as |\slideentry|, independent of
452 % the used theme. By redefining |\subslideentry|, it is possible to, for example,
453 % make miniframes for subframes appear differently form miniframes for normal
454 % frames.
455 %
456 % ^^A--------------------------------------------------------------------------
457 % \section{The Look and Feel}
458 % \subsection{In Embed Mode}
459 % In embed mode, the frames containing details are between the other frames.
460 % And navigation (navigation bar, sidebar and so on) behaves the same way, as
461 % it would without the \BSF\ package. Of course the highlighting of section
462 % and subsection names is the same too.
463 %
464 % ^^A---------------------------------------------
465 % \subsection{In Append Mode}
466 % In apend mode, the frames containing details are at the end of the PDF file.
467 %
468 % The navigation in the main part (the part of the PDF without the details)
469 % behaves as if the frames with details are not part of the PDF. And for the
470 % total number of frames, the frames with details are not counted (leading to
471 % something like ``41 / 29'' for the subframes in themes with a footline like
472 % AnnArbor).
473 %
474 % In themes with miniframes there are also frame symbols for the frames with
475 % details. Clicking on the symbols leads to these frames. But if the option
476 % |nominiframes| is given, the frame symbols will disappear and the symbol for
477 % the normal frame before the frame with details is highlighted on the frame
478 % with details.
479 %
480 % The navigation bar in the appended part (the part of the PDF with frames
481 % containing details) behaves as follows
482 % \begin{description}
483 % \item[slide and frame symbol:] behave as if the appended frames where at the
484 % end of the source, so leading to the next or previous slide or frame in
485 % the PDF (arrows), or leading to the last or first slide of a frame.
486 % \item[section and subsection symbol:] are always leading to the appropriate
487 % slides in the main part of the PDF.
488 % \item[presentation symbol:] leads to the first frame of the presentation or
489 % the last frame of the main part (before a possible appendix).
490 % \item[appendix symbol:] leads to the first or last frame of the appendix.
491 % \end{description}
492 %
493 % The links for sections and subsections in the sidebar and others lead to the
494 % first slide of the section or subsetion.
495 %
496 % In the navigation part of appended frames, the section and subsection names
497 % are the same and the highlighting is done as if the frames where embedded.
498 %
499 % ^^A--------------------------------------------------------------------------
500 % \section{A practical Approach}
501 % \subsection{The Order of Frames}
502 % If a presentation contains details on some items, there are two ways to
503 % insert them.
504 % \begin{enumerate}
505 % \item The details can be inserted right after the according item. This is
506 % useful, if it is planned to present the details.
507 % \item The details can be inserted at the end. This is useful, if it is not
508 % planned to present the details, but they might be needed to answer
509 % question.
510 % \end{enumerate}
511 %
512 % In both cases, links can be useful. In the first case, these are links to
513 % skip the details. And in the second case, these are links to jump to and
514 % return from the details.
515 %
516 % The first case is shown in \autoref{fig:embed} and the second in
517 % \autoref{fig:append}. In both pictures the black lines denote the
518 % transitions using the cursor keys, and the blue lines the transitions
519 % using links. The dashed black lines are transitions by cursor keys, which
520 % are normally not needed.
521 %
522 % \begin{figure}[htb]
523 % \includegraphics[width=\textwidth]{beamersubframe-embed.pdf}
524 % \caption{Frame Order with Details embedded}\label{fig:embed}
525 % \end{figure}
526 %
527 % \begin{figure}[htb]
528 % \includegraphics[width=\textwidth]{beamersubframe-append.pdf}
529 % \caption{Frame Order with Details appended}\label{fig:append}
530 % \end{figure}
531 %
532 % Of course, the way the links are arranged in the picuters is only an example.
533 % There are hundreds of possibilities. And how the links are arranged the best
534 % way, depends on the presentation \emph{and} on the person giving the
535 % presentation. For this section, let's consider the links in the pictures
536 % the ideal way.
537 %
538 % To use the \BSF\ package, in the source the frames must be arranged as shown
539 % in \autoref{fig:embed}. By default, the frames in the PDF file are arranged
540 % the same way. By just using the option |append|, the frames in the PDF file
541 % will be arragned as shown in \autoref{fig:append}.
542 %
543 % ^^A---------------------------------------------
544 % \subsection{Basic Changes to the Source}
545 % To use the \BSF\ package, a few changes to the source of a presentaion must
546 % be applied. In the example below, the left side shows the source before the
547 % changes and the right side the source after them.
548 %
549 % \noindent
550 % \begin{minipage}{0.49\textwidth}
551 % \footnotesize
552 % \begin{verbatim}
553 % \begin{frame}{Frame on Foo}
554 % material on foo
555 % \end{frame}
556 %
557 % \begin{frame}
558 % {Details on Foo Item b}
559 % details for item b
560 % \end{frame}
561 %
562 % \begin{frame}{Another Frame}
563 % other material
564 % \end{frame}
565 %
566 % \end{document}
567 % \end{verbatim}
568 % \end{minipage}
569 % \hfill
570 % \begin{minipage}{0.49\textwidth}
571 % \footnotesize
572 % \begin{verbatim}
573 % \begin{frame}{Frame on Foo}
574 % material on foo
575 % \end{frame}
576 %
577 % \begin{subframe}
578 % {Details on Foo Item b}
579 % details for item b
580 % \end{subframe}
581 %
582 % \begin{frame}{Another Frame}
583 % other material
584 % \end{frame}
585 % \appendsubframes
586 % \end{document}
587 % \end{verbatim}
588 % \end{minipage}
589 %
590 % Here, the |frame| environment for the frame with details was changed to the
591 % |subframe| environment, and the command |\appendsubframes| was inserted
592 % before |\end{document}|. This is the minimum of changes necessary.
593 %
594 % It is not necessary, to change the arguments of subframes. Also, there is no
595 % need to change the contents of subframes. Even the |fragile| option (for
596 % verbatim material) will work, because the |subframe| environment automatically
597 % adds the option |environment=subframe|.
598 %
599 % ^^A---------------------------------------------
600 % \subsection{Conditional Links}
601 % \label{sec:clinks}
602 % How links are used and arranged, it totally up to the user, because this is
603 % highly individual. But nevertheless, links in embed mode should be different
604 % from links in append mode. For example, a link on a frame before a subframe
605 % (or a group of subframes) with details should skip them in embed mode, while
606 % in append mode the same link should lead to the subframe (or the first
607 % subframe of the group).
608 %
609 % Let's stay with the examples shown in \autoref{fig:embed} and
610 % \autoref{fig:append}.
611 %
612 % The link ``Skip Details'' on slide 2 of ``frame on foo'' in embed mode is
613 % replaced by a link ``Goto Details'' in append mode. In the first case the
614 % destination is slide 3 of ``frame on foo'' and in the second case it is
615 % slide 1 of ``details on foo item b''.
616 %
617 % Let's say, ``frame on foo'' has a label ``lfoo'', given as option |label=lfoo|
618 % to the |frame| environment (this is also necessary, if the \BSF\ package is
619 % not used). For append mode a label must be added to the subframe ``details
620 % on foo item b''. Let's call it ``ldfoob''.
621 %
622 % For embed mode the link can be realised with
623 % \begin{verbatim}
624 % \uncover<2>{\hyperlink{lfoo<3>}{\beamerskipbutton{Skip Details}}}
625 % \end{verbatim}
626 % and for append mode with
627 % \begin{verbatim}
628 % \uncover<2>{\hyperlink{ldfoob}{\beamergotobutton{Goto Details}}}
629 % \end{verbatim}
630 %
631 % In order to make the link work as expected in both modes, without the need to
632 % change the source, |\ifappend| can be used like this:
633 % \begin{verbatim}
634 % \ifappend{\uncover<2>{\hyperlink{ldfoob}%
635 % {\beamergotobutton{Goto Details}}}}%
636 % {\uncover<2>{\hyperlink{lfoo<3>}%
637 % {\beamerskipbutton{Skip Details}}}}
638 % \end{verbatim}
639 %
640 % The link to return from the frames with details can then be done this way:
641 % \begin{verbatim}
642 % \ifappend{\uncover<4>{\hyperlink{lfoo<3>}%
643 % {\beamerreturnbutton{Return from Details}}}}{}
644 % \end{verbatim}
645 % This has the disatvantage, that in embed mode there is no link, and therefore
646 % the layout will differ between embed mode and append mode. But this can be
647 % fixed by adding an invisible button like this:
648 % \begin{verbatim}
649 % \ifappend{\uncover<4>{\hyperlink{lfoo<3>}
650 % {\beamerreturnbutton{Return from Details}}}}%
651 % {\visible<0>{\beamerreturnbutton{Return from Details}}}
652 % \end{verbatim}
653 %
654 % Typing all this every time can be a bit exhausting. So let's define some macros.
655 %
656 % For skipping or going to the details, a macro called |\linkdetail| can be
657 % defined as
658 % \begin{verbatim}
659 % \newcommand<>{\linkdetail}[4]{%
660 % \ifappend{\uncover#5{\hyperlink{#3}{\beamergotobutton{#4}}}}%
661 % {\uncover#5{\hyperlink{#1}{\beamerskipbutton{#2}}}}
662 % }
663 % \end{verbatim}
664 %
665 % The command is overlay-aware and it has four arguments:
666 % \begin{description}
667 % \item[\texttt{\#1}] is the label for the destination to go to in order to skip
668 % the details.
669 % \item[\texttt{\#2}] is the text for the link to skip the details.
670 % \item[\texttt{\#3}] is the label for the destination to go to in order to jump
671 % to the details.
672 % \item[\texttt{\#4}] is the text for the link to go to the details.
673 % \end{description}
674 % Now the link on the frame before the subframe can be written as
675 % \begin{verbatim}
676 % \linkdetails<2>{lfoo<3>}{Skip Details}{ldfoob}{Goto Details}
677 % \end{verbatim}
678 %
679 % For returning from the details, a macro called |\returndetail| can be
680 % defined as
681 % \begin{verbatim}
682 % \newcommand<>{\returndetail}[2]{%
683 % \ifappend{\uncover#3{\hyperlink{#1}{\beamerreturnbutton{#2}}}}%
684 % {\visible<0>{\beamerreturnbutton{#2}}}
685 % }
686 % \end{verbatim}
687 %
688 % The command is also overlay-aware and it has two arguments:
689 % \begin{description}
690 % \item[\texttt{\#1}] is the label for the destination to go to in order to return
691 % from details.
692 % \item[\texttt{\#2}] is the text for the link to return from details.
693 % \end{description}
694 % And the link on the subframe can be written as
695 % \begin{verbatim}
696 % \returndetails<4>{lfoo<3>}{Return from Details}
697 % \end{verbatim}
698 %
699 % Of course, these are only examples. How links are done, is up to the user.
700 % And therefore, it is also up to the user, how commands like |\linkdetail| and
701 % |\returndetail| are defined.
702 %
703 % Another example: I like my links to be active only on the slide, they are
704 % needed. On all other slides, they should be covered and inactive. So I definded
705 % the macros a bit different:
706 % \begin{verbatim}
707 % \newcommand<>{\linkdetail}[4]{%
708 % \ifappend{\uncover#5{\alt#5{\hyperlink{#3}{\beamergotobutton{#4}}}%
709 % {\beamergotobutton{#4}}}}%
710 % {\uncover#5{\alt#5{\hyperlink{#1}{\beamerskipbutton{#2}}}%
711 % {\beamerskipbutton{#2}}}}
712 % }
713 % \newcommand<>{\returndetail}[2]{%
714 % \ifappend{\uncover#3{\alt#3{\hyperlink{#1}{\beamerreturnbutton{#2}}}%
715 % {\beamerreturnbutton{#2}}}}{}
716 % }
717 % \end{verbatim}
718 %
719 % ^^A---------------------------------------------
720 % \subsection{An Example}
721 % \subsubsection{Without \BSF}
722 % As an example, let's realise frames in the order shown in \autoref{fig:embed}
723 % and \autoref{fig:append}. To show the difference of the source with and
724 % without using the \BSF\ package, first the order shown in \autoref{fig:embed}
725 % is realised without \BSF.
726 %
727 % \begin{verbatim}
728 % \documentclass{beamer}
729 % \usepackage{lmodern}
730 % \usepackage[T1]{fontenc}
731 %
732 % \begin{document}
733 % \begin{frame}{some frame}
734 % \begin{itemize}[<+->]
735 % \item there is foo
736 % \item foo is good
737 % \item and there is bar
738 % \item bar is good too
739 % \end{itemize}
740 % \end{frame}
741 %
742 % \begin{frame}<1-2>[label=lfoo]{frame on foo}
743 % \begin{itemize}[<+->]
744 % \item item a
745 % \item item b \uncover<2>{\hyperlink{lfoo<3>}%
746 % {\beamerskipbutton{Skip Details}}}
747 % \item item c
748 % \item item d
749 % \end{itemize}
750 % \end{frame}
751 %
752 % \begin{frame}{details on foo item b}
753 % \begin{itemize}[<+->]
754 % \item item b.1
755 % \item item b.2
756 % \item item b.3
757 % \item item b.4
758 % \end{itemize}
759 % \end{frame}
760 %
761 % \begin{frame}
762 % \frametitle{more details on foo item b}
763 % \begin{itemize}[<+->]
764 % \item item b.5
765 % \item item b.6
766 % \item item b.7
767 % \item item b.8
768 % \end{itemize}
769 % \end{frame}
770 %
771 % \againframe<3->{lfoo}
772 %
773 % \begin{frame}{frame on bar}
774 % \begin{itemize}[<+->]
775 % \item item w
776 % \item item x
777 % \item item y
778 % \item item z \uncover<4>{\hyperlink{lother}%
779 % {\beamerskipbutton{Skip Details}}}
780 % \end{itemize}
781 % \end{frame}
782 %
783 % \begin{frame}
784 % \frametitle{details on bar item z}
785 % \begin{itemize}[<+->]
786 % \item item z.1
787 % \item item z.2
788 % \item item z.3
789 % \item item z.4
790 % \end{itemize}
791 %
792 % \vspace{2ex}
793 % \uncover<4>{\hyperlink{lother}{\beamerskipbutton{Skip further Details}}}
794 % \end{frame}
795 %
796 % \begin{frame}{more details on bar item z}
797 % \begin{itemize}[<+->]
798 % \item item z.5
799 % \item item z.6
800 % \item item z.7
801 % \item item z.8
802 % \end{itemize}
803 % \end{frame}
804 %
805 % \begin{frame}[label=lother]{another frame}
806 % \begin{itemize}[<+->]
807 % \item conclusion 1
808 % \item conclusion 2
809 % \item conclusion 3
810 % \item conclusion 4
811 % \end{itemize}
812 % \end{frame}
813 % \end{document}
814 % \end{verbatim}
815 %
816 % ^^A-------------------------
817 % \subsubsection{With \BSF}
818 % And now the same order of frames, but this time using the \BSF\ package and
819 % with some comments.
820 % \begin{verbatim}
821 % \documentclass{beamer}
822 % \usepackage{lmodern}
823 % \usepackage[T1]{fontenc}
824 % \end{verbatim}
825 % Here, the option |embed| has to be changed to |append|, to get the order as
826 % shown in \autoref{fig:append}.
827 % \begin{verbatim}
828 % \usepackage[embed]{beamersubframe}
829 % \end{verbatim}
830 % The two commands, as explained in \autoref{sec:clinks}.
831 % \begin{verbatim}
832 % \newcommand<>{\linkdetail}[4]{%
833 % \ifappend{\uncover#5{\hyperlink{#3}{\beamergotobutton{#4}}}}%
834 % {\uncover#5{\hyperlink{#1}{\beamerskipbutton{#2}}}}
835 % }
836 % \newcommand<>{\returndetail}[2]{%
837 % \ifappend{\uncover#3{\hyperlink{#1}{\beamerreturnbutton{#2}}}}%
838 % {\visible<0>{\beamerreturnbutton{#2}}}
839 % }
840 % \end{verbatim}
841 % The next command realises a link with the same destination (argument |#1|) for
842 % both modes, but different texts (|#2| for embed mode and |#3| for append mode.
843 % \begin{verbatim}
844 % \newcommand<>{\linkdifftext}[3]{%
845 % \ifappend{\uncover#4{\hyperlink{#1}{\beamergotobutton{#3}}}}%
846 % {\uncover#4{\hyperlink{#1}{\beamerskipbutton{#2}}}}
847 % }
848 % \end{verbatim}
849 % The template defined below is an example for the use of |\ifsubframe|. It puts
850 % the text ``detail'' in the lower left corner of subframes and ``main part'' in
851 % the lower left corner of normal frames. Careful: it replaces a sidebar, so
852 % this will not work with themes like Berkeley.
853 % \begin{verbatim}
854 % \defbeamertemplate*{sidebar left}{bsf test}[1][50]
855 % {
856 % \vfill%
857 % \rlap{\hskip0.1cm\hbox{\color{fg!#1!bg}\tiny{\ifsubframe{detail}{main part}}}}%
858 % \vskip2pt%
859 % }
860 %
861 % \begin{document}
862 % \begin{frame}{some frame}
863 % \begin{itemize}[<+->]
864 % \item there is foo
865 % \item foo is good
866 % \item and there is bar
867 % \item bar is good too
868 % \end{itemize}
869 % \end{frame}
870 %
871 % \begin{frame}<1-2>[label=lfoo]{frame on foo}
872 % \begin{itemize}[<+->]
873 % \item item a
874 % \end{verbatim}
875 % Here, the link was changed.
876 % \begin{verbatim}
877 % \item item b \linkdetail<2>{lfoo<3>}{Skip Details}{ldfoob}{Goto Details}
878 % \item item c
879 % \item item d
880 % \end{itemize}
881 % \end{frame}
882 % \end{verbatim}
883 % For the next two frames the environment was changed to |subframe|. And for the
884 % first, the label |ldfoob| was added.
885 % \begin{verbatim}
886 % \begin{subframe}[label=ldfoob]{details on foo item b}
887 % \begin{itemize}[<+->]
888 % \item item b.1
889 % \item item b.2
890 % \item item b.3
891 % \item item b.4
892 % \end{itemize}
893 % \end{subframe}
894 %
895 % \begin{subframe}
896 % \frametitle{more details on foo item b}
897 % \begin{itemize}[<+->]
898 % \item item b.5
899 % \item item b.6
900 % \item item b.7
901 % \item item b.8
902 % \end{itemize}
903 %
904 % \vspace{2ex}
905 % \end{verbatim}
906 % The link to return from details was added. Because there was no link in the
907 % version without \BSF\ the layout of the frame is now changed compared to that
908 % version. But it doesn't change from one mode to the other, because of the way
909 % |\returndetails| was definded.
910 % \begin{verbatim}
911 % \returndetail<4>{lfoo<3>}{Return from Details}
912 % \end{subframe}
913 %
914 % \againframe<3->{lfoo}
915 %
916 % \begin{frame}{frame on bar}
917 % \begin{itemize}[<+->]
918 % \item item w
919 % \item item x
920 % \item item y
921 % \end{verbatim}
922 % Again, the link was changed here.
923 % \begin{verbatim}
924 % \item item z \linkdetail<4>{lother}{Skip Details}{ldbarz}{Goto Details}
925 % \end{itemize}
926 % \end{frame}
927 % \end{verbatim}
928 % For the next two frames the environment was changed to |subframe| also. And
929 % for the first, the label |ldbarz| was added.
930 % \begin{verbatim}
931 % \begin{subframe}[label=ldbarz]
932 % \frametitle{details on bar item z}
933 % \begin{itemize}[<+->]
934 % \item item z.1
935 % \item item z.2
936 % \item item z.3
937 % \item item z.4
938 % \end{itemize}
939 %
940 % \vspace{2ex}
941 % \end{verbatim}
942 % This link was changed, so the text differs between modes. But it would have
943 % been possible here, to leave the link unchanged.
944 % \begin{verbatim}
945 % \linkdifftext<4>{lother}{Skip further Details}{Return from Details}
946 % \end{subframe}
947 %
948 % \begin{subframe}{more details on bar item z}
949 % \begin{itemize}[<+->]
950 % \item item z.5
951 % \item item z.6
952 % \item item z.7
953 % \item item z.8
954 % \end{itemize}
955 %
956 % \vspace{2ex}
957 % \end{verbatim}
958 % Again, the link was added here, resulting also in a change off layout compared
959 % to the first version.
960 % \begin{verbatim}
961 % \returndetail<4>{lother}{Return from Details}
962 % \end{subframe}
963 %
964 % \begin{frame}[label=lother]{another frame}
965 % \begin{itemize}[<+->]
966 % \item conclusion 1
967 % \item conclusion 2
968 % \item conclusion 3
969 % \item conclusion 4
970 % \end{itemize}
971 % \end{frame}
972 % \end{verbatim}
973 % And finally, the |\appendsubframes| command was inserted here.
974 % \begin{verbatim}
975 % \appendsubframes
976 % \end{document}
977 % \end{verbatim}
978 %
979 % The source of the second version is available as example file, which can be
980 % generated from |beamersubframe.dtx|.
981 %
982 % ^^A--------------------------------------------------------------------------
983 % \section{Restrictions}
984 % \label{sec:restrictions}
985 % Since this is an early version of the \BSF\ package, there are some
986 % restrictions.
987 %
988 % \begin{itemize}
989 % \item The package was only tested with Beamer mode |beamer|. Using other
990 % modes may lead to strange errors.
991 % \item Supporting material, like notes, is not tested yet.
992 % \item Lectures are not tested yet.
993 % \item There is no support for subsubsections (not even tested). And it is not
994 % planned at all.
995 % \item There is no |\subframe| command.
996 % \item There is no |\againsubframe| command.
997 % \end{itemize}
998 %
999 % ^^A--------------------------------------------------------------------------
1000 % \section{Testing}
1001 % For testing the \BSF\ package the following themes were used:
1002 % \begin{itemize}
1003 % \item Dresden
1004 % \item Darmstadt
1005 % \item Berkeley
1006 % \item Montpellier
1007 % \item Malmoe
1008 % \item AnnArbor
1009 % \end{itemize}
1010 %
1011 % The themes were used without options. They where choosen to cover all types of
1012 % navigation possible with the themes delivered with Beamer. If I missed
1013 % something and this doesn't work, please let me know. If there are other things
1014 % not working (e.g.\ some inserts), please let me know too. In both cases, a
1015 % file for testing would be nice.
1016 %
1017 % ^^A--------------------------------------------------------------------------
1018 % \section{ToDo}
1019 % Although the \BSF\ package is already useful, there are a lot of things left
1020 % to do:
1021 % \begin{description}
1022 % \item[testing] Beamer has a lot of features, an many of them are still
1023 % not tested.
1024 % \item[Beamer modes] I have to admit, I didn't even test them.
1025 % \item[notes] The same here.
1026 % \item[lectures] And again, not tested.
1027 % \item[macros] There are commands, which would be nice to have, like
1028 % |\subframe|, |\againsubframe|, and |\subnote| (to get notes between
1029 % frames moved too)
1030 % \item[levels] With multiple levels of subframes, it would be possible, to have
1031 % details on details (on details on \dots). And then, one could embed the
1032 % first $n$ levels of details, and append the others.
1033 % \end{description}
1034 %
1035 % The list is not complete. If someone has an item to add, please let me know.
1036 %
1037 % ^^A--------------------------------------------------------------------------
1038 % \StopEventually{\newpage\PrintIndex}
1039 % ^^A \PrintChanges}
1040 %
1041 % ^^A--------------------------------------------------------------------------
1042 % \newpage
1043 % \section{The Code}
1044 % \subsection{The Usual}
1045 % First the usual things.
1046 % \begin{macrocode}
1047 \NeedsTeXFormat{LaTeX2e}
1048 \ProvidesPackage{beamersubframe}[\filedate\space
1049 v\fileversion\space reordering beamer frames]
1050 % \end{macrocode}
1051 %
1052 % ^^A---------------------------------------------
1053 % \subsection{Check the Class}
1054 % Since the \BSF\ package only works with the Beamer class and article mode is
1055 % not supported yet, check for the Beamer class. If it is not loaded, throw an
1056 % error message and stop loading the package.
1057 % \begin{macrocode}
1058 \@ifclassloaded{beamer}{}{%
1059 \PackageError{beamersubframe}{%
1060 The package works only with the beamer class,\MessageBreak
1061 therefore it is not loaded.
1062 }{%
1063 The package is not loaded, because it needs the\MessageBreak
1064 beamer class. Continuing may lead to additional\MessageBreak
1065 errors because of undefined commands.
1066 }
1067 \endinput
1068 }
1069 % \end{macrocode}
1070 %
1071 % ^^A---------------------------------------------
1072 % \subsection{``Variables''}
1073 % \begin{macro}{\if@bsf@append}
1074 % First there is the main flag to distinguish between append mode and embed mode.
1075 % \begin{macrocode}
1076 \newif\if@bsf@append
1077 % \end{macrocode}
1078 % \end{macro}
1079 %
1080 % \begin{macro}{\if@bsf@miniframes}
1081 % This flag is true by default. It is set to false by the option |nominiframes|.
1082 % \begin{macrocode}
1083 \newif\if@bsf@miniframes
1084 \@bsf@miniframestrue
1085 % \end{macrocode}
1086 % \end{macro}
1087 %
1088 % \begin{macro}{\if@bsf@subframe}
1089 % This flag is set to true for subframes in both modes. For normal frames it is
1090 % false.
1091 % \begin{macrocode}
1092 \newif\if@bsf@subframe
1093 \@bsf@subframefalse
1094 % \end{macrocode}
1095 % \end{macro}
1096 %
1097 % \begin{macro}{\if@bsf@nosfnum}
1098 % This flag is used for checking the |.sfp| file.
1099 % \begin{macrocode}
1100 \newif\if@bsf@nosfnum
1101 % \end{macrocode}
1102 % \end{macro}
1103 %
1104 % \begin{macro}{\if@bsf@firstline}
1105 % This flag is needed to write |\begin{frame}| in front of the arguments of a
1106 % |subframe| environment to the |.sfr| file in append mode.
1107 % \begin{macrocode}
1108 \newif\if@bsf@firstline
1109 % \end{macrocode}
1110 % \end{macro}
1111 %
1112 % \begin{macro}{\if@bsf@firstpart}
1113 % This flag is needed by |\bsfrestorepart| to initialize some macros used as
1114 % variables instead of writing the |\bsf@partpages| entry to the |.nav| file.
1115 % \begin{macrocode}
1116 \newif\if@bsf@firstpart
1117 % \end{macrocode}
1118 % \end{macro}
1119 %
1120 % \begin{macro}{\if@bsf@firstsection}
1121 % This flag is needed by |\bsfrestoresection| to initialize some macros used as
1122 % variables instead of writing the |\bsf@sectionpages| entry to the |.nav| file.
1123 % \begin{macrocode}
1124 \newif\if@bsf@firstsection
1125 % \end{macrocode}
1126 % \end{macro}
1127 %
1128 % \begin{macro}{\if@bsf@firstsubsection}
1129 % This flag is needed by |\bsfrestoresubsection| to initialize some macros used
1130 % as variables instead of writing the |\bsf@subsectionpages| entry to the |.nav|
1131 % file.
1132 % \begin{macrocode}
1133 \newif\if@bsf@firstsubsection
1134 % \end{macrocode}
1135 % \end{macro}
1136 %
1137 % \begin{macro}{\if@bsf@nosubsection}
1138 % This flag is used by |\bsfrestoresection| and |\bsfrestoresubsection| to
1139 % determine, if a section contains any subsections.
1140 % \begin{macrocode}
1141 \newif\if@bsf@nosubsection
1142 % \end{macrocode}
1143 % \end{macro}
1144 %
1145 % \begin{macro}{\if@bsf@prevnosubsection}
1146 % This flag contains the final state of |\if@bsf@nosubsection| for the previous
1147 % section.
1148 % \begin{macrocode}
1149 \newif\if@bsf@prevnosubsection
1150 % \end{macrocode}
1151 % \end{macro}
1152 %
1153 % \begin{macro}{\bsf@frame@param}
1154 % This token register is used to store the first three arguments of the
1155 % |subframe| environment in embed mode, after adding the option
1156 % |environmet=subframe|. The contents is passed to the |frame| environmet as
1157 % its first three arguments.
1158 % \begin{macrocode}
1159 \newtoks\bsf@frame@param
1160 % \end{macrocode}
1161 % \end{macro}
1162 %
1163 % \begin{macro}{\bsf@sfrout}
1164 % The stream used to write the |.sfr| file. It holds the contents of all
1165 % subframes. The file is only written and used in append mode.
1166 % \begin{macrocode}
1167 \newwrite\bsf@sfrout
1168 % \end{macrocode}
1169 % \end{macro}
1170 %
1171 % ^^A---------------------------------------------
1172 % \subsection{Options and Packages}
1173 % \begin{option}{embed}
1174 % The options are rather simple. The option |embed| just sets |\if@bsf@append|
1175 % to false.
1176 % \begin{macrocode}
1177 \DeclareOption{embed}{\@bsf@appendfalse}
1178 % \end{macrocode}
1179 % \end{option}
1180 % \begin{option}{append}
1181 % And |append| sets |\if@bsf@append| to true.
1182 % \begin{macrocode}
1183 \DeclareOption{append}{\@bsf@appendtrue}
1184 % \end{macrocode}
1185 % \end{option}
1186 % \begin{option}{nominiframes}
1187 % The option |nominiframes| sets |\if@bsf@miniframes| to false.
1188 % \begin{macrocode}
1189 \DeclareOption{nominiframes}{\@bsf@miniframesfalse}
1190 % \end{macrocode}
1191 % \end{option}
1192 % The default is set and the options are processed.
1193 % \begin{macrocode}
1194 \ExecuteOptions{embed}
1195 \ProcessOptions*\relax
1196 % \end{macrocode}
1197 % And the verbatim package is loaded.
1198 % \begin{macrocode}
1199 \RequirePackage{verbatim}
1200 % \end{macrocode}
1201
1202 % ^^A---------------------------------------------
1203 % \subsection{Navigation}
1204 % \subsubsection{Sidebar and Headline}
1205 % To get the highlighting of sections and subsections on appened subframes as if
1206 % the frames were embedded, some counters must be restored to the values, they
1207 % had at the point, the subframe appeared in the source. Additionally, for the
1208 % headline some inserts must be restored.
1209 %
1210 % To achieve this, the |subframe| environment writes a macro with all necessary
1211 % arguments to the |.sfr| file. This is done for each subframe, before its
1212 % contents, embedded in a |frame| environmet, is written to the file (see
1213 % \autoref{sec:code-subframe}).
1214 %
1215 % \begin{macro}{\bsfrestore}
1216 % The macro is called |\bsfrestore|. It is executed, when the |.sfr| file is
1217 % loaded. It restores the counters for part (|#1|), section (|#2|), and
1218 % aubsection (|#3|). It also restores the counter subsectionslide (|#4|), which
1219 % is needed for miniframes.
1220 %
1221 % Then |\insertsectionhead| and |\insertsubsectionhead| are restored to their
1222 % meanings at the point, the subframe appeard in the source. These meanings were
1223 % stored to the two macros |\bsf@sectionhead|\meta{part}|.|\meta{section} and
1224 % |\bsf@subsectionhead|\meta{part}|.|\meta{section}|.|\meta{subsection} by the
1225 % |subframe| environment (see \autoref{sec:code-subframe}).
1226 %
1227 % After that, the inserts for the part, section, and subsection numbers are
1228 % restored.
1229 %
1230 % The macro is also used by the |lastframe| environment (see
1231 % \autoref{sec:code-lastframe}).
1232 % \begin{macrocode}
1233 \newcommand{\bsfrestore}[4]{%
1234 \setcounter{part}{#1}%
1235 \setcounter{section}{#2}%
1236 \setcounter{subsection}{#3}%
1237 \setcounter{subsectionslide}{#4}%
1238 \expandafter\let\expandafter\insertsectionhead
1239 \csname bsf@sectionhead\the\c@part.\the\c@section\endcsname
1240 \expandafter\let\expandafter\insertsubsectionhead
1241 \csname bsf@subsectionhead\the\c@part.\the\c@section.\the\c@subsection\endcsname
1242 \def\insertpartheadnumber{#1}%
1243 \def\insertsectionheadnumber{#2}%
1244 \def\insertsubsectionheadnumber{#3}%
1245 }
1246 % \end{macrocode}
1247 % \end{macro}
1248 %
1249 % ^^A-------------------------
1250 % \subsubsection{Miniframes}
1251 % \label{sec:code-miniframes}
1252 % To typset miniframes, Beamer writes a |\slideentry| with the necessary
1253 % arguments to the |.nav| file. Because miniframes should appear, as if the
1254 % subframes are embedded, the |subframe| environment has to write such an entry
1255 % at the point, the subframe appears in the source. But instead of a
1256 % |\slideentry|, \BSF\ writes a |\subslideentry| (see \autoref{sec:man-subse}).
1257 %
1258 % Argument |#4| of |\slideentry| contains the start page and the end page of the
1259 % frame. Unfortunately, for subframes these numbers are unknown, until the
1260 % |.sfr| file was loaded by |\appendsubframes|.
1261 %
1262 % To get around this, for each subframe two macros are used. Their names \linebreak
1263 % are
1264 % |\bsf@substartpage|\meta{part}|.|\meta{section}|.|\meta{subsection}|.|\meta{subsectionslide}
1265 % and \linebreak
1266 % |\bsf@subendpage|\meta{part}|.|\meta{section}|.|\meta{subsection}|.|\meta{subsectionslide}.
1267 % Here \meta{part}, \meta{section} and so on are the numbers.
1268 %
1269 % Now at the point where the subframe appears in the souce, the |\subslideentry|
1270 % is written. Instead of the unknown frame numbers, it contains the sequence
1271 % |{\bsf@usenum{bsf@substartpage...}/\bsf@usenum{bsf@subendpage...}}| as argument
1272 % |#4|. After a subframe was typeset by loading the |.sfr| file, the necessary
1273 % information is written to the |.sfp| file. In the next \TeX\ run, when loading
1274 % the |.sfp| file at the beginning of the document (see \autoref{sec:code-beginend}),
1275 % these macros are all defined.
1276 %
1277 % \begin{macro}{\bsf@subnum}
1278 % The first macro involved is just a shortcut to get the numbers.
1279 % \begin{macrocode}
1280 \def\bsf@subnum{%
1281 \the\c@part.\the\c@section.\the\c@subsection.\the\c@subsectionslide
1282 }
1283 % \end{macrocode}
1284 % \end{macro}
1285 %
1286 % Beamer uses the macro |\beamer@writeslidentry| to write the |\slideentry| and
1287 % the |\beamer@framepages| entry (used for the navigation bar) to the |.nav|
1288 % file. For subframes this is split into two macros.
1289 %
1290 % \begin{macro}{\beamer@writeslidentry@miniframes}
1291 % The |\subslideentry| is written by |\beamer@writeslidentry@miniframes|. The
1292 % macro is called directly by the |subframe| environment (see
1293 % \autoref{sec:code-subframe}).
1294 % \begin{macrocode}
1295 \def\beamer@writeslidentry@miniframes{%
1296 \addtocontents{nav}%
1297 {\protect\headcommand{%
1298 \protect\subslideentry{\the\c@section}{\the\c@subsection}%
1299 {\the\c@subsectionslide}%
1300 {\protect\bsf@usenum{bsf@substartpage\bsf@subnum}/%
1301 \protect\bsf@usenum{bsf@subendpage\bsf@subnum}}%
1302 {\lastsubsection}{\the\c@part}}}%
1303 }
1304 % \end{macrocode}
1305 % \end{macro}
1306 %
1307 % \begin{macro}{\beamer@writeslidentry@navbar}
1308 % The |\beamer@framepages| entry is written by |\beamer@writeslidentry@navbar|.
1309 % And it also writes the |\bsfsubframepages| entry to the |.sfp| file.
1310 %
1311 % This macro is used to replace |\beamer@writeslidentry|, before the |.sfr| file
1312 % is loaded. This is done in |\appendsubframes| (see \autoref{sec:code-appendsub}).
1313 % \begin{macrocode}
1314 \def\beamer@writeslidentry@navbar{%
1315 \expandafter\beamer@ifempty\expandafter{\beamer@framestartpage}{}% does not happen normally
1316 {%else
1317 \addtocontents{nav}%
1318 {\protect\headcommand{%
1319 \protect\beamer@framepages{\beamer@framestartpage}{\beamer@frameendpage}}}%
1320 \addtocontents{sfp}{%
1321 \protect\bsfsubframepages{\the\c@part}{\the\c@section}{\the\c@subsection}%
1322 {\the\c@subsectionslide}{\beamer@framestartpage}{\beamer@frameendpage}}%
1323 \clearpage\beamer@notesactions%
1324 }%
1325 }
1326 % \end{macrocode}
1327 % \end{macro}
1328 %
1329 % \begin{macro}{\subslideentry}
1330 % The |\subslideentry| is initialized in a way that it does the same as the
1331 % |\slideentry|. Because |\slideentry| is refedined by some themes, |\let| can
1332 % not be used here.
1333 % \begin{macrocode}
1334 \def\subslideentry{\slideentry}
1335 % \end{macrocode}
1336 % \end{macro}
1337 %
1338 % \begin{macro}{\bsfsubframepages}
1339 % The |.sfp| file contains one |\bsfsubframepages| entry for each subframe. The
1340 % arguments are the part number (|#1|), the section number (|#2|), the subsection
1341 % number (|#3|), the subsectionslide number (|#4|), and the first (|#5|) and the
1342 % last page of the subframe (|#6|).
1343 %
1344 % When the |.sfp| file is loaded, each |\bsfsubframepages| defines two macros
1345 % |\bsf@substartpage...| and |\bsf@subendpage...| used by the |\subslideentry|.
1346 % \begin{macrocode}
1347 \def\bsfsubframepages#1#2#3#4#5#6{%
1348 \expandafter\def\csname bsf@substartpage#1.#2.#3.#4\endcsname{#5}%
1349 \expandafter\def\csname bsf@subendpage#1.#2.#3.#4\endcsname{#6}%
1350 }
1351 % \end{macrocode}
1352 % \end{macro}
1353 %
1354 % \begin{macro}{\bsf@usenum}
1355 % The macro |\bsf@usenum|, used in the |\subslideentry|, sets a default in case
1356 % the |\bsf@substartpage...| and |\bsf@subendpage...| macros are not defined due
1357 % to a missing, corrupted or incomplete |.sfp| file. Without this, there could
1358 % be errors which would persist on every subsequent run of \TeX.
1359 % \begin{macrocode}
1360 \def\bsf@usenum#1{%
1361 \@ifundefined{#1}{1}{\csname #1\endcsname}%
1362 }
1363 % \end{macrocode}
1364 % \end{macro}
1365 %
1366 % \begin{macro}{\bsf@checksfp}
1367 % In order to warn the user about a missing, corrupted or incomplete |.sfp| file,
1368 % the file is checked. This is done indirectly by checking, if all
1369 % |\bsf@substartpage...| and |\bsf@subendpage...| macros in the current |.nav|
1370 % file are defined.
1371 %
1372 % For this all commands in the |.nav| file are executed using Beamers |\dohead|
1373 % command. Because some of the commands would typeset something, they are
1374 % disabled and everything is done in a group to keep the changes local.
1375 %
1376 % The macro |\bsf@usenum| is also redefined to set the flag |\if@bsf@nosfnum| to
1377 % true in case one of the checked macros is undefined.
1378 % \begin{macrocode}
1379 \def\bsf@checksfp{%
1380 \begingroup
1381 \@bsf@nosfnumfalse
1382 \def\bsf@usenum##1{%
1383 \@ifundefined{##1}{\@bsf@nosfnumtrue}{}}
1384 \def\slideentry##1##2##3##4##5##6{}%
1385 \def\partentry##1##2{}%
1386 \def\sectionentry##1##2##3##4##5{}%
1387 \def\beamer@subsectionentry##1##2##3##4##5{}%
1388 \def\subslideentry##1##2##3##4##5##6{%
1389 \bsf@checksfnum(##4)}%
1390 \dohead
1391 \if@bsf@nosfnum
1392 \PackageWarningNoLine{Beamer SubFrame}{%
1393 Missing, incomplete or corrupted file\MessageBreak
1394 \jobname.sfp! Links for miniframes of\MessageBreak
1395 subframes may be wrong. Please run TeX\MessageBreak
1396 again}
1397 \fi
1398 \endgroup
1399 }
1400 % \end{macrocode}
1401 % \end{macro}
1402 %
1403 % \begin{macro}{\bsf@checksfnum}
1404 % The macro |\bsf@checksfnum| is just used by |\bsf@checksfp| to get rid of the
1405 % slash in argument |#4| of the |\subslideentry|.
1406 % \begin{macrocode}
1407 \def\bsf@checksfnum(#1/#2){#1#2}
1408 % \end{macrocode}
1409 % \end{macro}
1410 %
1411 % ^^A-------------------------
1412 % \subsubsection{Navigation Bar}
1413 % Getting the navigation bar right takes some effort. First lets take a look,
1414 % what Beamer does to get the necessary information for the navigation bar.
1415 %
1416 % \paragraph{How Beamer does it}~\\
1417 % Beamer writes several different entries to the |.nav| file.
1418 % \begin{description}
1419 % \item[\texttt{\bslash beamer@framepages}] with the first and the last page of
1420 % the frame as arguments. It is written for every frame at its end.
1421 % \item[\texttt{\bslash beamer@subsectionpages}] with the first and the last
1422 % page of the subsection as arguments. It is written by the |\subsection|
1423 % command for the previous subsection, as well as by |\section| and
1424 % |\part| and the end of the document for the last subsection.
1425 % \item[\texttt{\bslash beamer@sectionpages}] with the first and the last page
1426 % of the section as arguments. It is written by the |\section| command for
1427 % the previous section, as well as by |\part| and the end of the document
1428 % for the last section.
1429 % \item[\texttt{\bslash beamer@partpages}] with the first and the last page of
1430 % the part as arguments. It is written by the |\part| command for the
1431 % previous part and the end of the document for the last part.
1432 % \item[\texttt{\bslash beamer@documentpages}] with the last page of the
1433 % documnet as argument. It is written at the end of the document.
1434 % \end{description}
1435 %
1436 % The macros in the |.nav| file are executed once for every page (i.e.\ slide).
1437 % By this the entry |\beamer@framepages| sets the macro |\beamer@startpageofframe|
1438 % to its first argument and |\beamer@endpageofframe| to its second argument, but
1439 % only if the current page is $\ge$ than the first argument and $\le$ than the
1440 % second one. Similar macros are set the same way by the other entries.
1441 %
1442 % The frame icon is then typeset in a way, that
1443 % \begin{itemize}
1444 % \item the left arrow points to page |\beamer@startpageofframe| $-1$,
1445 % \item the left part of the frame symbol points to page |\beamer@startpageofframe|,
1446 % \item the right part of the frame symbol points to page |\beamer@endpageofframe|,
1447 % \item and the right arrow points to page |\beamer@endpageofframe| $+1$.
1448 % \end{itemize}
1449 % The arrows are limited 1 or |\beamer@endpageofdocument| respectively. The icons
1450 % for subsections and sections are typeset in a similar way.
1451 %
1452 % The right part of the presentation symbol or (if there is an appendix) of the
1453 % appendix symbol will point to page |\beamer@endpageofdocument|.
1454
1455 % \paragraph{How \BSF\ does it}~\\
1456 % The frame icon should point to the previous or next frame or subframe in the
1457 % PDF file. This is simply achieved by writing the |\beamer@framepages| entry
1458 % with |\beamer@writeslidentry@navbar| (see \autoref{sec:code-miniframes}) for
1459 % every subframe.
1460 %
1461 % The section icon should point to the first and last page of the section the
1462 % subframe belongs to in the main part. For this, the first page of the first
1463 % and the last page of the last subframe of a section is needed also. The
1464 % information is stored in two steps.
1465 % \begin{enumerate}
1466 % \item A macro |\bsfrestoresection| is written to the |.sfr| file for each
1467 % section. Its arguments are the number of the previous section and the
1468 % first page of the section just started.
1469 % \item When loading the |.sfr| file, the first |\bsfrestoresection| entry
1470 % initializes some makros (used as variables). All subsequent entries
1471 % write a |\bsf@sectionpages| entry to the |.nav| file, which has the
1472 % necessary pages as arguments.
1473 % \end{enumerate}
1474 % For parts and subsections corresponding entries are written to the files. And
1475 % for the last part, section, and subsection |\[email protected]| entries are written
1476 % after appending the subframes.
1477 %
1478 % The |\[email protected]| entries written by Beamer at the end of the document
1479 % would mix up the links of the navigation bar. It is not possible to prevent
1480 % writing these entries. Instead they are disabled after appending the subframes.
1481 % Since they would stay disabled for all pages after the first, they are
1482 % reenabled at the beginning of the |.nav| file. Also, these entries have to be
1483 % written before appending the subframes, in order to make the navigation bar
1484 % work correctly for the last section and subsection in the main part.
1485 %
1486 % Since this is also done for the |\beamer@documentpages| entry, the right
1487 % arrows of the section and subsection icons are limited to the last page of the
1488 % main part, i.e.\ the page before the first subframe. The same applies to the
1489 % right part of the presentation or appendix symbol.
1490 %
1491 % Unfortunately, this would apply to the right arrows of the slide icon and the
1492 % frame icon too. Therefore the package writes a |\bsf@documentpages| entry to
1493 % the |.nav| file after appending the subframes. Additionally, two macros of
1494 % Beamer are redefined to use this information, instead of the information of
1495 % the |\beamer@documentpages| entry.
1496 %
1497 % \paragraph{The Macros}~\\
1498 % Lets start with the two redefined macros. The originals are defined in
1499 % \textsf{beamerbasenavigation.sty}.
1500 %
1501 % \begin{macro}{\hyperlinkslidenext}
1502 % The new definition of |\hyperlinkslidenext| uses |\bsf@nextpage| instead of
1503 % |\beamer@nextpage|.
1504 % \begin{macrocode}
1505 \def\hyperlinkslidenext{%
1506 \bsf@nextpage\c@page%
1507 \hyperlink{Navigation\the\beamer@tempcount}}
1508 % \end{macrocode}
1509 % \end{macro}
1510 %
1511 % \begin{macro}{\hyperlinkframestartnext}
1512 % The new definition of |\hyperlinkframestartnext| also uses |\bsf@nextpage|
1513 % instead of |\beamer@nextpage|.
1514 % \begin{macrocode}
1515 \def\hyperlinkframestartnext{%
1516 \bsf@nextpage\beamer@endpageofframe%
1517 \hyperlink{Navigation\the\beamer@tempcount}}
1518 % \end{macrocode}
1519 % \end{macro}
1520 %
1521 % \begin{macro}{\bsf@nextpage}
1522 % The macro |\bsf@nextpage| works like |\beamer@nextpage| (from
1523 % \textsf{beamerbasenavigation.sty}), but it uses |\bsf@endpageofdocument| as
1524 % the last page for links, instead of |\beamer@endpageofdocument|.
1525 % \begin{macrocode}
1526 \def\bsf@nextpage#1{%
1527 \beamer@tempcount=#1%
1528 \advance\beamer@tempcount by1\relax%
1529 \ifnum\beamer@tempcount>\bsf@endpageofdocument%
1530 \beamer@tempcount=\bsf@endpageofdocument%
1531 \fi}
1532 % \end{macrocode}
1533 % \end{macro}
1534 %
1535 % \begin{macro}{\bsf@documentpages}
1536 % The |\bsf@endpageofdocument| is defined by the |\bsf@documentpages| entry of
1537 % the |.nav| file.
1538 % \begin{macrocode}
1539 \def\bsf@documentpages#1{\def\bsf@endpageofdocument{#1}}
1540 % \end{macrocode}
1541 % \end{macro}
1542 %
1543 % \begin{macro}{\bsf@endpageofdocument}
1544 % And |\bsf@endpageofdocument| is initialized to reflect the original.
1545 % \begin{macrocode}
1546 \def\bsf@endpageofdocument{\beamer@endpageofdocument}
1547 % \end{macrocode}
1548 % \end{macro}
1549 %
1550 % To disable and reenable the |\[email protected]| entries, first
1551 % \begin{macro}{\beamer@partpages@orig}
1552 % the macro |\beamer@partpages|,
1553 % \begin{macrocode}
1554 \let\beamer@partpages@orig\beamer@partpages
1555 % \end{macrocode}
1556 % \end{macro}
1557 %
1558 % \begin{macro}{\beamer@subsectionpages@orig}
1559 % the macro |\beamer@subsectionpages|,
1560 % \begin{macrocode}
1561 \let\beamer@subsectionpages@orig\beamer@subsectionpages
1562 % \end{macrocode}
1563 % \end{macro}
1564 %
1565 % \begin{macro}{\beamer@sectionpages@orig}
1566 % the macro |\beamer@sectionpages|,
1567 % \begin{macrocode}
1568 \let\beamer@sectionpages@orig\beamer@sectionpages
1569 % \end{macrocode}
1570 % \end{macro}
1571 %
1572 % \begin{macro}{\beamer@documentpages@orig}
1573 % and the macro |\beamer@documentpages| are saved.
1574 % \begin{macrocode}
1575 \let\beamer@documentpages@orig\beamer@documentpages
1576 % \end{macrocode}
1577 % \end{macro}
1578 %
1579 % \begin{macro}{\bsf@enablenaventries}
1580 % The command |\bsf@enablenaventries| restores the original meanings of the
1581 % |\[email protected]| entries. It is written to the |.nav| file at the beginning
1582 % of the document (see \autoref{sec:code-beginend}).
1583 % \begin{macrocode}
1584 \def\bsf@enablenaventries{%
1585 \let\beamer@partpages\beamer@partpages@orig
1586 \let\beamer@subsectionpages\beamer@subsectionpages@orig
1587 \let\beamer@sectionpages\beamer@sectionpages@orig
1588 \let\beamer@documentpages\beamer@documentpages@orig
1589 }
1590 % \end{macrocode}
1591 % \end{macro}
1592 %
1593 % \begin{macro}{\bsf@disablenaventries}
1594 % And |\bsf@disablenaventries| disables the entries by letting them gobble their
1595 % arguments. It is written to the |.nav| file after appending the subframes (see
1596 % \autoref{sec:code-appendsub}).
1597 % \begin{macrocode}
1598 \def\bsf@disablenaventries{%
1599 \let\beamer@partpages\@gobbletwo
1600 \let\beamer@subsectionpages\@gobbletwo
1601 \let\beamer@sectionpages\@gobbletwo
1602 \let\beamer@documentpages\@gobble
1603 }
1604 % \end{macrocode}
1605 % \end{macro}
1606 %
1607 % In order to write the |\bsfrestore...| entries to the |.sfr| file, the
1608 % sectioning commands must be extended. First the originals for
1609 %
1610 % \begin{macro}{\part@orig}
1611 % the macro |\part|,
1612 % \begin{macrocode}
1613 \let\part@orig\part
1614 % \end{macrocode}
1615 % \end{macro}
1616 %
1617 % \begin{macro}{\section@orig}
1618 % the macro |\section|,
1619 % \begin{macrocode}
1620 \let\section@orig\section
1621 % \end{macrocode}
1622 % \end{macro}
1623 %
1624 % \begin{macro}{\subsection@orig}
1625 % and the macro |\subsection| are saved.
1626 % \begin{macrocode}
1627 \let\subsection@orig\subsection
1628 % \end{macrocode}
1629 % \end{macro}
1630 % The sectioning macros are only redefined in append mode.
1631 % \begin{macrocode}
1632 \if@bsf@append
1633 % \end{macrocode}
1634 %
1635 % \begin{macro}{\part}
1636 % The new version of |\part| writes the |\bsfrestorepart| entry to the |.sfr|
1637 % file. The original version is called at the end, so its arguments are of no
1638 % concern here. But because of that, |\c@part| still contains the number of the
1639 % previous part. Here, |\c@page| already contains the number of the first page
1640 % of the new part.
1641 % \begin{macrocode}
1642 \def\part{%
1643 \immediate\write\bsf@sfrout{\string\bsfrestorepart{\the\c@part}%
1644 {\the\c@page}}%
1645 \part@orig
1646 }
1647 % \end{macrocode}
1648 % \end{macro}
1649 %
1650 % \begin{macro}{\section}
1651 % The new version of |\section| writes the |\bsfrestoresection| entry to the
1652 % |.sfr| file. Besides that, it works like the new |\part| command.
1653 % \begin{macrocode}
1654 \def\section{%
1655 \immediate\write\bsf@sfrout{\string\bsfrestoresection{\the\c@section}%
1656 {\the\c@page}}%
1657 \section@orig
1658 }
1659 % \end{macrocode}
1660 % \end{macro}
1661 %
1662 % \begin{macro}{\subsection}
1663 % And the new version of |\subsection| writes the |\bsfrestoresubsection| entry
1664 % to the |.sfr| file. It also works like the new |\part| command.
1665 % \begin{macrocode}
1666 \def\subsection{%
1667 \immediate\write\bsf@sfrout{\string\bsfrestoresubsection{\the\c@subsection}%
1668 {\the\c@page}}%
1669 \subsection@orig
1670 }
1671 \fi
1672 % \end{macrocode}
1673 % \end{macro}
1674 %
1675 % The |\bsfrestore...| entries are executed, when loading the |.sfr| file.
1676 % Basically, they write the |\bsf@... pages| entries to the |.nav| file. But
1677 % the first time, they just initialize some macros used as variables, because
1678 % at this point only the first page of the first subframe of a part, section
1679 % or subsection and the first page of the part, section or subsection itself
1680 % are known.
1681 %
1682 % \begin{macro}{\bsfrestorepart}
1683 % On the first call, |\bsfrestorepart| stores the the first page of the new part
1684 % (|#2|), the number of the previous part (|#1|), and the number of the first
1685 % page of the first subframe belonging to the new part (|c@page|).
1686 % \begin{macrocode}
1687 \def\bsfrestorepart#1#2{%
1688 \if@bsf@firstpart
1689 \@bsf@firstpartfalse
1690 \def\bsf@partstartpage{#2}%
1691 \def\bsf@prevpart{#1}%
1692 \edef\bsf@partfirstsubframepage{\the\c@page}%
1693 \else
1694 % \end{macrocode}
1695 % On all subsequent calls, if there is a new part, the last page of the last
1696 % subframe belonging to the previous part (in |\@tempcnta|) and the last page
1697 % of the previous part (in |\@tempcntb|) are calculated.
1698 % \begin{macrocode}
1699 \@tempcnta=\bsf@prevpart\relax
1700 \ifnum#1>\@tempcnta
1701 \@tempcnta\c@page\advance\@tempcnta -1\relax
1702 \@tempcntb=#2\relax\advance\@tempcntb -1\relax
1703 % \end{macrocode}
1704 % Then the |\bsf@partpages| entry is written to the |.nav| file. Here
1705 % |\addtocontents| can not be used, because it doesn't work, if |\bsfrestorepart|
1706 % appears after the last subframe.
1707 % \begin{macrocode}
1708 \if@filesw
1709 \immediate\write\@auxout{\string\@writefile{nav}%
1710 {\noexpand\headcommand{%
1711 \noexpand\bsf@partpages{\bsf@partfirstsubframepage}%
1712 {\the\@tempcnta}{\bsf@partstartpage}{\the\@tempcntb}}}}%
1713 \fi
1714 % \end{macrocode}
1715 % After that, the ``variables'' are reinitialized.
1716 % \begin{macrocode}
1717 \def\bsf@partstartpage{#2}%
1718 \def\bsf@prevpart{#1}%
1719 \edef\bsf@partfirstsubframepage{\the\c@page}%
1720 \fi
1721 \fi
1722 }
1723 % \end{macrocode}
1724 % Two of the ``variables'' must be initialized, in order to make the package
1725 % work for presentations without sectioning commands.
1726 % \begin{macrocode}
1727 \def\bsf@partstartpage{1}%
1728 \def\bsf@prevpart{0}%
1729 % \end{macrocode}
1730 % \end{macro}
1731 %
1732 % \begin{macro}{\bsfrestoresection}
1733 % The macros |\bsfrestoresection| and |\bsfrestoresubsection| work the same way
1734 % as |\bsfrestorepart|. But additionally, they must keep track of sections
1735 % without subsections. For this, the flags |\if@bsf@nosubsection| and
1736 % |\if@bsf@prevnosubsection| and the macro |\bsf@prevsectionstartpage| are used.
1737 % \begin{macrocode}
1738 \def\bsfrestoresection#1#2{%
1739 \if@bsf@firstsection
1740 \@bsf@firstsectionfalse
1741 \def\bsf@prevsectionstartpage{#2}%
1742 \@bsf@nosubsectiontrue
1743 \@bsf@prevnosubsectionfalse
1744 \def\bsf@sectionstartpage{#2}%
1745 \def\bsf@prevsection{#1}%
1746 \edef\bsf@sectionfirstsubframepage{\the\c@page}%
1747 \else
1748 \@tempcnta=\bsf@prevsection\relax
1749 \ifnum#1>\@tempcnta
1750 % \end{macrocode}
1751 % When a new section starts, the start page and the |\if@bsf@nosubsection| flag
1752 % of the previous section are stored.
1753 % \begin{macrocode}
1754 \edef\bsf@prevsectionstartpage{\bsf@sectionstartpage}%
1755 \if@bsf@nosubsection
1756 \@bsf@prevnosubsectiontrue
1757 \else
1758 \@bsf@prevnosubsectionfalse
1759 \fi
1760 % \end{macrocode}
1761 % The flag |\if@bsf@nosubsection| is set to false, because the new section has
1762 % no subsections yet.
1763 % \begin{macrocode}
1764 \@bsf@nosubsectiontrue
1765 % \end{macrocode}
1766 % And the number of the previous subsection is set to $-1$, because the
1767 % subsection counter will be reset to 0 on the start of each section.
1768 % \begin{macrocode}
1769 \def\bsf@prevsubsection{-1}%
1770 \@tempcnta\c@page\advance\@tempcnta -1\relax
1771 \@tempcntb=#2\relax\advance\@tempcntb -1\relax
1772 \if@filesw
1773 \immediate\write\@auxout{\string\@writefile{nav}%
1774 {\noexpand\headcommand{%
1775 \noexpand\bsf@sectionpages{\bsf@sectionfirstsubframepage}%
1776 {\the\@tempcnta}{\bsf@sectionstartpage}{\the\@tempcntb}}}}%
1777 \fi
1778 \def\bsf@sectionstartpage{#2}%
1779 \def\bsf@prevsection{#1}%
1780 \edef\bsf@sectionfirstsubframepage{\the\c@page}%
1781 \fi
1782 \fi
1783 }
1784 \def\bsf@sectionstartpage{1}%
1785 \def\bsf@prevsection{0}%
1786 % \end{macrocode}
1787 % \end{macro}
1788 %
1789 % \begin{macro}{\bsfrestoresubsection}
1790 % The macro |\bsfrestoresubsection| uses the flags |\if@bsf@nosubsection| and
1791 % |\if@bsf@prevnosubsection| and the macro |\bsf@prevsectionstartpage| to set
1792 % the correct range of pages.
1793 % \begin{macrocode}
1794 \def\bsfrestoresubsection#1#2{%
1795 \if@bsf@firstsubsection
1796 \@bsf@firstsubsectionfalse
1797 \@bsf@prevnosubsectionfalse
1798 \def\bsf@subsectionstartpage{#2}%
1799 \def\bsf@prevsubsection{#1}%
1800 \edef\bsf@subsectionfirstsubframepage{\the\c@page}%
1801 \else
1802 \@tempcnta=\bsf@prevsubsection\relax
1803 \ifnum#1>\@tempcnta
1804 \@tempcnta\c@page\advance\@tempcnta -1\relax
1805 % \end{macrocode}
1806 % Since the |\[email protected]| entries are written (indirectly) at the point of the
1807 % next part, section or subsection, the entry for let's say subsection 1.3 would
1808 % be written at the point of subsection 3.1, if section 2 has no subsections.
1809 % So if the previous section had no subsection, its start page is used to
1810 % calculate the last page of the last subsection instead of the start page of
1811 % this subsection.
1812 % \begin{macrocode}
1813 \if@bsf@prevnosubsection
1814 \@tempcntb=\bsf@prevsectionstartpage\relax
1815 \else
1816 \@tempcntb=#2\relax
1817 \fi
1818 \advance\@tempcntb -1\relax
1819 % \end{macrocode}
1820 % Because |\if@bsf@prevnosubsection| can only be used at the point of the first
1821 % subsection of a new section, it is set to false.
1822 % \begin{macrocode}
1823 \@bsf@prevnosubsectionfalse
1824 \@bsf@nosubsectionfalse
1825 \if@filesw
1826 \immediate\write\@auxout{\string\@writefile{nav}%
1827 {\noexpand\headcommand{%
1828 \noexpand\bsf@subsectionpages{\bsf@subsectionfirstsubframepage}%
1829 {\the\@tempcnta}{\bsf@subsectionstartpage}{\the\@tempcntb}}}}%
1830 \fi
1831 \def\bsf@subsectionstartpage{#2}%
1832 \def\bsf@prevsubsection{#1}%
1833 \edef\bsf@subsectionfirstsubframepage{\the\c@page}%
1834 \fi
1835 \fi
1836 }
1837 \def\bsf@subsectionstartpage{1}%
1838 \def\bsf@prevsubsection{0}%
1839 % \end{macrocode}
1840 % \end{macro}
1841 %
1842 % \begin{macro}{\bsf@partpages}
1843 % The |\bsf@partpages| macro is similar to the |\beamer@partpages| macro (from
1844 % \textsf{beamerbasenavigation.sty}). But to decide if the first and the last
1845 % page of a part are stored in |\beamer@startpageofpart| and |\beamer@endpageofpart|,
1846 % it uses the first page of the first subframe (|#1|) and the last page of the
1847 % last subframe (|#2|) belonging to the part.
1848 %
1849 % There may be parts with no subframes. In this case, |#1| is greater then |#2|
1850 % and the first (|#3|) and last page (|#4|) of the part are not stored.
1851 % \begin{macrocode}
1852 \def\bsf@partpages#1#2#3#4{%
1853 \ifnum\c@page<#1%
1854 \else%
1855 \ifnum\c@page>#2%
1856 \else%
1857 \gdef\beamer@startpageofpart{#3}%
1858 \gdef\beamer@endpageofpart{#4}%
1859 \fi%
1860 \fi%
1861 }
1862 % \end{macrocode}
1863 % \end{macro}
1864 %
1865 % \begin{macro}{\bsf@sectionpages}
1866 % The macro |\bsf@sectionpages| works the same way as |\bsf@partpages|.
1867 % \begin{macrocode}
1868 \def\bsf@sectionpages#1#2#3#4{%
1869 \ifnum\c@page<#1%
1870 \else%
1871 \ifnum\c@page>#2%
1872 \else%
1873 \gdef\beamer@startpageofsection{#3}%
1874 \gdef\beamer@endpageofsection{#4}%
1875 \fi%
1876 \fi%
1877 }
1878 % \end{macrocode}
1879 % \end{macro}
1880 %
1881 % \begin{macro}{\bsf@subsectionpages}
1882 % And |\bsf@sectionpages| works the same way as |\bsf@partpages| too.
1883 % \begin{macrocode}
1884 \def\bsf@subsectionpages#1#2#3#4{%
1885 \ifnum\c@page<#1%
1886 \else%
1887 \ifnum\c@page>#2%
1888 \else%
1889 \gdef\beamer@startpageofsubsection{#3}%
1890 \gdef\beamer@endpageofsubsection{#4}%
1891 \fi%
1892 \fi%
1893 }
1894 % \end{macrocode}
1895 % \end{macro}
1896 %
1897 % ^^A-------------------------
1898 % \subsubsection{Inserts}
1899 % Beamers |\inserttotalframenumber| is changed by simply writing its definition
1900 % a second time to the |.nav| file, thus overwriting Beamers original definition.
1901 % This is done at the end of the document (see \autoref{sec:code-beginend}).
1902 % The necessary frame number is stored in |\bsf@totalframenumber| before
1903 % appending the subframes (see \autoref{sec:code-appendsub}).
1904 % \begin{macro}{\inserttotalframenumberwithsub}
1905 % The new |\inserttotalframenumberwithsub| is written at the end of the documnet
1906 % (see \autoref{sec:code-beginend}), regardless of the mode of \BSF, so it's
1907 % always defined. But to work on the first \TeX\ run, it must be initialized.
1908 % \begin{macrocode}
1909 \def\inserttotalframenumberwithsub{\inserttotalframenumber}
1910 % \end{macrocode}
1911 % \end{macro}
1912 %
1913 % ^^A-------------------------
1914 % \subsubsection{The \texttt{subframe} environment}
1915 % \label{sec:code-subframe}
1916 % \begin{environment}{subframe}
1917 % The |subframe| environment is defined differently for the two modes. In append
1918 % mode it is basically a verbatim environment, which writes its contents to the
1919 % |.sfr| file. Here, the verbatim package is used.
1920 %
1921 % Before writing the contents, it writes the |\bsfrestore| entry for the
1922 % subframe. The latter contains the value of the |subsectionslide| counter as
1923 % fourth argument, which has to be corrected, if miniframes for subframes should
1924 % not appear. The counter needs to be incremented, if miniframes should appear
1925 % for subframes.
1926 %
1927 % The |\bsfrestore| entry also has to restore the section and subsection heads.
1928 % Since they might contain macros and not just the text itself,
1929 % |\insertsectionhead| and |\insertsubsectionhead| can not be used directly.
1930 % Their current meaning is stored in macros, which are later used to restore
1931 % the heads.
1932 %
1933 % The first line of the |subframe| environment, which contains the arguments, is
1934 % treated differently. It is preceded with |\begin{frame}|.
1935 %
1936 % At the end of the environment, |\end{frame}| is written to the |.sfr| file.
1937 % And the |\subslideentry| is written with |\beamer@writeslidentry@miniframes|,
1938 % but only if miniframes should appear for subframes.
1939 % \begin{macrocode}
1940 \if@bsf@append
1941 \newenvironment{subframe}{%
1942 \@tempcnta\c@subsectionslide
1943 \if@bsf@miniframes\else \advance\@tempcnta by -1\fi
1944 \expandafter\global\expandafter\let
1945 \csname bsf@sectionhead\the\c@part.\the\c@section
1946 \endcsname\insertsectionhead
1947 \expandafter\global\expandafter\let
1948 \csname bsf@subsectionhead\the\c@part.\the\c@section.\the\c@subsection
1949 \endcsname\insertsubsectionhead
1950 \immediate\write\bsf@sfrout{\string\bsfrestore{\the\c@part}{\the\c@section}%
1951 {\the\c@subsection}{\the\@tempcnta}}%
1952 \if@bsf@miniframes \addtocounter{subsectionslide}{1}\fi
1953 \@bsf@firstlinetrue
1954 \let\do\@makeother\dospecials\catcode`\^^M\active
1955 \def\verbatim@processline{%
1956 \if@bsf@firstline
1957 \immediate\write\bsf@sfrout{\string\begin{frame}\the\verbatim@line}%
1958 \@bsf@firstlinefalse
1959 \else
1960 \immediate\write\bsf@sfrout{\the\verbatim@line}%
1961 \fi
1962 }%
1963 \verbatim@}{\immediate\write\bsf@sfrout{\string\end{frame}^^J}%
1964 \if@bsf@miniframes \beamer@writeslidentry@miniframes \fi
1965 }
1966 \else
1967 % \end{macrocode}
1968 % In embed mode, the |subframe| environment is basically a |frame| environment.
1969 % Before calling it, |\if@bsf@subframe| is set to true. And after the |frame|
1970 % environment, |\if@bsf@subframe| is set to false again. This is needed for the
1971 % |\ifsubframe| command.
1972 %
1973 % The main problem here is adding |environment=subframe| to the options. For
1974 % this, |\bsf@frame| is called with the name of the environment, the optional
1975 % overlay specification (|#2|), and the first optional argument (|#1|).
1976 % \begin{macrocode}
1977 \newenvironment<>{subframe}[1][]{%
1978 \@bsf@subframetrue
1979 \bsf@frame{subframe}{#2}{#1}}{\end{frame}\@bsf@subframefalse}
1980 \fi
1981 % \end{macrocode}
1982 % \end{environment}
1983 %
1984 % \begin{macro}{\bsf@frame}
1985 % The macro |\bsf@frame| initializes the token register |\bsf@frame@param|, sets
1986 % a default for the second optional argument and then calls |\bsf@@frame|.
1987 % \begin{macrocode}
1988 \def\bsf@frame#1#2#3{\bsf@frame@param={}%
1989 \@ifnextchar[{\bsf@@frame{#1}{#2}{#3}}{\bsf@@frame{#1}{#2}{#3}[]}%
1990 }
1991 % \end{macrocode}
1992 % \end{macro}
1993 %
1994 % \begin{macro}{\bsf@@frame}
1995 % The macro |\bsf@@frame| is called with the name of the new frame environment
1996 % (|#1|), the overlay specification (|#2|), and the first (|#3|) and the second
1997 % (|#4|) optional argument. It stores the arguments in|\bsf@frame@param|,
1998 % thereby adding |environment=|\meta{name of the new frame environment} at the
1999 % appropriate place.
2000 % \begin{macrocode}
2001 \def\bsf@@frame#1#2#3[#4]{%
2002 \def\@tempa{#3}
2003 % \end{macrocode}
2004 % If |#3| is empty, then there are no optional arguments, i.e.\ no default
2005 % overlay specification and no options. In this case, |#4| is empty too.
2006 % \begin{macrocode}
2007 \ifx\@tempa\@empty
2008 \bsf@frame@param={#2[environment=#1]}%
2009 \else
2010 \def\@tempb{#4}
2011 % \end{macrocode}
2012 % If only |#4| is empty, then there is one optional argument. This case is
2013 % handled by |\bsf@@@frame|.
2014 % \begin{macrocode}
2015 \ifx\@tempb\@empty
2016 \bsf@@@frame{#1}{#2}#3\@@end
2017 % \end{macrocode}
2018 % Otherwhise, both optional arguments are present.
2019 % \begin{macrocode}
2020 \else
2021 \bsf@frame@param={#2[#3][environment=#1,#4]}%
2022 \fi
2023 \fi
2024 % \end{macrocode}
2025 % At the end, |\bsf@frame@| is called with the token register |\bsf@frame@param|
2026 % already expanded.
2027 % \begin{macrocode}
2028 \expandafter\bsf@frame@\the\bsf@frame@param\@@end
2029 }
2030 % \end{macrocode}
2031 % \end{macro}
2032 %
2033 % \begin{macro}{\bsf@@@frame}
2034 % The macro |\bsf@@@frame| checks, if the only optional argument is a default
2035 % overlay specification or the list of options. Here |#1| is the name of the new
2036 % frame environment, |#2| is the overlay specification, |#3| is the first
2037 % character of the optional argument and |#4| contains all subsequent characters.
2038 %
2039 % If |#3| is `|<|', then the optional argument is a default overlay specification.
2040 % Otherwhise, it is the list of options.
2041 % \begin{macrocode}
2042 \def\bsf@@@frame#1#2#3#4\@@end{%
2043 \def\@tempa{#3}\def\@tempb{<}%
2044 \ifx\@tempa\@tempb\relax
2045 \bsf@frame@param={#2[#3#4][environment=#1]}%
2046 \else
2047 \bsf@frame@param={#2[environment=#1,#3#4]}%
2048 \fi
2049 }
2050 % \end{macrocode}
2051 % \end{macro}
2052 %
2053 % \begin{macro}{\bsf@frame@}
2054 % The macro |\bsf@frame@| calls |\begin{frame}| with its argument, which
2055 % contains the overlay specification and the default overlay specification if
2056 % present, and the options, containing at least |environment=...|. This includes
2057 % angle brackets and brackets.
2058 % \begin{macrocode}
2059 \def\bsf@frame@#1\@@end{\begin{frame}#1}
2060 % \end{macrocode}
2061 % \end{macro}
2062 %
2063 % ^^A-------------------------
2064 % \subsubsection{The \texttt{lastframe} environment}
2065 % \label{sec:code-lastframe}
2066 % \begin{environment}{lastframe}
2067 % The |lastframe| environment also uses |\bsf@frame| to add |environment=lastframe|
2068 % to the options before calling the |frame| environment.
2069 %
2070 % Before that, it uses |\bsfrestore| to reset all sectioning counters. After
2071 % this, the counters are in the same state, as they would be for a title frame
2072 % before all sectioning commands. By this, navigation in the sidebar or headline
2073 % will appear the same way as on the title page.
2074 % \begin{macrocode}
2075 \newenvironment<>{lastframe}[1][]{%
2076 \bsfrestore{0}{0}{0}{0}%
2077 \bsf@frame{lastframe}{#2}{#1}}{\end{frame}}
2078 % \end{macrocode}
2079 % \end{environment}
2080 %
2081 % ^^A-------------------------
2082 % \subsubsection{Appending Subframes}
2083 % \label{sec:code-appendsub}
2084 % \begin{macro}{\appendsubframes}
2085 % The macro |\appendsubframes| does nothing in embed mode. In append mode it
2086 % first writes |\endinput| to the |.sfr| file and initializes some macros for
2087 % navigation. The page number of the last frame of the main part is stored in
2088 % |\bsf@pagebeforesub|, to be used after loading the |.sfr| file.
2089 % \begin{macrocode}
2090 \newcommand{\appendsubframes}{%
2091 \if@bsf@append
2092 \immediate\write\bsf@sfrout{\string\endinput}%
2093 \edef\bsf@partfirstsubframepage{\the\c@page}%
2094 \edef\bsf@sectionfirstsubframepage{\the\c@page}%
2095 \edef\bsf@subsectionfirstsubframepage{\the\c@page}%
2096 \@tempcnta\c@page\advance\@tempcnta -1\relax
2097 \edef\bsf@pagebeforesub{\the\@tempcnta}%
2098 % \end{macrocode}
2099 % For the navigation in the main part, the |\[email protected]| entries are
2100 % written to the |.nav| file.
2101 % \begin{macrocode}
2102 \addtocontents{nav}{\protect\headcommand{%
2103 \protect\beamer@partpages{\the\beamer@partstartpage}{\bsf@pagebeforesub}}}%
2104 \addtocontents{nav}{\protect\headcommand{%
2105 \protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\bsf@pagebeforesub}}}%
2106 \addtocontents{nav}{\protect\headcommand{%
2107 \protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\bsf@pagebeforesub}}}%
2108 \addtocontents{nav}{\protect\headcommand{%
2109 \protect\beamer@documentpages{\bsf@pagebeforesub}}}%
2110 % \end{macrocode}
2111 % The number of the last frame of the main part is stored in |\bsf@totalframenumber|.
2112 % And |\beamer@writeslidentry| is replaced by |\beamer@writeslidentry@navbar|.
2113 % \begin{macrocode}
2114 \edef\bsf@totalframenumber{\the\c@framenumber}%
2115 \let\beamer@writeslidentry\beamer@writeslidentry@navbar
2116 % \end{macrocode}
2117 % Before loading the |.sfr| file, it is closed and the flags for the navigation
2118 % bar are initialized. The flag for |\ifsubframe| is set to true, because from
2119 % now on there are only subframes.
2120 % \begin{macrocode}
2121 \immediate\closeout\bsf@sfrout
2122 \@bsf@firstparttrue
2123 \@bsf@firstsectiontrue
2124 \@bsf@firstsubsectiontrue
2125 \@bsf@subframetrue
2126 \input{\jobname.sfr}
2127 % \end{macrocode}
2128 % After all subframes are typeset, the final |\[email protected]| entries are written
2129 % to the |.nav| file.
2130 % \begin{macrocode}
2131 \@tempcnta\c@page\advance\@tempcnta -1\relax
2132 \if@filesw
2133 \immediate\write\@auxout{\string\@writefile{nav}%
2134 {\noexpand\headcommand{\noexpand\bsf@partpages{\bsf@partfirstsubframepage}%
2135 {\the\@tempcnta}{\bsf@partstartpage}{\bsf@pagebeforesub}}}}%
2136 \immediate\write\@auxout{\string\@writefile{nav}%
2137 {\noexpand\headcommand{\noexpand\bsf@sectionpages{\bsf@sectionfirstsubframepage}%
2138 {\the\@tempcnta}{\bsf@sectionstartpage}{\bsf@pagebeforesub}}}}%
2139 \immediate\write\@auxout{\string\@writefile{nav}%
2140 {\noexpand\headcommand{\noexpand\bsf@subsectionpages{\bsf@subsectionfirstsubframepage}%
2141 {\the\@tempcnta}{\bsf@subsectionstartpage}{\bsf@pagebeforesub}}}}%
2142 \immediate\write\@auxout{\string\@writefile{nav}%
2143 {\noexpand\headcommand{\noexpand\bsf@documentpages{\the\@tempcnta}}}}%
2144 % \end{macrocode}
2145 % Finally, the command to disable the remaining |\[email protected]| entries is
2146 % written to the |.nav| file.
2147 % \begin{macrocode}
2148 \immediate\write\@auxout{\string\@writefile{nav}%
2149 {\noexpand\headcommand{\noexpand\bsf@disablenaventries}}}%
2150 \fi
2151 \fi
2152 }
2153 % \end{macrocode}
2154 % \end{macro}
2155 %
2156 % ^^A-------------------------
2157 % \subsubsection{At Begin and End of the Document}
2158 % \label{sec:code-beginend}
2159 % At the beginning of the document, first the |.sfp| file is loaded. The |.sfr|
2160 % file is only opened in append mode.
2161 % \begin{macrocode}
2162 \AtBeginDocument{%
2163 \InputIfFileExists{\jobname.sfp}{}{}%
2164 \if@bsf@append
2165 \immediate\openout\bsf@sfrout\jobname.sfr\relax
2166 % \end{macrocode}
2167 % To reenable the |\[email protected]| entries after the first page, the command
2168 % |\bsf@enablenaventries| is written as the first entry to the |.nav| file.
2169 % \begin{macrocode}
2170 \if@filesw
2171 \immediate\write\@auxout{\string\@writefile{nav}%
2172 {\noexpand\headcommand{\noexpand\bsf@enablenaventries}}}%
2173 \fi
2174 \fi
2175 }
2176 % \end{macrocode}
2177 %
2178 % At the end of the document in append mode first the |.sfp| file is checked.
2179 % After that |\bsf@totalframenumber| is initialized if necessary, i.e.\ if
2180 % |\appendsubframes| was omitted in the source.
2181 % \begin{macrocode}
2182 \AtEndDocument{%
2183 \if@bsf@append
2184 \bsf@checksfp
2185 \@ifundefined{bsf@totalframenumber}{%
2186 \edef\bsf@totalframenumber{\the\c@framenumber}}{}%
2187 \if@filesw
2188 % \end{macrocode}
2189 % The definition for |\inserttotalframenumber| is written to the |.nav| file a
2190 % second time, thus overwriting the first definition written by Beamer. Here it
2191 % contains the number of frames of the main part.
2192 % \begin{macrocode}
2193 \immediate\write\@auxout{\string\@writefile{nav}%
2194 {\noexpand\headcommand{%
2195 \noexpand\def\noexpand\inserttotalframenumber{\bsf@totalframenumber}}}}
2196 % \end{macrocode}
2197 % A stream for the for the |.sfp| file is defined and the file is opened, so
2198 % \LaTeX\ can write it, when loading the |.aux| file at the end of the document.
2199 % \begin{macrocode}
2200 \newwrite\tf@sfp
2201 \immediate\openout\tf@sfp\jobname.sfp\relax
2202 \fi
2203 \fi
2204 % \end{macrocode}
2205 % Regardless of the mode, the definition of |\inserttotalframenumberwithsub| is
2206 % written to the |.nav| file, so it can be used in themes in both modes.
2207 % \begin{macrocode}
2208 \if@filesw
2209 \immediate\write\@auxout{\string\@writefile{nav}%
2210 {\noexpand\headcommand{%
2211 \noexpand\def\noexpand\inserttotalframenumberwithsub{\the\c@framenumber}}}}
2212 \fi
2213 }
2214 % \end{macrocode}
2215 %
2216 % ^^A-------------------------
2217 % \subsubsection{Contitional Execution}
2218 % \begin{macro}{\ifappend}
2219 % The macro |\ifappend| simply expands to its first argument in append mode and
2220 % to its second in embed mode.
2221 % \begin{macrocode}
2222 \newcommand{\ifappend}[2]{\if@bsf@append #1\else #2\fi}
2223 % \end{macrocode}
2224 % \end{macro}
2225 %
2226 % \begin{macro}{\ifsubframe}
2227 % The macro |\ifsubframes| simply expands to its first argument in subframes and
2228 % to its second in normal frames.
2229 % \begin{macrocode}
2230 \newcommand{\ifsubframe}[2]{\if@bsf@subframe #1\else #2\fi}
2231 % \end{macrocode}
2232 % \end{macro}
2233 %
2234 % \newpage
2235 % \Finale\endinput
2236 %</package>
2237 % ^^A--------------------------------------------------------------------------
2238 % ^^A Now the source of the example
2239 %<*example>
2240 \documentclass{beamer}
2241 \usepackage{lmodern}
2242 \usepackage[T1]{fontenc}
2243
2244 \usepackage[append]{beamersubframe}
2245
2246 \newcommand<>{\linkdetail}[4]{%
2247 \ifappend{\uncover#5{\hyperlink{#3}{\beamergotobutton{#4}}}}%
2248 {\uncover#5{\hyperlink{#1}{\beamerskipbutton{#2}}}}
2249 }
2250 \newcommand<>{\returndetail}[2]{%
2251 \ifappend{\uncover#3{\hyperlink{#1}{\beamerreturnbutton{#2}}}}%
2252 {\visible<0>{\beamerreturnbutton{#2}}}
2253 }
2254 \newcommand<>{\linkdifftext}[3]{%
2255 \ifappend{\uncover#4{\hyperlink{#1}{\beamergotobutton{#3}}}}%
2256 {\uncover#4{\hyperlink{#1}{\beamerskipbutton{#2}}}}
2257 }
2258
2259 \defbeamertemplate*{sidebar left}{bsf test}[1][50]
2260 {
2261 \vfill%
2262 \rlap{\hskip0.1cm\hbox{\color{fg!#1!bg}\tiny{\ifsubframe{detail}{main part}}}}%
2263 \vskip2pt%
2264 }
2265
2266 \begin{document}
2267 \begin{frame}{some frame}
2268 \begin{itemize}[<+->]
2269 \item there is foo
2270 \item foo is good
2271 \item and there is bar
2272 \item bar is good too
2273 \end{itemize}
2274 \end{frame}
2275
2276 \begin{frame}<1-2>[label=lfoo]{frame on foo}
2277 \begin{itemize}[<+->]
2278 \item item a
2279 \item item b \linkdetail<2>{lfoo<3>}{Skip Details}{ldfoob}{Goto Details}
2280 \item item c
2281 \item item d
2282 \end{itemize}
2283 \end{frame}
2284
2285 \begin{subframe}[label=ldfoob]{details on foo item b}
2286 \begin{itemize}[<+->]
2287 \item item b.1
2288 \item item b.2
2289 \item item b.3
2290 \item item b.4
2291 \end{itemize}
2292 \end{subframe}
2293
2294 \begin{subframe}
2295 \frametitle{more details on foo item b}
2296 \begin{itemize}[<+->]
2297 \item item b.5
2298 \item item b.6
2299 \item item b.7
2300 \item item b.8
2301 \end{itemize}
2302
2303 \vspace{2ex}
2304 \returndetail<4>{lfoo<3>}{Return from Details}
2305 \end{subframe}
2306
2307 \againframe<3->{lfoo}
2308
2309 \begin{frame}{frame on bar}
2310 \begin{itemize}[<+->]
2311 \item item w
2312 \item item x
2313 \item item y
2314 \item item z \linkdetail<4>{lother}{Skip Details}{ldbarz}{Goto Details}
2315 \end{itemize}
2316 \end{frame}
2317
2318 \begin{subframe}[label=ldbarz]
2319 \frametitle{details on bar item z}
2320 \begin{itemize}[<+->]
2321 \item item z.1
2322 \item item z.2
2323 \item item z.3
2324 \item item z.4
2325 \end{itemize}
2326
2327 \vspace{2ex}
2328 \linkdifftext<4>{lother}{Skip further Details}{Return from Details}
2329 \end{subframe}
2330
2331 \begin{subframe}{more details on bar item z}
2332 \begin{itemize}[<+->]
2333 \item item z.5
2334 \item item z.6
2335 \item item z.7
2336 \item item z.8
2337 \end{itemize}
2338
2339 \vspace{2ex}
2340 \returndetail<4>{lother}{Return from Details}
2341 \end{subframe}
2342
2343 \begin{frame}[label=lother]{another frame}
2344 \begin{itemize}[<+->]
2345 \item conclusion 1
2346 \item conclusion 2
2347 \item conclusion 3
2348 \item conclusion 4
2349 \end{itemize}
2350 \end{frame}
2351
2352 \appendsubframes
2353 \end{document}
2354 %</example>