| 1 |
%% |
| 2 |
%% This is file `bckwrdexample.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% texpower-doc.dtx (with options: `bckwrdexample,bckwrdexample-src,end') |
| 8 |
%% |
| 9 |
%% -------------------------------------------------------------- |
| 10 |
%% TeXPower bundle - dynamic online presentations with LaTeX |
| 11 |
%% Copyright (C) 1999-2004 Stephan Lehmke |
| 12 |
%% Copyright (C) 2003-2005 Hans Fredrik Nordhaug |
| 13 |
%% |
| 14 |
%% This program is free software; you can redistribute it and/or |
| 15 |
%% modify it under the terms of the GNU General Public License |
| 16 |
%% as published by the Free Software Foundation; either version 2 |
| 17 |
%% of the License, or (at your option) any later version. |
| 18 |
%% |
| 19 |
%% This program is distributed in the hope that it will be useful, |
| 20 |
%% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
%% GNU General Public License for more details. |
| 23 |
%% -------------------------------------------------------------- |
| 24 |
%% |
| 25 |
%% The list of all files belonging to the TeXPower bundle is |
| 26 |
%% given in the file `00readme.txt'. |
| 27 |
%% |
| 28 |
\ProvidesFile{bckwrdexample.tex}% |
| 29 |
[2005/04/07 TeXPower example file] |
| 30 |
%----------------------------------------------------------------------------------------------------------------- |
| 31 |
% |
| 32 |
% Backwards writing example for the package texpower.sty. |
| 33 |
% |
| 34 |
%----------------------------------------------------------------------------------------------------------------- |
| 35 |
% Set background color to black and use slifonts. |
| 36 |
|
| 37 |
\PassOptionsToPackage{blackbackground}{texpower} |
| 38 |
\RequirePackage{tpslifonts} |
| 39 |
|
| 40 |
% Input the generic preamble. |
| 41 |
|
| 42 |
\input{__TPpreamble} |
| 43 |
\hypersetup{pdftitle={texpower backwards writing example}} |
| 44 |
|
| 45 |
% Define \includegraphics for including an mps (metapost postscript) image. |
| 46 |
\usepackage{graphicx} |
| 47 |
% The mps extension isn't supported out-of-the-box for latex+dvips |
| 48 |
\ifthenelse{\boolean{psspecialsallowed}}{% |
| 49 |
\DeclareGraphicsExtensions{.mps}}{} |
| 50 |
|
| 51 |
%----------------------------------------------------------------------------------------------------------------- |
| 52 |
% Finally, everything is set up. Here we go... |
| 53 |
% |
| 54 |
\begin{document} |
| 55 |
\begin{slide} |
| 56 |
|
| 57 |
%----------------------------------------------------------------------------------------------------------------- |
| 58 |
% |
| 59 |
\makeslidetitle{\macroname{stepwise} Example: Writing Backwards}\label{Sec:ExBackwards} |
| 60 |
% |
| 61 |
% The following example doesn't really demonstrate a useful application. Its purpose is twofold: |
| 62 |
% a) Show how the functionality of \stepwise can be extended by the user by referring to the macros provided by the |
| 63 |
% package. |
| 64 |
% b) Show that \steps can appear in any order, and can be made to appear simultaneously in several places (and mention |
| 65 |
% the problems this raises). |
| 66 |
|
| 67 |
% We define a new macro \backstep which will call \step, but the steps will be executed in _reverse_ order. |
| 68 |
% This is achieved as follows: |
| 69 |
% * We refer to the counter totalsteps, which gives the total number of steps occurring in this argument of |
| 70 |
% \stepwise. |
| 71 |
% * From this, we subtract the value of the counter stepcommand, which gives the number of this \step command (in the |
| 72 |
% order of appearance). |
| 73 |
% * The result is compared with the counter step, which gives the number of the current step. |
| 74 |
% (the default for `triggering' a \step is the condition \value{step}=\value{stepcommand}) |
| 75 |
% |
| 76 |
% Note that if the ifthen Package would support this syntax, we could use the bracketed optional argument of \step (as |
| 77 |
% in the previous example), defining \backstep like this: |
| 78 |
% |
| 79 |
% \newcommand{\backstep}{\step[\value{totalsteps}-\value{stepcommand}+1=\value{step}]} |
| 80 |
% |
| 81 |
% As \ifthenelse doesn't offer this syntax, we have to calculate \value{totalsteps}-\value{stepcommand}+1 in a separate |
| 82 |
% counter. This doesn't fit the intended use of \step's optional argument. But hey, there is another syntax ;-) |
| 83 |
% If the optional argument is specified with braces (...), then it can contain an arbitrary test which takes two |
| 84 |
% arguments and selects the first if it succeeds and the second if it fails. We use this variant here. |
| 85 |
% |
| 86 |
\newcounter{reversestepno}% |
| 87 |
\newcommand{\backstep}{\step(\setcounter{reversestepno}{\value{totalsteps}-\value{stepcommand}+1}\ifthenelse{\value{step}=\value{reversestepno}})}% |
| 88 |
% |
| 89 |
% We use the custom command \parstepwise which not only wraps the whole argument of \stepwise into a minipage (because |
| 90 |
% otherwise vertical spacing goes haywire, don't ask me why), but also gives substance to steps. |
| 91 |
% |
| 92 |
% If the following \stepwise command would only contain the calls to \backstep, everything would be fine. |
| 93 |
% But we _had_ to add something else.... |
| 94 |
% In the second part of this application of \stepwise, several steps are executed simultaneously with those executed |
| 95 |
% backwards in the first part. This means the value of the counter totalsteps is 14, i.e. the calls to \backstep |
| 96 |
% correspond to steps 8...14. To remedy this, we decree that the first step performed shall be number 7, by setting |
| 97 |
% the counter firststep accordingly in the optional argument of \stepwise. |
| 98 |
% |
| 99 |
\parstepwise[\setcounter{firststep}{\value{totalsteps}/2+\value{firststep}}] |
| 100 |
{% |
| 101 |
\begin{quote} |
| 102 |
\Huge |
| 103 |
\backstep{Is} \backstep{now} \backstep{it} |
| 104 |
\backstep{backwards} \backstep{write} \backstep{to} |
| 105 |
\backstep{possible\,!} |
| 106 |
|
| 107 |
\bigskip |
| 108 |
|
| 109 |
% By determining explicitly the times at which the following steps are executed, we make them appear |
| 110 |
% simultaneously with the preceding flock of \backsteps. As we have set the counter firststep to 7, we start |
| 111 |
% counting with 8. |
| 112 |
% |
| 113 |
\step[\value{step}=8]{\includegraphics[width=2cm]{fig-1}} |
| 114 |
\step[\value{step}=9]{\includegraphics[width=2cm]{fig-1}} |
| 115 |
\step[\value{step}=10]{\includegraphics[width=2cm]{fig-1}} |
| 116 |
\step[\value{step}=11]{\includegraphics[width=2cm]{fig-1}} |
| 117 |
\step[\value{step}=12]{\includegraphics[width=2cm]{fig-1}} |
| 118 |
\step[\value{step}=13]{\includegraphics[width=2cm]{fig-1}} |
| 119 |
\step[\value{step}=14]{\includegraphics[width=2cm]{fig-1}}% |
| 120 |
\end{quote} |
| 121 |
}% |
| 122 |
\newslide |
| 123 |
\end{slide} |
| 124 |
\end{document} |
| 125 |
\endinput |
| 126 |
%% |
| 127 |
%% End of file `bckwrdexample.tex'. |