File: other_apps.tex

package info (click to toggle)
pyxplot 0.9.2-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,288 kB
  • sloc: ansic: 50,373; xml: 1,339; python: 570; sh: 318; makefile: 89
file content (303 lines) | stat: -rw-r--r-- 12,344 bytes parent folder | download | duplicates (6)
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
% other_apps.tex
%
% The documentation in this file is part of Pyxplot
% <http://www.pyxplot.org.uk>
%
% Copyright (C) 2006-2012 Dominic Ford <coders@pyxplot.org.uk>
%               2008-2012 Ross Church
%
% $Id: other_apps.tex 1302 2012-09-05 17:30:27Z dcf21 $
%
% Pyxplot 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.
%
% You should have received a copy of the GNU General Public License along with
% Pyxplot; if not, write to the Free Software Foundation, Inc., 51 Franklin
% Street, Fifth Floor, Boston, MA  02110-1301, USA

% ----------------------------------------------------------------------------

% LaTeX source for the Pyxplot Users' Guide

\chapter{Other applications of Pyxplot}

In this chapter we present a short cookbook describing a few common yet
miscellaneous tasks for which Pyxplot may prove useful.

\section{Conversion of jpeg images to PostScript}
\index{jpeg images}

The need to convert bitmap images -- for example, those in jpeg format -- into
PostScript representations is commonly encountered by users of the \latexdcf\
typesetting system, since \latexdcf's {\tt includegraphics} command can only
incorporate Encapsulated PostScript (EPS) images into documents.  A small
number of graphics packages provide facilities for making such conversions,
including ImageMagick\index{ImageMagick}'s {\tt convert} command, but these
almost invariable produce excessively large PostScript files on account of
their failure to use PostScript's native facilities for image compression.
Pyxplot's \indcmdt{image} can in many cases perform much more efficient
conversion:

\begin{verbatim}
set output image.eps
image 'image.jpg' width 10
\end{verbatim}

\section{Inserting equations in Powerpoint presentations}
\index{Microsoft Powerpoint}\index{presentations}

The two tools most commonly used for presenting talks\index{presentations} --
Microsoft {\it Powerpoint}\index{Microsoft Powerpoint} and
OpenOffice\index{OpenOffice} {\it Impress} -- have limited facilities for importing
text rendered in \latexdcf\ into slides. {\it Powerpoint} does
include its own {\it Equation Editor}, but its output is considerably less
professional than that produced by \latexdcf.  This can prove a frustration for
anyone who works in a field with notation which makes use of non-standard
characters, but especially for those who work in mathematical and
equation-centric disciplines.

It is possible to import graphic images into {\it Powerpoint}, but it cannot
read images in PostScript format, the format in which \latexdcf\ usually produces
its output.  Pyxplot's {\tt gif} and {\tt png} terminals provide a fix for this
problem, as the following example demonstrates:

\begin{verbatim}
set term transparent noantialias gif
set term dpi 300
set output 'equation.gif'
set multiplot

# Render the Planck blackbody formula in LaTeX
set textcolour yellow
text '$B_\nu = \frac{8\pi h}{c^3} \
\frac{\nu^3}{\exp \left( h\nu / kT \right) -1 }$' at 0,0
text 'The Planck Blackbody Formula:' at 0 , 0.75
\end{verbatim}

The result is a {\tt gif} image of the desired equation, with yellow text on a
transparent background. This can readily be imported into {\it Powerpoint} and
re-scaled to the desired size.

\section{Delivering talks in Pyxplot}

Going one step further, Pyxplot can be used as a stand-alone tool for designing
slides for talks; it has several advantages over other presentation tools.  All
of the text which is placed on slides is rendered neatly in \latexdcf.  Images can
be placed on slides using the \indcmdts{jpeg} and \indcmdts{eps} commands, and
placed at any arbitrary coordinate position on the slide.  In comparison with
programs such as Microsoft {\it Powerpoint}\index{Microsoft Powerpoint} and
OpenOffice\index{OpenOffice} {\it Impress}, the text looks much neater,
especially if equations or unusual characters are required. In comparison with
\TeX-based programs such as Foil\TeX, it is much easier to incorporate images
around text to create colourful slides which will keep an audience attentive.

