From 11c484aba65897a075decb96db9796579daa4ecb Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 12 Aug 2011 15:31:29 +0000
Subject: beamersubframe 0.2 (11aug11)

git-svn-id: svn://tug.org/texlive/trunk@23510 c570f23f-e606-0410-a88d-b1316a301751
---
 .../tex/latex/beamersubframe/beamersubframe.sty    | 515 ++++++++++++++++-----
 1 file changed, 404 insertions(+), 111 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/beamersubframe/beamersubframe.sty')

diff --git a/Master/texmf-dist/tex/latex/beamersubframe/beamersubframe.sty b/Master/texmf-dist/tex/latex/beamersubframe/beamersubframe.sty
index 948fc981719..5754bb8e42a 100644
--- a/Master/texmf-dist/tex/latex/beamersubframe/beamersubframe.sty
+++ b/Master/texmf-dist/tex/latex/beamersubframe/beamersubframe.sty
@@ -1,3 +1,12 @@
+%%
+%% This is file `beamersubframe.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% beamersubframe.dtx  (with options: `package')
+%% 
+%% Copyright (c) 2011 Mike Kaufmann, all rights reserved
 %% 
 %% This program is provided under the terms of the
 %% LaTeX Project Public License distributed from CTAN
@@ -6,153 +15,437 @@
 %% Author: Mike Kaufmann
 %%         m.km@gmx.de
 %% 
-\def\fileversion{0.1}
-\def\filedate{2011/06/29}
+%% \CharacterTable
+%%  {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
+%%   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
+%%   Digits        \0\1\2\3\4\5\6\7\8\9
+%%   Exclamation   \!     Double quote  \"     Hash (number) \#
+%%   Dollar        \$     Percent       \%     Ampersand     \&
+%%   Acute accent  \'     Left paren    \(     Right paren   \)
+%%   Asterisk      \*     Plus          \+     Comma         \,
+%%   Minus         \-     Point         \.     Solidus       \/
+%%   Colon         \:     Semicolon     \;     Less than     \<
+%%   Equals        \=     Greater than  \>     Question mark \?
+%%   Commercial at \@     Left bracket  \[     Backslash     \\
+%%   Right bracket \]     Circumflex    \^     Underscore    \_
+%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
+%%   Right brace   \}     Tilde         \~}
+%%
+%%
+\def\fileversion{0.2}
+\def\filedate{2011/08/07}
+
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{beamersubframe}[\filedate\space
     v\fileversion\space reordering beamer frames]
-
-% check for beamer class
 \@ifclassloaded{beamer}{}{%
-    \PackageError{beamersubframe}{%
-        The package works only with the beamer class,\MessageBreak
-        therefore it is not loaded.
-    }{%
-        The package is not loaded, because it needs the\MessageBreak
-        beamer class. Continuing may lead to additional\MessageBreak
-        errors because of undefined commands.
-    }
-    \endinput
+  \PackageError{beamersubframe}{%
+    The package works only with the beamer class,\MessageBreak
+    therefore it is not loaded.
+  }{%
+    The package is not loaded, because it needs the\MessageBreak
+    beamer class. Continuing may lead to additional\MessageBreak
+    errors because of undefined commands.
+  }
+  \endinput
 }
-
 \newif\if@bsf@append
+\newif\if@bsf@miniframes
+\@bsf@miniframestrue
+\newif\if@bsf@subframe
+\@bsf@subframefalse
+\newif\if@bsf@nosfnum
 \newif\if@bsf@firstline
-\newtoks\sub@frame@param
-\newwrite\sfr@out
-\newwrite\sfr@sub
-
+\newif\if@bsf@firstpart
+\newif\if@bsf@firstsection
+\newif\if@bsf@firstsubsection
+\newif\if@bsf@nosubsection
+\newif\if@bsf@prevnosubsection
+\newtoks\bsf@frame@param
+\newwrite\bsf@sfrout
 \DeclareOption{embed}{\@bsf@appendfalse}
 \DeclareOption{append}{\@bsf@appendtrue}
