An introduction to Prosper for LaTex

Tags: latex December 24, 2008

I have decided to try to move away from using Microsoft Office. Not using Word is easy because latex is a lot better. Not using Excel is relatively easy because gnuplot is very good. However, there are no applications that are better than Powerpoint. Since I have not installed Office on my new computer yet, I am attempting to use a combination of dia, prosper, and latex. The newest version of dia, 0.96.1, is actually quite good and much better than previous versions. It is a suitable replacement for Powerpoint in terms of drawing figures. And prosper allows me to create pdf presentations within latex. Since using dia is relatively straightforward while using prosper is not, I will describe how to use prosper.

I will describe installation, basic usage that includes bulleted lists, sizing of text and space, code, graphics, overlays, and pdf generation, and advanced usage that includes scaling images, creating empty lines between text, converting multiple dia files, dealing with multiple columns, and creating a slide template.

Installation

If you use a package manager then the installation is easy. However, if you don't then it is a little more difficult because you need to let latex know where to find prosper. Assuming that you do not have root access to the machine, you can specify the location of prosper through the TEXINPUTS environment variable (supposedly tetex might use an -include-dir option instead). The information in the prosper package states that you need to add the prosper directory to TEXINPUTS. However, I found that you also need to add the img and contrib directories. The .bashrc file wound contain the following line to add these directories assuming prosper is in your home directory: export TEXINPUTS=$TEXINPUTS:$HOME/test/prosper/:$HOME/test/prosper/img:$HOME/test/prosper/contrib

Incidentally, the same is true of a latex package, texpower, that has similar functionality to prosper. The corresponding line is export TEXINPUTS=$TEXINPUTS:$HOME/test/texpower-0-2/:$HOME/test/texpower-0-2/tpslifonts Basic Usage To use prosper, the document class must be set properly and the latex document needs to be divided into slides. The document class can have a number of options. The most important of which are pdf to state that a pdf will be created, slideColor to state that there will be color, colorBG to state that the background can have color, and the slide template that dictates how the slide looks like. I decided to call my slide template simple1. The definition is thus \documentclass[pdf,slideColor,colorBG,simple1]{prosper} After that, each slide is its own environment with a name. The beginning of each slide is indicated by \begin{slide}{Slide Name} and the ending is indicated by \end{slide}. Also, the title slide is generated through the \maketitle command, just like a regular title. Bulleted lists can be generated within slides using the itemize environment (\begin{itemize}, an \item command followed by text per line, and \end{itemize}). There are three levels of bullets. Two ways to control space between items is to put each item in a separate list or to add \vspace* commands that force vertical space. If the list is too low on the slide, then the \vspace* command can be inserted with a negative length to raise the list. Also, if the fonts are the wrong size, they can be adjusted by separating the text by surrounding it with {} and then placing the appropriate size in front, e.g. \small, \footnotesize, or \scriptsize. Also, the \textcolor command can be used to change the color of text. The command has two paramaters, the color and the contents (e.g. \textcolor{red}{text}). The best approach to including code in the presentations is to use an advanced verbatim environment and specify a relative font size. That requires the package definition \usepackage{fancyvrb,relsize} and then the command needs to be of the following pattern where the font size can be adjusted: \begin{Verbatim}[fontsize=\relsize{-5}] ... code ... \end{Verbatim} Including graphics is easy by using the \includegraphics command and specifying the name of an eps file. Prosper allows for a slide to be divided into several overlays such that only parts of a slide appear in any one time. In reality, each overlay is just a separate page. However, the benefit is that parts of a slide need to be defined only once. There is an \overlay command that takes two parameters: the number of overlays and the slide. Within the slide, the easiest way to specify when something appears is to use the \fromSlide command, which also takes two parameters: the first overlay that the text appears on, and the contents to appear. Note that the interplay between formatting and overlays is problematic. Therefore it is very important that the second parameter to the \fromSlide command only contains simple elements like text, entire bulleted lists, verbatim environments, and graphics. Anything too complicated may cause problems. The following commands can be used to generate a presentation, e.g. in presentation1.tex, and make sure the fonts are okay: latex presentation1 dvips -Ppdf -G0 presentation1 -o ps2pdf13 -dSubsetFonts=true -dCompatibility=1.3 -dEmbedAll presentation1.ps pdffonts pres.entation1pdf Note that the options for dvips are essential. Otherwise quite a few characters will appear really screwed up. Advanced Usage One of the problems with images is that they tend to be too big or too small. A good way to deal with images is to create them to be about the same size and then scale multiple images together using the same scaling factor. That way, the scaling factor can be changed easily for multiple images. It is also possible to use several scaling factors. For example, the follow code scales two images, img1.dia.eps and img2.dia.eps, by a factor of 0.25: \newcommand{\scalefactor1}{0.25} \includegraphics[scale=\scalefactor1]{img1.dia.eps} \includegraphics[scale=\scalefactor1]{img2.dia.eps} Creating empty lines between text is a bit of a pain. Usually it is necessary when there are several short points to be made, when there is a heading followed by text, or text followed by a graphic. To create a space, a line needs to be ended by \\, then a line with a single space command (i.e. '\ ' without the quotes) needs to appear, followed by an empty line. For example: line 1: 'text1\\' line 2: '\ ' line 3: '' line 4: 'text2' To convert multiple figures from dia to eps, I use the following script for x in *.dia ; do dia$x -e \$x.eps ; done

