summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/flipbook/flipbook-doc.tex
blob: 09ccdcae09781a0dcaf8e7b02dc6a283b5d8508b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
\documentclass[a4paper,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage{xspace}
\usepackage{url}

\usepackage[debug]{flipbook}

% Where animations are put in the corners.
\lhead[top left]{}
\rhead[]{top right}
\lfoot[bottom left\\
  \fbInputF{./Images/Anims/anASCII/an}{tex}{0.3}]{}
\rfoot[]{bottom right\\
  \fbInputB{./Images/Anims/anASCII/an}{tex}{0.3}
}

% One can use a higher footer if it looks nicer.
%\addtolength{\footskip}{1cm}


\def\Flipbook{{\bf Flipbook}\xspace}
\def\flipbook{{\bf flipbook}\xspace}

\title{The \Flipbook Package\\
  --- Documentation ---}
\author{
  Olivier Buffet\\
  \url{firstname.lastname@loria.fr}
}

\begin{document}

\maketitle

\begin{abstract}
  How to add flip book animations in the corners of your \LaTeX{}
  documents.
\end{abstract}

\section{About Flip Book Animations}

\subsection{Introduction}

The \LaTeX{} \flipbook package is a small package intended to help you
add flip book animations in the corners of your documents. A flip book
(or ``flick book'') is a book in which each page represents one image
of an animation, so that one obtains a smooth animation by quickly
flipping the book's pages (usually by releasing the pages held with
your thumb).\footnote{As anything you can think of is already
  somewhere on the internet, please go on youtube and check out a
  video on how to use a flipbook: \url{http://www.youtube.com/} .}

The present package only serves to put such animations in corners of
documents (in one of the four ``external'' corners of pages). This
document for example has two flip book animations: one in the bottom
right corner of odd pages, and one in the bottom left corner of even
pages.

Useful links:
\begin{itemize}
\item \url{http://www.flipbook.info/}
\item \url{http://en.wikipedia.org/wiki/Flip_book}
\end{itemize}

\subsection{Ordering}

An important observation is that, flip book animations from left and
right corners go in opposite directions. In traditional flip books,
full page animations are printed on right pages, and the animation
starts on the first page. IMHO, for corner animations on standard
A4/letter paper, it seems reasonable for the animations to go:
\begin{itemize}
\item from the end of the document to its beginning in (top/bottom)
  right corners, and
\item from the beginning of the document to its end in (top/bottom)
  left corners.
\end{itemize}
The idea is that one uses its thumb to release new images (/pages) on
top of previous images in the animation.

Whatever your choice of ordering, a consequence of the fact that left
and right pages are associated with opposite orderings is that each of
this package's commands comes in two versions: one for left corners
and one for right corners. The commands defined in this package are of
the form \verb+\fbCOMMAND*+ where \verb+COMMAND+ is the command name
and \verb+*+ has to be replaced by \verb+F+ or \verb+B+ to specify if
you want to use an animation going Forward of Backward.


\section{About this Document}

Below are instructions to use the \flipbook package. The \LaTeX{}
source of two documents serve as examples of how to use {\tt flipbook.sty}
 style file:
\begin{itemize}
\item {\tt flipbook-doc.tex}: this documentation, which contains a
  very basic ASCII art animation, and can thus be compiled with both
  \LaTeX{} of pdf\LaTeX{},
\item {\tt flipbook-ex.tex}: an example with animations based on PNG or
  PDF images, so that the compilation requires pdf\LaTeX{}.
\end{itemize}

This package requires the following packages:
\begin{itemize}
\item {\tt fancyhdr},
\item {\tt graphicx},
\item {\tt verbatim},
\item {\tt scalefnt},
\item {\tt everypage},
\item {\tt ifthen}.
\end{itemize}
One could easily make a lighter version without some of them (e.g., in
case of incompatibilities with other packages).

\section{Creating Your Own Flip Book Animations}

\subsection{Initialization}

Whatever the type of animation to use, using this package first
requires going through the following two steps:
\begin{enumerate}
\item In most cases, your document will be printed on both sides
  (thanks to modern printers), requiring to distinguish left and right
  (even and odd) pages.

  You should thus make sure to specify the ``twoside'' option when
  specifying your documentclass. For example, the first line in the
  source code for this documentation is:
\begin{verbatim}
\documentclass[a4paper,twoside]{article}
\end{verbatim}

  In case your document is to be printed on a single side, you can
  specify the ``oneside'' option for your documentclass instead, as
  in:
\begin{verbatim}
\documentclass[a4paper,oneside]{article}
\end{verbatim}
  Note that, in this case, all pages are considered to be right pages.

\item Then, to make use of the \flipbook package, add the following
  line in the preamble:
\begin{verbatim}
\usepackage{flipbook}
\end{verbatim}
\end{enumerate}

\subsection{Using Standard Graphics}

Here are the instructions to create your own flip book animations
using standard graphics (either vector or bitmap images):
\begin{enumerate}
\item For each animation, put a {\bf numbered} sequence of
  eps/pdf/png/jpg images in a directory.
\item Use the {\tt fancyhdr} commands (also in the preamble) to create
  your animations, for example (with two different approaches for
  placement):\footnote{See Section~\ref{sec:other} if you need to use
    other commands.}
\begin{verbatim}
\lfoot[~ \\
  \fbImageF{./Images/Anims/an2/im}{pdf}{scale=0.18}]{}
\rfoot[]{\thepage
  \setlength\unitlength{1cm}
  \begin{picture}(0,0)
    \put(2.5,-2.5){
      \fbImageB{./Images/Anims/an3/im}{png}{scale=0.25}
    }
  \end{picture}
}
\end{verbatim}
  Please, be careful when placing your images: they should be as close
  to the corner as possible, but your printer should still print them
  properly (most printers leave a white border out).
\item An important point is the use of the \verb+fbImage*+ command
  (where \verb+*+ is \verb+L+ or \verb+R+ depending whether one is
  working in the left or right corner). Assuming:
  \begin{itemize}
    \item that one set of images is in directory \verb+DIR+ with a name such as
      \verb+PREFIXnn.png+,
    \item and that you want all of them to be scaled by a factor of
      \verb+.2+ (other options of the \verb+includegraphics+ command
      are possible),
    \end{itemize}
    then you have to use the command:
    \\
    \verb+\fbImage*{./DIR/PREFIX}{png}{scale=0.2}+
\end{enumerate}

Note: The \verb+graphicx+ package is used to display pictures using
the \verb+\includegraphics+ command.

\subsection{Using ASCII Art}

The previous section has shown how to use the \verb+fbImage*+ command
to display images. Two other commands are provided to display text:
\begin{itemize}
\item \verb+fbInput*+: allows including a \verb+tex+ file; in the
  present document it is used in the bottom right corner as follows:
\begin{verbatim}
\fbInputB{./Images/Anims/anASCII/an}{tex}{0.3}
\end{verbatim}
the three arguments are (i) the directory and prefix of the ``image''
files, (ii) the suffix of the ``image'' files, and (iii) the scale;
\item \verb+fbVerb*+: allows including a raw text file (in verbatim
  mode); in the present document it is used in the bottom left corner
  as follows, showing the source of \LaTeX{} files:
\begin{verbatim}
\fbVerbF{./Images/Anims/anASCII/an}{tex}{0.3}
\end{verbatim}
\end{itemize}

\subsection{Debugging}

If nothing appears, this may be because your images are placed outside
the page (tune the coordinates of the \verb+\put+ command).

Another common cause of missing pictures is that your images are not
found (no error message is displayed because there would typically be
too many of them).

To facilitate tracking such mistakes, one can call the package with
the ``debug'' option. It prints a warning message for each ``missing
file'' (1) in the console, and (2) instead of the missing file (so, if
no message is displayed, this may be that the coordinates are wrong).

\section{Comments}

\subsection{Other Means of Controlling Headers and Footers}
\label{sec:other}

With some document classes (e.g., \verb+book.cls+ or
\verb+thloria.cls+), you may prefer using the \verb+\OddHead+,
\verb+\EvenHead+, \verb+\OddFoot+, \verb+\EvenFoot+ commands. Here is
an example validated with \verb+thloria.cls+:
\begin{verbatim}
%-------------------------------------------------------------------
%                             flipbook
%-------------------------------------------------------------------

% display flipbook at the bottom right of each normal page
\EvenHead{{\leftmark}{\thepage\hfil{\slshape\leftmark}}}
\OddHead{{\leftmark\rightmark}{{\slshape\rightmark}\hfil\thepage}}
\OddFoot{
  \hfil
  \setlength\unitlength{1cm}
  \begin{picture}(0,0)
    \put(0.25,-1.75){
      \fbImageB{../Images/Anims/an2/im}{pdf}{scale=0.25}
    }
  \end{picture}
}
\EvenFoot{}

% display also on special pages (chapter titles, etc)
\pagestyle{Fancy}
\fancyhf{}

\fancypagestyle{plain}{
  \fancyhead{}
  \renewcommand{\headrulewidth}{0pt}
  \fancyfoot[RO]{
    \setlength\unitlength{1cm}
    \begin{picture}(0,0)
      \put(0.25,-1.75){
        \fbImageB{../Images/Anims/an2/im}{pdf}{scale=0.25}
      }
    \end{picture}
  }
} 
\end{verbatim}

\subsection{Warning: File Size}

Do not forget that animations include many pictures and that each
picture uses disk space. Be careful to prefer vector graphics, or
possibly avoid high-quality bitmap pictures, if you want to keep your
file size reasonable.

\subsection{Going Further}

This package provides simple commands to create flip books based on
vector/bitmap images, or ASCII art.

It should be easy to use various packages to generate animations using
\LaTeX{}, e.g., using pstricks, tikz, or generating files thanks to
external applications (using shell escape)...

\subsection{TODO}

Ideas for the future:
\begin{itemize}
\item Make it possible to define lists of animations (one per usable corner).
\item Allow references to animations, as for floats
  (figure/table/algorithm/...), or at least to the interval of pages
  corresponding to a given animation.
\end{itemize}

\subsection{Your Creations}

I'd be happy to know about your \LaTeX{} documents
(reports/theses/books/...) including flip books. 

\subsection{Acknowledgments}

Thanks to Christophe Thiéry, Cláudia Tavares, Arnaud Glad and Stephen
Willshaw for their help and feedback.

\newpage
A
\newpage
A
\newpage
A
\newpage
A
\newpage
A

\end{document}


% Local IspellDict:        american
% (The above line tells ispell to run by default with an american dictionary.)