-
+\DeclareOption{nominiframes}{\@bsf@miniframesfalse}
 \ExecuteOptions{embed}
 \ProcessOptions*\relax
-
 \RequirePackage{verbatim}
 
-\def\beamer@subnum{%
-    \the\c@part.\the\c@section.\the\c@subsection.\the\c@subsectionslide
+\newcommand{\bsfrestore}[4]{%
+  \setcounter{part}{#1}%
+  \setcounter{section}{#2}%
+  \setcounter{subsection}{#3}%
+  \setcounter{subsectionslide}{#4}%
+  \expandafter\let\expandafter\insertsectionhead
+    \csname bsf@sectionhead\the\c@part.\the\c@section\endcsname
+  \expandafter\let\expandafter\insertsubsectionhead
+    \csname bsf@subsectionhead\the\c@part.\the\c@section.\the\c@subsection\endcsname
+  \def\insertpartheadnumber{#1}%
+  \def\insertsectionheadnumber{#2}%
+  \def\insertsubsectionheadnumber{#3}%
 }
-
-\def\beamersubframepages#1#2#3#4#5#6{%
-    \expandafter\def\csname beamer@substartpage#1.#2.#3.#4\endcsname{#5}%
-    \expandafter\def\csname beamer@subendpage#1.#2.#3.#4\endcsname{#6}%
+\def\bsf@subnum{%
+  \the\c@part.\the\c@section.\the\c@subsection.\the\c@subsectionslide
 }
-
 \def\beamer@writeslidentry@miniframes{%
-    \addtocontents{nav}%
-      {\protect\headcommand{%
-          \protect\slideentry{\the\c@section}{\the\c@subsection}{\the\c@subsectionslide}%
-          {\protect\@nameuse{beamer@substartpage\beamer@subnum}/%
-           \protect\@nameuse{beamer@subendpage\beamer@subnum}}{\lastsubsection}{\the\c@part}}}%
+  \addtocontents{nav}%
+    {\protect\headcommand{%
+      \protect\subslideentry{\the\c@section}{\the\c@subsection}%
+        {\the\c@subsectionslide}%
+        {\protect\bsf@usenum{bsf@substartpage\bsf@subnum}/%
+         \protect\bsf@usenum{bsf@subendpage\bsf@subnum}}%
+        {\lastsubsection}{\the\c@part}}}%
 }
-
 \def\beamer@writeslidentry@navbar{%
   \expandafter\beamer@ifempty\expandafter{\beamer@framestartpage}{}% does not happen normally
   {%else
     \addtocontents{nav}%
-      {\protect\headcommand{% 
+      {\protect\headcommand{%
         \protect\beamer@framepages{\beamer@framestartpage}{\beamer@frameendpage}}}%
-    \immediate\write\sfr@sub{\string\beamersubframepages%
-                             {\the\c@part}{\the\c@section}{\the\c@subsection}%
-                             {\the\c@subsectionslide}{\beamer@framestartpage}{\beamer@frameendpage}}%
+    \addtocontents{sfp}{%
+      \protect\bsfsubframepages{\the\c@part}{\the\c@section}{\the\c@subsection}%
+        {\the\c@subsectionslide}{\beamer@framestartpage}{\beamer@frameendpage}}%
     \clearpage\beamer@notesactions%
-  }
+  }%
 }
-\let\beamer@writeslidentry@orig\beamer@writeslidentry
-
-\newcommand{\beamerrestore}[6]{%
-    \setcounter{part}{#1}%
-    \setcounter{section}{#2}%
-    \setcounter{subsection}{#3}%
-    \setcounter{subsectionslide}{#4}%
-    \def\insertsectionhead{#5}%
-    \def\insertsubsectionhead{#6}%
+\def\subslideentry{\slideentry}
+\def\bsfsubframepages#1#2#3#4#5#6{%
+  \expandafter\def\csname bsf@substartpage#1.#2.#3.#4\endcsname{#5}%
+  \expandafter\def\csname bsf@subendpage#1.#2.#3.#4\endcsname{#6}%
+}
+\def\bsf@usenum#1{%
+  \@ifundefined{#1}{1}{\csname #1\endcsname}%
 }
+\def\bsf@checksfp{%
+  \begingroup
+    \@bsf@nosfnumfalse
+    \def\bsf@usenum##1{%
+      \@ifundefined{##1}{\@bsf@nosfnumtrue}{}}
+    \def\slideentry##1##2##3##4##5##6{}%
+    \def\partentry##1##2{}%
+    \def\sectionentry##1##2##3##4##5{}%
+    \def\beamer@subsectionentry##1##2##3##4##5{}%
+    \def\subslideentry##1##2##3##4##5##6{%
+      \bsf@checksfnum(##4)}%
+    \dohead
+    \if@bsf@nosfnum
+      \PackageWarningNoLine{Beamer SubFrame}{%
+        Missing, incomplete or corrupted file\MessageBreak
+        \jobname.sfp! Links for miniframes of\MessageBreak
+        subframes may be wrong. Please run TeX\MessageBreak
+        again}
+    \fi
+  \endgroup
+}
+\def\bsf@checksfnum(#1/#2){#1#2}
 
+\def\hyperlinkslidenext{%
+  \bsf@nextpage\c@page%
+  \hyperlink{Navigation\the\beamer@tempcount}}
+\def\hyperlinkframestartnext{%
+  \bsf@nextpage\beamer@endpageofframe%
+  \hyperlink{Navigation\the\beamer@tempcount}}
+\def\bsf@nextpage#1{%
+  \beamer@tempcount=#1%
+  \advance\beamer@tempcount by1\relax%
+  \ifnum\beamer@tempcount>\bsf@endpageofdocument%
+  \beamer@tempcount=\bsf@endpageofdocument%
+  \fi}
+\def\bsf@documentpages#1{\def\bsf@endpageofdocument{#1}}
+\def\bsf@endpageofdocument{\beamer@endpageofdocument}
+\let\beamer@partpages@orig\beamer@partpages
+\let\beamer@subsectionpages@orig\beamer@subsectionpages
+\let\beamer@sectionpages@orig\beamer@sectionpages
+\let\beamer@documentpages@orig\beamer@documentpages
+\def\bsf@enablenaventries{%
+  \let\beamer@partpages\beamer@partpages@orig
+  \let\beamer@subsectionpages\beamer@subsectionpages@orig
+  \let\beamer@sectionpages\beamer@sectionpages@orig
+  \let\beamer@documentpages\beamer@documentpages@orig
+}
+\def\bsf@disablenaventries{%
+  \let\beamer@partpages\@gobbletwo
+  \let\beamer@subsectionpages\@gobbletwo
+  \let\beamer@sectionpages\@gobbletwo
+  \let\beamer@documentpages\@gobble
+}
+\let\part@orig\part
+\let\section@orig\section
+\let\subsection@orig\subsection
 \if@bsf@append
-    \newenvironment{subframe}{%
-        \immediate\write\sfr@out{\string\beamerrestore{\the\c@part}{\the\c@section}%
-                {\the\c@subsection}{\the\c@subsectionslide}{\insertsectionhead}{\lastsubsection}}
-        \addtocounter{subsectionslide}{1}%
-        \@bsf@firstlinetrue
-        \let\do\@makeother\dospecials\catcode`\^^M\active
-        \def\verbatim@processline{%
-            \if@bsf@firstline
-                \immediate\write\sfr@out{\string\begin{frame}\the\verbatim@line}%
-                \@bsf@firstlinefalse
-            \else
-                \immediate\write\sfr@out{\the\verbatim@line}%
-            \fi
-        }%
-        \verbatim@}{\immediate\write\sfr@out{\string\end{frame}^^J}%
-        \beamer@writeslidentry@miniframes
-    }
+  \def\part{%
+    \immediate\write\bsf@sfrout{\string\bsfrestorepart{\the\c@part}%
+        {\the\c@page}}%
+    \part@orig
+  }
+  \def\section{%
+    \immediate\write\bsf@sfrout{\string\bsfrestoresection{\the\c@section}%
+        {\the\c@page}}%
+    \section@orig
+  }
+  \def\subsection{%
+    \immediate\write\bsf@sfrout{\string\bsfrestoresubsection{\the\c@subsection}%
+        {\the\c@page}}%
+    \subsection@orig
+  }
+\fi
+\def\bsfrestorepart#1#2{%
+  \if@bsf@firstpart
+    \@bsf@firstpartfalse
+    \def\bsf@partstartpage{#2}%
+    \def\bsf@prevpart{#1}%
+    \edef\bsf@partfirstsubframepage{\the\c@page}%
+  \else
+    \@tempcnta=\bsf@prevpart\relax
+    \ifnum#1>\@tempcnta
+      \@tempcnta\c@page\advance\@tempcnta -1\relax
+      \@tempcntb=#2\relax\advance\@tempcntb -1\relax
+      \if@filesw
+        \immediate\write\@auxout{\string\@writefile{nav}%
+          {\noexpand\headcommand{%
+            \noexpand\bsf@partpages{\bsf@partfirstsubframepage}%
+              {\the\@tempcnta}{\bsf@partstartpage}{\the\@tempcntb}}}}%
+      \fi
+      \def\bsf@partstartpage{#2}%
+      \def\bsf@prevpart{#1}%
+      \edef\bsf@partfirstsubframepage{\the\c@page}%
+    \fi
+  \fi
+}
+\def\bsf@partstartpage{1}%
+\def\bsf@prevpart{0}%
+\def\bsfrestoresection#1#2{%
+  \if@bsf@firstsection
+    \@bsf@firstsectionfalse
+    \def\bsf@prevsectionstartpage{#2}%
+    \@bsf@nosubsectiontrue
+    \@bsf@prevnosubsectionfalse
+    \def\bsf@sectionstartpage{#2}%
+    \def\bsf@prevsection{#1}%
+    \edef\bsf@sectionfirstsubframepage{\the\c@page}%
+  \else
+    \@tempcnta=\bsf@prevsection\relax
+    \ifnum#1>\@tempcnta
+      \edef\bsf@prevsectionstartpage{\bsf@sectionstartpage}%
+      \if@bsf@nosubsection
+        \@bsf@prevnosubsectiontrue
+      \else
+        \@bsf@prevnosubsectionfalse
+      \fi
+      \@bsf@nosubsectiontrue
+      \def\bsf@prevsubsection{-1}%
+      \@tempcnta\c@page\advance\@tempcnta -1\relax
+      \@tempcntb=#2\relax\advance\@tempcntb -1\relax
+      \if@filesw
+        \immediate\write\@auxout{\string\@writefile{nav}%
+          {\noexpand\headcommand{%
+            \noexpand\bsf@sectionpages{\bsf@sectionfirstsubframepage}%
+              {\the\@tempcnta}{\bsf@sectionstartpage}{\the\@tempcntb}}}}%
+      \fi
+      \def\bsf@sectionstartpage{#2}%
+      \def\bsf@prevsection{#1}%
+      \edef\bsf@sectionfirstsubframepage{\the\c@page}%
+    \fi
+  \fi
+}
+\def\bsf@sectionstartpage{1}%
+\def\bsf@prevsection{0}%
+\def\bsfrestoresubsection#1#2{%
+  \if@bsf@firstsubsection
+    \@bsf@firstsubsectionfalse
+    \@bsf@prevnosubsectionfalse
+    \def\bsf@subsectionstartpage{#2}%
+    \def\bsf@prevsubsection{#1}%
+    \edef\bsf@subsectionfirstsubframepage{\the\c@page}%
+  \else
+    \@tempcnta=\bsf@prevsubsection\relax
+    \ifnum#1>\@tempcnta
+      \@tempcnta\c@page\advance\@tempcnta -1\relax
+      \if@bsf@prevnosubsection
+        \@tempcntb=\bsf@prevsectionstartpage\relax
+      \else
+        \@tempcntb=#2\relax
+      \fi
+      \advance\@tempcntb -1\relax
+      \@bsf@prevnosubsectionfalse
+      \@bsf@nosubsectionfalse
+      \if@filesw
+        \immediate\write\@auxout{\string\@writefile{nav}%
+          {\noexpand\headcommand{%
+            \noexpand\bsf@subsectionpages{\bsf@subsectionfirstsubframepage}%
+              {\the\@tempcnta}{\bsf@subsectionstartpage}{\the\@tempcntb}}}}%
+      \fi
+      \def\bsf@subsectionstartpage{#2}%
+      \def\bsf@prevsubsection{#1}%
+      \edef\bsf@subsectionfirstsubframepage{\the\c@page}%
+    \fi
+  \fi
+}
+\def\bsf@subsectionstartpage{1}%
+\def\bsf@prevsubsection{0}%
+\def\bsf@partpages#1#2#3#4{%
+  \ifnum\c@page<#1%
+  \else%
+    \ifnum\c@page>#2%
+    \else%
+      \gdef\beamer@startpageofpart{#3}%
+      \gdef\beamer@endpageofpart{#4}%
+    \fi%
+  \fi%
+}
+\def\bsf@sectionpages#1#2#3#4{%
+  \ifnum\c@page<#1%
+  \else%
+    \ifnum\c@page>#2%
+    \else%
+      \gdef\beamer@startpageofsection{#3}%
+      \gdef\beamer@endpageofsection{#4}%
+    \fi%
+  \fi%
+}
+\def\bsf@subsectionpages#1#2#3#4{%
+  \ifnum\c@page<#1%
+  \else%
+    \ifnum\c@page>#2%
+    \else%
+      \gdef\beamer@startpageofsubsection{#3}%
+      \gdef\beamer@endpageofsubsection{#4}%
+    \fi%
+  \fi%
+}
+\def\inserttotalframenumberwithsub{\inserttotalframenumber}
+\if@bsf@append
+  \newenvironment{subframe}{%
+    \@tempcnta\c@subsectionslide
+    \if@bsf@miniframes\else \advance\@tempcnta by -1\fi
+    \expandafter\global\expandafter\let
+      \csname bsf@sectionhead\the\c@part.\the\c@section
+        \endcsname\insertsectionhead
+    \expandafter\global\expandafter\let
+      \csname bsf@subsectionhead\the\c@part.\the\c@section.\the\c@subsection
+        \endcsname\insertsubsectionhead
+    \immediate\write\bsf@sfrout{\string\bsfrestore{\the\c@part}{\the\c@section}%
+        {\the\c@subsection}{\the\@tempcnta}}%
+    \if@bsf@miniframes \addtocounter{subsectionslide}{1}\fi
+    \@bsf@firstlinetrue
+    \let\do\@makeother\dospecials\catcode`\^^M\active
+    \def\verbatim@processline{%
+      \if@bsf@firstline
+        \immediate\write\bsf@sfrout{\string\begin{frame}\the\verbatim@line}%
+        \@bsf@firstlinefalse
+      \else
+        \immediate\write\bsf@sfrout{\the\verbatim@line}%
+      \fi
+    }%
+    \verbatim@}{\immediate\write\bsf@sfrout{\string\end{frame}^^J}%
+    \if@bsf@miniframes \beamer@writeslidentry@miniframes \fi
+  }
 \else
-    % problem here: adding ``environment=subframe'' to the options
-    \def\sub@frame@#1\@@end{\begin{frame}#1}
-    \def\sub@@@frame#1#2#3\@@end{%      processing for one optional argument
-        \def\@tempa{#2}\def\@tempb{<}%
-        \ifx\@tempa\@tempb\relax%       test for default overlay spec
-            \sub@frame@param={#1[#2#3][environment=subframe]}%
-        \else
-            \sub@frame@param={#1[environment=subframe,#2#3]}%
-        \fi
-    }
-    \def\sub@@frame#1#2[#3]{%
-        \def\@tempa{#2}
-        \ifx\@tempa\@empty%         this means: no default overlay spec and no options
-            \sub@frame@param={#1[environment=subframe]}%
-        \else
-            \def\@tempb{#3}
-            \ifx\@tempb\@empty%     this means: one optional argument
-                \sub@@@frame{#1}#2\@@end
-            \else%                  both, default overlay spec and options present
-                \sub@frame@param={#1[#2][environment=subframe,#3]}%
-            \fi
-        \fi
-        \expandafter\sub@frame@\the\sub@frame@param\@@end
-    }
-    \def\sub@frame#1#2{%
-        \@ifnextchar[{\sub@@frame{#1}{#2}}{\sub@@frame{#1}{#2}[]}%
-    }
-    \newenvironment<>{subframe}[1][]{%
-        \sub@frame@param={}%
-        \sub@frame{#2}{#1}}{\end{frame}}
+  \newenvironment<>{subframe}[1][]{%
+    \@bsf@subframetrue
+    \bsf@frame{subframe}{#2}{#1}}{\end{frame}\@bsf@subframefalse}
 \fi
-
+\def\bsf@frame#1#2#3{\bsf@frame@param={}%
+  \@ifnextchar[{\bsf@@frame{#1}{#2}{#3}}{\bsf@@frame{#1}{#2}{#3}[]}%
+}
+\def\bsf@@frame#1#2#3[#4]{%
+  \def\@tempa{#3}
+  \ifx\@tempa\@empty
+    \bsf@frame@param={#2[environment=#1]}%
+  \else
+    \def\@tempb{#4}
+    \ifx\@tempb\@empty
+      \bsf@@@frame{#1}{#2}#3\@@end
+    \else
+      \bsf@frame@param={#2[#3][environment=#1,#4]}%
+    \fi
+  \fi
+  \expandafter\bsf@frame@\the\bsf@frame@param\@@end
+}
+\def\bsf@@@frame#1#2#3#4\@@end{%
+  \def\@tempa{#3}\def\@tempb{<}%
+  \ifx\@tempa\@tempb\relax
+    \bsf@frame@param={#2[#3#4][environment=#1]}%
+  \else
+    \bsf@frame@param={#2[environment=#1,#3#4]}%
+  \fi
+}
+\def\bsf@frame@#1\@@end{\begin{frame}#1}
+\newenvironment<>{lastframe}[1][]{%
+  \bsfrestore{0}{0}{0}{0}%
+  \bsf@frame{lastframe}{#2}{#1}}{\end{frame}}
 \newcommand{\appendsubframes}{%
-    \if@bsf@append
-        \let\beamer@writeslidentry\beamer@writeslidentry@navbar
-        \immediate\closeout\sfr@out
-        \input{\jobname.sfr}
-%        \immediate\openout\sfr@out\jobname.sfr
-        \let\beamer@writeslidentry\beamer@writeslidentry@orig
+  \if@bsf@append
+    \immediate\write\bsf@sfrout{\string\endinput}%
+    \edef\bsf@partfirstsubframepage{\the\c@page}%
+    \edef\bsf@sectionfirstsubframepage{\the\c@page}%
+    \edef\bsf@subsectionfirstsubframepage{\the\c@page}%
+    \@tempcnta\c@page\advance\@tempcnta -1\relax
+    \edef\bsf@pagebeforesub{\the\@tempcnta}%
+    \addtocontents{nav}{\protect\headcommand{%
+        \protect\beamer@partpages{\the\beamer@partstartpage}{\bsf@pagebeforesub}}}%
+    \addtocontents{nav}{\protect\headcommand{%
+        \protect\beamer@subsectionpages{\the\beamer@subsectionstartpage}{\bsf@pagebeforesub}}}%
+    \addtocontents{nav}{\protect\headcommand{%
+        \protect\beamer@sectionpages{\the\beamer@sectionstartpage}{\bsf@pagebeforesub}}}%
+    \addtocontents{nav}{\protect\headcommand{%
+        \protect\beamer@documentpages{\bsf@pagebeforesub}}}%
+    \edef\bsf@totalframenumber{\the\c@framenumber}%
+    \let\beamer@writeslidentry\beamer@writeslidentry@navbar
+    \immediate\closeout\bsf@sfrout
+    \@bsf@firstparttrue
+    \@bsf@firstsectiontrue
+    \@bsf@firstsubsectiontrue
+    \@bsf@subframetrue
+    \input{\jobname.sfr}
+    \@tempcnta\c@page\advance\@tempcnta -1\relax
+    \if@filesw
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{\noexpand\bsf@partpages{\bsf@partfirstsubframepage}%
+          {\the\@tempcnta}{\bsf@partstartpage}{\bsf@pagebeforesub}}}}%
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{\noexpand\bsf@sectionpages{\bsf@sectionfirstsubframepage}%
+          {\the\@tempcnta}{\bsf@sectionstartpage}{\bsf@pagebeforesub}}}}%
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{\noexpand\bsf@subsectionpages{\bsf@subsectionfirstsubframepage}%
+          {\the\@tempcnta}{\bsf@subsectionstartpage}{\bsf@pagebeforesub}}}}%
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{\noexpand\bsf@documentpages{\the\@tempcnta}}}}%
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{\noexpand\bsf@disablenaventries}}}%
     \fi
+  \fi
 }
-
 \AtBeginDocument{%
-    \InputIfFileExists{\jobname.sfp}{}{}%
-    \if@bsf@append
-        \immediate\openout\sfr@out\jobname.sfr\relax
-        \immediate\openout\sfr@sub\jobname.sfp\relax
+  \InputIfFileExists{\jobname.sfp}{}{}%
+  \if@bsf@append
+    \immediate\openout\bsf@sfrout\jobname.sfr\relax
+    \if@filesw
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{\noexpand\bsf@enablenaventries}}}%
     \fi
+  \fi
 }
 \AtEndDocument{%
-    \if@bsf@append
-%        \immediate\closeout\sfr@out
-        \immediate\closeout\sfr@sub
+  \if@bsf@append
+    \bsf@checksfp
+    \@ifundefined{bsf@totalframenumber}{%
+      \edef\bsf@totalframenumber{\the\c@framenumber}}{}%
+    \if@filesw
+      \immediate\write\@auxout{\string\@writefile{nav}%
+        {\noexpand\headcommand{%
+          \noexpand\def\noexpand\inserttotalframenumber{\bsf@totalframenumber}}}}
+      \newwrite\tf@sfp
+      \immediate\openout\tf@sfp\jobname.sfp\relax
     \fi
+  \fi
+  \if@filesw
+    \immediate\write\@auxout{\string\@writefile{nav}%
+      {\noexpand\headcommand{%
+        \noexpand\def\noexpand\inserttotalframenumberwithsub{\the\c@framenumber}}}}
+  \fi
 }
-
-% simple command for user macros
 \newcommand{\ifappend}[2]{\if@bsf@append #1\else #2\fi}
+\newcommand{\ifsubframe}[2]{\if@bsf@subframe #1\else #2\fi}
+\endinput
+%%
+%% End of file `beamersubframe.sty'.
-- 
cgit v1.2.3