A surprisingly difficult effect to create is multiple columns. The way to create them is to use a minipage environment, one minipage per column. However, the minipage environment is very sensitive to spacing and tends to cause figures to be grossly unaligned with text.

The basic usage is to specify that text is aligned at the top of the minipage and the width of the minipage. Then within the minipage, if the contents should be centered, then a \centering command needs to be issued. Also, between minipages, an \hspace command can be issued to separate the columns. A single slide can have about 8.3cm worth of minipages and empty space. When a graphic starts a minipage there are usually problems. These can be avoided by putting a title at the top or by using the \raisebox command, which takes two parameters, the amount to raise the box by and text, which in this case is the \includegraphics command. When the graphic is too big for the minipage, formatting gets really bad. Lots of tweaking is involved.

Creating a slide template is relatively complex. I used a number of files that come with prosper for reference. In particular, the prosper.cls class that defines some basic information and the PPRdefault.sty file, which contains a basic slide template. For prosper, the template files have PPR prepended and end in sty. Latex looks for them in the prosper directory or the current directory. Therefore the simple1 template mentioned befor would be in the file PPRsimple1.sty.

The files that come with prosper are put in /usr/share/texmf/tex/latex/prosper On a side not, many programs are installed into the /usr/share directory. For example /usr/share/vim contains vim files.

The following is the PPRsimple1.sty file with explanations in latex comments.

% most of the file is based on PPRdefault.sty with the end from prosper.cls

%standard frontmatter

\NeedsTeXFormat{LaTeX2e}[1995/12/01]

\ProvidesPackage{PPRsimple1}[2008/10/14]

\typeout{‘simple1’ style for Prosper ---}

% all fonts sans serif

\FontTitle{%

\usefont{T1}{phv}{m}{n}\fontsize{21pt}{18pt}\selectfont\black}{%

\usefont{T1}{phv}{m}{n}\fontsize{21pt}{18pt}\selectfont\black}

\FontText{%

\black\usefont{T1}{phv}{m}{n}\fontsize{12.0pt}{11.0pt}\selectfont}{%

\black\usefont{T1}{phv}{m}{n}\fontsize{12.0pt}{11.0pt}\selectfont}

% Positionning of the title of a slide.

\newcommand{\slidetitle}[1]{%

\rput[c](5.25,4.2){\fontTitle{#1}}

}

% Positionning for a logo

\LogoPosition{-1,-1.1}

% Definition of this style for slides.

\newcommand{\NoFrame}[1]{%

\PutLogo % Mandatory

{#1}}

%can modify what is added besides page with \slideCaption{}

\NewSlideStyle{t}{5.3,3.0}{NoFrame}

\PDFCroppingBox{10 40 594 800}

% show no text for caption

\slideCaption{~}

%the following modifies how the number of each slide appears and ensures that the number is not too far out of bounds

% the style must be called GenericPageStyle to work properly

% assumes no totalling

% from prosper.cls, except renew, no ~--~p. in the last print, and a forced 5mm hspace added

\renewpagestyle{GenericPageStyle}{\hfill }{\ifnoFooter\else\hfill%

\ifisDraft

{\@colorFoot\tiny \textbf{\jobname.tex}~--~\@Title~--~\@Author~--~\number\day/\number\month/\number\year~--~\timenow~--~p.~\thepage\ifallPages/\realpageref{last@page}\fi\hspace*{5mm}}%

\else

\ifshowVersion

{\@colorFoot\tiny \textbf{\jobname.tex}~--~\@Title~--~\@Author~--~\number\day/\number\month/\number\year~--~\timenow~--~p.~\thepage\ifallPages/\realpageref{last@page}\fi\hspace*{5mm}}%

\else

{\@colorFoot\tiny \@cartouche~\thepage\ifallPages/\realpageref{last@page}\fi\hspace*{5mm}}%

\fi\fi\fi

}

% end from prosper.cls, the rest is from PPRdefault.sty

\RequirePackage{semhelv}

\myitem{1}{\includegraphics[width=.4cm]{red-bullet-on-white.ps}}

\myitem{2}{\includegraphics[width=.3cm]{green-bullet-on-white.ps}}

\myitem{3}{\includegraphics[width=.3cm]{yellow-bullet-on-white.ps}}

\endinput

Those were the base requirements necessary for me to create a simple presentation in latex. Overall the combination of dia, latex, and prosper works well as a replacement for powerpoint. The diagrams can be fiddled with extensively with dia very accurately, which is almost always required, and everything else appears quite good without too much effort.