% __TPdiv.tex,v 1.2.2.1 2002/11/14 21:18:19 hansfn Exp
%  
% TeXPower bundle - dynamic online presentations with LaTeX
% Copyright (C) 1999-2002 Stephan Lehmke
% 
% 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.
%
%-----------------------------------------------------------------------------------------------------------------
% File: __TPdiv.tex
%
% Code for the divisibility example (demonstrating \step's optional arguments) for the package texpower.sty.
% 
% This file is input by others. Don't compile it separately.
%
%-----------------------------------------------------------------------------------------------------------------
% Autor: Stephan Lehmke <Stephan.Lehmke@cs.uni-dortmund.de>
%
% v0.0.1 Mar 20, 2000: First version for the pre-alpha release of TeXPower.
%
% v0.0.2 Apr 26, 2000: Some small changes in preparation of the update to TeXpower v0.0.7.
%
% v0.0.3 May 18, 2000: New file name.
%

%-----------------------------------------------------------------------------------------------------------------
%
\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

%%% Local Variables: 
%%% mode: latex
%%% fill-column: 120
%%% TeX-master: "divexample"
%%% End: 
