%%
%% This is file `divexample.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% texpower-doc.dtx  (with options: `divexample,divexample-src,end')
%% 
%% --------------------------------------------------------------
%% TeXPower bundle - dynamic online presentations with LaTeX
%% Copyright (C) 1999-2004 Stephan Lehmke
%% Copyright (C) 2003-2005 Hans Fredrik Nordhaug
%% 
%% This program is free software; you can redistribute it and/or
%% modify it under the terms of the GNU General Public License
%% as published by the Free Software Foundation; either version 2
%% of the License, or (at your option) any later version.
%% 
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%% GNU General Public License for more details.
%% --------------------------------------------------------------
%% 
%% The list of all files belonging to the TeXPower bundle is
%% given in the file `00readme.txt'.
%% 
\ProvidesFile{divexample.tex}%
      [2005/04/07 TeXPower example file]
%-----------------------------------------------------------------------------------------------------------------
%
% Divisibility example (demonstrating \step's optional arguments) for the package texpower.sty.
%
%-----------------------------------------------------------------------------------------------------------------
% We input the generic preamble.

\input{__TPpreamble}
\hypersetup{pdftitle={texpower divisibility example}}


%-----------------------------------------------------------------------------------------------------------------
% Finally, everything is set up. Here we go...
%
\begin{document}
\begin{slide}
  % As the sectioning in the example files starts with \subsection, we `grade down' the sectioning commands.
  \let\subsubsection\subsection
  \let\subsection\section
%-----------------------------------------------------------------------------------------------------------------
%
\makeslidetitle{\macroname{stepwise} Example: Fooling Around}\label{Sec:ExFooling}
% The following example is just to show that a lot of fancy things are possible by appropriately defining the diverse
% `hooks' offererd by \stepwise.
`Tweaking' the hooks a little allows some truly bizarre applications\dots

% In the following \stepwise command, \activatestep will be set to \textbf. This means the `first' occurrence of a number
% is wider (because bf is an extended font) than all other occurrences of it. To avoid glitches in line breaks, all
% other occurrences of numbers (visible and invisible) need to be of the same width. Hence we define new versions of
% \displaystepcontents and \hidestepcontents.
\def\mydisplay#1{\makebox[\widthof{\textbf{#1}}]{#1}}
\def\myhide#1{\phantom{\makebox[\widthof{\textbf{#1}}]{#1}}}

\newcounter{modulo}
\newcounter{i}

% Finally, we define a custom \step command which sets the optional arguments of \step.
% We already have introduced the first optional argument, which determines when a \step is activated for the first
% time. Here, this one is left at its default value (\value{step}=\value{stepcommand}).
% Here, we also use the second optional argument, which has the same syntax as the first one (i.e. it can be surrounded
% either by square brackets or braces), but determines when a \step is active _at all_ (i.e. whether
% \displaystepcontents or \hidestepcontents is used). The default is the internal check \if@first@TP@true, which determines
% whether step number \value{stepcommand} has already been activated for the first time (this is saved internally for
% every step). Now, we redefine this condition to be fulfilled whenever the value of the counter step is divisible by
% the value of the counter stepcommand.
\def\mystep{\step[](\setcounter{modulo}{\value{step}/\value{stepcommand}*\value{stepcommand}}\ifthenelse{\value{step}=\value{modulo}})}%


% By setting the page duration to 0.5 seconds, we make the following sequence of slides appear automatically one by one,
% one every half second.

\pageDuration{0.5}

%
% We use the custom command \parstepwise which not only wraps the whole argument of \stepwise into a minipage (because
% otherwise vertical spacing goes haywire, don't ask me why), but also gives substance to steps. We use the starred
% version of this command so that the number 1 appears on the first slide generated by \parstepwise.
%
% \activatestep is set to \textbf to emphasize the number the divisors of which are displayed.
\parstepwise*[\let\activatestep=\textbf\let\displaystepcontents=\mydisplay\let\hidestepcontents=\myhide]
{%
  \huge
  \setcounter{i}{0}%
    Divisibility demo:

    % We just have to generate the appropriate number of \mystep commands which display `their' numbers.
    \whiledo{\value{i}<40}{\stepcounter{i}\mystep{\arabic{i}} }%

  }

% Stop automatic advancing of pages.

\stopAdvancing
\end{slide}
\end{document}
\endinput
%%
%% End of file `divexample.tex'.
