Running

LaTeX showcase

Martin's virtual lair

Here is the talk I gave at the annual Postgraduate Research Symposium of the University of Leeds on 30 June 2010. It uses the LaTeX beamer class for presentations together with some specific packages and templates. In this article I will explain these technical aspects of my presentation.

• the custom theme is progressbar v0.32 of Sylvain Bouveret: http://recherche.noiraudes.net/en/LaTeX.php
• the font used is Palatino
• the animated vector graphics on page 11 were done with the PSTricks extension pst-solides3d

With the exception of the custom theme, everything should be included in a recent and comprehensive LaTeX installation. In case you're wondering, the two graphics in the left picture above were created with Inkscape and Mathematica, respectively.

How do we set up everything? First, let's have a look at the preamble of the LaTeX document:

\documentclass[10pt]{beamer}  % using the Beamer class for presentations
\usetheme{progressbar}        % using the custom theme "Progressbar"
\usecolortheme{crane}         % using the yellow color theme "crane"
\usepackage{pst-solides3d}    % loads the PSTricks package for 3D graphics
\usepackage{animate}          % loads the package for animations
\usepackage[T1]{fontenc}      % using the "Palatino" font
\usepackage{iwona}
\usepackage{palatino}

In order to use the custom theme progressbar, we first need to download it and place all its files in the same directory as the LaTeX file. The third line of the preamble loads the crane color theme, one of the standard color themes of the Beamer class. The next two lines are the prerequisites for creating animated vector graphics. Note that the PSTricks package pst-solides3d automatically loads pstricks itself, so we don't need to make an entry for that. Finally, the last three lines instruct LaTeX to use the Palatino font (Don't ask me why we need three commands here. I grabbed that bit from the internet, and it does not work for me if I omit one of the lines).

It is worth mentioning that I used version 0.32 of the progressbar theme instead of the latest version 0.42, because my presentation looks a bit better with the old color scheme. I've sent an email to Sylvain asking him whether he could bring back the old style as an option in future versions, and he replied that he will consider it for the upcoming 0.5x branch.

When opening the presentation with the Adobe Reader, one should see animations of rotating polyhedra on page 11. They were created with the help of the pst-solides3d and animate packages. The first package provides an interface to access the powerful vector graphics capabilities of PSTricks in order to generate 3D graphics. The second package enables us to create animations from this, and to embed them in the resulting PDF file. The compilation chain is latex → dvips → ps2pdf, because PSTricks does not work with pdflatex (though there exist some workarounds for that). It must also be noted that not all PDF readers support embedded movies and animations. For vector animations the Adobe Reader is a safe choice, because it can play them back on all platforms (Win, Mac, Linux).

Here's how we can create the fancy animated objects: The pst-solides3d package comes with some predefined geometric solids such as the sphere, cube and the Platonic solids. The yellow polyhedron on the left is the icosahedron, one of the five Platonic solids. It can be easily generated with the code below, and the output should look like this (source code).

\begin{figure}[ht]
\begin{animateinline}[autoplay, loop]{20}
\multiframe{72}{rotationangle=0+1}{
\psset{viewpoint=0 -100 30,Decran=115,lightsrc=-50 -100 80, lightintensity=1.2}
\begin{pspicture}(2.1,2.25)
\psSolid[object=icosahedron,a=1,RotZ=\rotationangle,fillcolor=yellow,
action=draw*](1.0,0,1.05)
\end{pspicture}
}
\end{animateinline}
\end{figure}

Let's analyze the code. The {animateinline} environment encompasses the part where an animation should be played. The options [autoplay, loop]{20} mean that the animation should start automatically, play at 20 frames per second, and loop forever. The next line specifies that 72 individual frames should be generated, and that the variable rotationangle should be set to 0, with an increment of 1 with every frame. The line starting with \psset takes some options that specify the viewpoint and the light/shadow properties (for full information see the pst-solides3d manual). We are now ready to start the actual {pspicture} environment which will draw a PSTricks vector graphic. The numbers in round brackets specify the dimensions and offset of the picture. The most important command is \psSolid which will draw the actual solid. Here we specify that a yellow icosahedron with edge lengths of 1 should be drawn, and that it should be rotated around the vertical Z-axis by a degree given with the variable rotationangle. For a general three-dimensional object we would have to rotate by 360 degrees to return to the starting orientation, but due to the icosahedral symmetry we only need to go to 360/5 = 72 degrees to return to an orientation identical to the start orientation.

Let's now have a look at the orange polyhedron in the above right picture. This "cubic antiprism" does not come as a prefab in the pst-solides3d package, so we have to provide LaTeX with all its vertices and surfaces. The following code should generate this output (source code).

\begin{figure}[ht]
\begin{animateinline}[autoplay, loop]{20}
\multiframe{90}{rotationangle=0+1}{
\psset{viewpoint=0 -100 30,Decran=150,lightsrc=-50 -100 80, lightintensity=1.2}
\begin{pspicture}(3.0,2.5)
\psSolid[object=new,RotZ=\rotationangle,fillcolor=orange,
sommets=
0.3289   0.7941  0.5110
-0.3289 -0.7941  0.5110
0.7941  -0.3289  0.5110
-0.7941  0.3289  0.5110
0.3289  -0.7941 -0.5110
-0.3289  0.7941 -0.5110
0.7941   0.3289 -0.5110
-0.7941 -0.3289 -0.5110,
faces={
[4 6 5 7]
[2 6 0]
[2 4 6]
[1 4 2]
[1 7 4]
[3 7 1]
[3 5 7]
[0 5 3]
[0 6 5]
[0 3 1 2]},
action=draw*](1.08,0,0.95)
\end{pspicture}
}
\end{animateinline}
\end{figure

Much of this code is analogous to the code of the previous example. The important difference is that object=new specifies that we are now dealing with a custom object whose geometric properties need to be passed to the \psSolid command. This can be done either directly in the LaTeX file (as done here) or by importing a 3D data file (.obj and .off files, see pst-solides3d manual for more info). The cartesian (x,y,z)-coordinates of the antiprism's eight vertices are passed to the sommets list. Finally, we need to feed the faces list with information as to how the object's surfaces are spanned between the vertices. For example, [0 1 2 3] means that the first four vertices from the sommets list span a face (namely the square on top of the antiprism). The same applies to the other faces, with each face being spanned by at least three vertices. That's easy enough, but a few things must be kept in mind: Firstly, the count of the vertices starts with 0, not with 1. Secondly, the vertices of a face should be listed either in clockwise or counter-clockwise order, otherwise the face will not get drawn correctly. Thirdly, it seems that pst-solides3d sometimes has trouble to determine which faces lie in front of others, and just draws the surfaces in the order as they appear in the faces list. So to be safe, the list should be started with those surfaces that lie furthest behind. This explains why I have [0 3 1 2] instead of [0 1 2 3] in the list above, and why this item comes last (it's because the top square of the antiprism is never concealed by other faces).