| 1 |
%% |
| 2 |
%% This is file `verbexample.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% texpower-doc.dtx (with options: `verbexample') |
| 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{verbexample.tex}% |
| 29 |
[2005/04/07 TeXPower example file] |
| 30 |
%----------------------------------------------------------------------------------------------------------------- |
| 31 |
% |
| 32 |
% Example showing the use of verbatim/fragile steps (using the fragilesteps environment). |
| 33 |
% |
| 34 |
%----------------------------------------------------------------------------------------------------------------- |
| 35 |
|
| 36 |
\documentclass[12pt,a4paper]{article} |
| 37 |
\usepackage[display]{texpower} |
| 38 |
\usepackage{ fancyvrb,listings,alltt} |
| 39 |
% Command to easily include some lines of code from a file |
| 40 |
\def\listcodefromfile#1#2#3{% |
| 41 |
\lstinputlisting[firstline=#1,lastline=#2,aboveskip=0pt,belowskip=0pt]{#3}} |
| 42 |
\begin{document} |
| 43 |
|
| 44 |
\begin{center} |
| 45 |
{\textbf{Example showing the use of verbatim/fragile steps with the fragilesteps environment}} |
| 46 |
\end{center} |
| 47 |
|
| 48 |
A simple example (with alltt) showing steps with verbatim text. |
| 49 |
Multiple lines in one step is only supported by alltt (and only for the |
| 50 |
standard step command, not bstep). |
| 51 |
\pause |
| 52 |
\begin{fragilesteps} |
| 53 |
\begin{alltt} |
| 54 |
One\step{ |
| 55 |
Two |
| 56 |
Three} |
| 57 |
Four |
| 58 |
\end{alltt} |
| 59 |
\end{fragilesteps} |
| 60 |
|
| 61 |
\pause |
| 62 |
|
| 63 |
An easy example (with listings) for including small parts of code in each step. |
| 64 |
If you want to include code line by line look at the next example. Notice that in this |
| 65 |
example you really don't need to use the fragilesteps environment, because |
| 66 |
there are no verbatim code - the next example however... |
| 67 |
\lstset{language=Java} |
| 68 |
\begin{fragilesteps} |
| 69 |
\step{\listcodefromfile{1}{3}{dummy.java}} |
| 70 |
\step{\listcodefromfile{4}{7}{dummy.java}} |
| 71 |
\end{fragilesteps} |
| 72 |
|
| 73 |
\pause |
| 74 |
|
| 75 |
A (fancy) example using the fancyvrb interface of the listings package. |
| 76 |
The re(b)step command is used to make some lines of code appear at the same time. |
| 77 |
(You can not include multiple lines in each (b)step command.) |
| 78 |
\pause |
| 79 |
\lstset{fancyvrb=true} |
| 80 |
\fvset{commandchars=\\\[\]} |
| 81 |
\begin{fragilesteps} |
| 82 |
\begin{Verbatim}[fontfamily=cmr] |
| 83 |
public long recur(int n) { |
| 84 |
\bstep[ if (n<1) {] |
| 85 |
\rebstep[ return 0;] |
| 86 |
\bstep[ } else if (n == 1) {] |
| 87 |
\rebstep[ return 1;] |
| 88 |
\bstep[ } else {] |
| 89 |
\rebstep[ return \bstep[recur(n-1)+recur(n-2);]] |
| 90 |
\rebstep[ }] |
| 91 |
} |
| 92 |
\end{Verbatim} |
| 93 |
\end{fragilesteps} |
| 94 |
|
| 95 |
\end{document} |
| 96 |
\endinput |
| 97 |
%% |
| 98 |
%% End of file `verbexample.tex'. |