As an additional advantage, graphs can be plotted within the scripts describing
each slide, directly from \datafile s in your local filesystem. If you receive
new data shortly before giving a talk, it is a simple matter to re-run the
Pyxplot scripts and your slides will automatically pick up the new \datafile s.

Below, we outline our recipe for designing slides in Pyxplot. There are many
steps, but they do not take much time; many simply involve pasting text into
various files. Readers of the printed version of the manual may find it easier
to copy these files from the HTML version of this manual on the Pyxplot
website.

\subsection{Setting up the infrastructure}

First, a bit of infrastructure needs to be set up. Note that once this has been
done for one talk, the infrastructure can be copied directly from a previous
talk.

\begin{enumerate}
\item Make a new directory in which to put your talk:
\begin{verbatim}
mkdir my_talk
cd my_talk
\end{verbatim}
\item Make a directory into which you will put the Pyxplot scripts for your
individual slides:
\begin{verbatim}
mkdir scripts
\end{verbatim}
\item Make a directory into which you will put any graphic images which you
want to put into your talk to make it look pretty:
\begin{verbatim}
mkdir images
\end{verbatim}
\item Make a directory into which Pyxplot will put graphic images of your
slides:
\begin{verbatim}
mkdir slides
\end{verbatim}
\item Design a background for your slides. Open a paint program such as the
{\tt gimp}, create a new image which measures $1024\times768$\,pixels, and fill
it with colour. My preference tends to be for a blue colour gradient, running
from bright blue at the top to dark blue at the bottom, but you may be more
inventive than me. You may wish to add institutional and/or project logos in
the corners. Alternatively, you can download a ready-made background image from
the Pyxplot website: \url{http://foo}. You should store this image as {\tt
images/background.jpg}.
\item We need a simple Pyxplot script to set up a slide template. Paste the
following text into the file {\tt scripts/slide\_init}; there's a bit of black
magic in the {\tt arrow} commands in this script which it isn't necessary to
understand at this stage:\label{stp:presentation_magic}
\begin{verbatim}
scale  = 1.25        ; inch = 2.54 # cm
width  = 10.24*scale ; height =  7.68*scale
x = width/100.0      ; y = height/100.0
set term gif ; set dpi (1024.0/width) * inch
set multiplot ; set nodisplay
set texthalign centre ; set textvalign centre
set textcolour yellow
jpeg "images/background.jpg" width width
arrow -x* 25,-y* 25 to -x* 25, y*125 with nohead
arrow -x* 25, y*125 to  x*125, y*125 with nohead
arrow  x*125, y*125 to  x*125,-y* 25 with nohead
arrow  x*125,-y* 25 to -x* 25,-y* 25 with nohead
\end{verbatim}
\item We also need a simple Pyxplot script to round off each slide. Paste the
following text into the file {\tt scripts/slide\_finish}:
\begin{verbatim}
set display ; refresh
\end{verbatim}
\item Paste the following text into the file {\tt compile}. This is a simple
shell script which instructs {\tt pyxplot\_watch} to compile your slides using
Pyxplot every time you edit any of the them:
\begin{verbatim}
#!/bin/bash
pyxplot_watch --verbose scripts/0\*
\end{verbatim}
\item Paste the following text into the file {\tt make\_slides}. This is a
simple shell script which crops your slides to measure exactly
$1024\times768$\,pixels, cropping any text boxes which may go off the side of
them. It links up with the black magic of Step~\ref{stp:presentation_magic}:
\begin{verbatim}
#!/bin/bash
mkdir -p slides_cropped
for all in slides/*.gif ; do
convert $all -crop 1024x768+261+198 `echo $all | \
sed 's@slides@slides_cropped@' | sed 's@gif@jpg@'`
done
\end{verbatim}
\item Make the scripts {\tt compile} and {\tt make\_slides} executable:
\begin{verbatim}
chmod 755 compile make_slides
\end{verbatim}
\end{enumerate}

\subsection{Writing a short example talk}

The infrastructure is now completely set up, and you are ready to start
designing slides. We will now design an example talk with three slides.

\begin{enumerate}
\item Run the script {\tt compile} and leave it running in the background.
Pyxplot will then re-run the scripts describing your slides whenever you edit
them.
\item As an example, we will now make a title slide. Paste the following script
into the file {\tt scripts/0001}:
\begin{verbatim}
set output 'slides/0001.gif'
load 'scripts/slide_init'

text '\parbox[t]{10cm}{\center \LARGE \bf \
  A Tutorial in the use of Pyxplot \\ \
  to present Talks \
} ' at x*50, y*75
text '\Large \bf Prof A.N.\ Other' at x*50, y*45
text '\parbox[t]{9cm}{\center \
  Director, \\ \
  Atlantis Island University \
} ' at x*50, y*38
text 'Annual Lecture, 1st January 2010' at x*50, y*22

load 'scripts/slide_finish'
\end{verbatim}
Note that the variables {\tt x} and {\tt y} are defined to be 1~per cent of the
width and height of your slides respectively, such that the bottom-left of each
slide is at $(0,0)$ and the top-right of each slide is at $({\tt 100*x},{\tt
100*y})$.
\item Next we will make a second slide with a series of bullet points. Paste
the following script into the file {\tt scripts/0002}:
\begin{verbatim}
set output 'slides/0002.gif'
load 'scripts/slide_init'

text '\Large \textbf{Talk Overview}' at x*50, y*92
text "\parbox[t]{9cm}{\begin{itemize} \
 \item Setting up the Infrastructure. \
 \item Writing a Short Example Talk. \
 \item Delivering your Talk. \
 \item Conclusion. \
 \end{itemize} \
} " at x*50 , y*60

set textcol cyan
text '{\bf With thanks to my collaborator, \
           Prof Y.E.\ Tanother.}' at x*50,y*15

load 'scripts/slide_finish'
\end{verbatim}
\item Finally, we will make a third slide with a graph on it. Paste the
following script into the file {\tt scripts/0003}:
\begin{verbatim}
set output 'slides/0003.gif'
load 'scripts/slide_init'

text '\Large \bf The Results of Our Model' at x*50, y*92
set axescolour yellow ; set nogrid
set origin x*17.5, y*20 ; set width x*70
set xrange [0.01:0.7]
set xlabel '$x$'
set yrange [0.01:0.7]
set ylabel '$f(x)$'
set palette Red, Green, Orange, Purple

set key top left
plot x t 'Model 1', exp(x)-1 t 'Model 2', \
     log(x+1) t 'Model 3', sin(x) t 'Model 4'

load 'scripts/slide_finish'
\end{verbatim}
\item To view your slides, run the script {\tt make\_slides}. Afterwards, you
will find your slides as a series of $1024\times768$\,pixel jpeg images in the
directory {\tt slides\_cropped}.  If you have the {\it Quick Image
Viewer}\index{Quick Image Viewer} ({\tt qiv}) installed, then you can view them
as follows:
\begin{verbatim}
qiv slides_cropped/*
\end{verbatim}
If you're in a hurry, you can skip the step of running the script {\tt
make\_slides} and view your slides as images in the {\tt slides} directory, but
note that the slides in here may not be properly cropped. This approach is
generally preferable when viewing your slides in a semi-live fashion as you are
editing them.
\item If you'd like to make the text on your slides larger or smaller, you can
do so by varying the {\tt scale} parameter in the file {\tt
scripts/slide\_init}.
\end{enumerate}

%The three slides which we have designed can been seen in
%Figures~\ref{fig:presentation_slide1}, \ref{fig:presentation_slide2} and
%\ref{fig:presentation_slide3}.

\subsection{Delivering your talk}

There are two straightforward ways in which you can give your talk. The
quickest way is simply to use the {\it Quick Image Viewer}\index{Quick Image
Viewer} ({\tt qiv}):
\begin{verbatim}
qiv slides_cropped/*
\end{verbatim}
Press the left mouse button to move forward through your talk, and the right
mouse button to go back a slide.

This method does lack some of the niceties of Microsoft {\it Powerpoint} -- for
example, the ability to jump to any arbitrary slide number, compatibility with
wireless remote controls to advance your slides, and the ability to use
animated slide transitions. It may be preferably, therefore, to paste the jpeg
images of your slides into a {\it Powerpoint} or OpenOffice {\it Impress}
presentation before you give your talk.