Using TeX Text and Equations
in OpenOffice.org Impress

For Linux and other Unix Machines

The formula editor that comes with OpenOffice.org is pretty good. However, there are reasons why one might want to use TeX to typeset your equations. TeX is probably the most powerful equation typesetting language out there. What's more, if you're a TeX or LaTeX user, you already know how to do it. You may prefer the TeX fonts for equations. Finally, there are some very serious limitations in the OpenOffice.org formula editor; for instance, you only get to choose from eight colors.

The basic procedure is to typeset your formula in TeX, and then via various converters turn the formula into a PNG image with a transparent background that can be included as a graphic object in OpenOffice.org. You won't get to edit it further there, but you can sling it around, write other things on top of it, etc.

The drawbacks are that whereas OpenOffice.org equations will scale without pixelization to any resolution (including the resolution of your printer if you print out slides), TeX equations included as images won't. You can get around some of that by just using a high enough resolution in your images. There is the additional problem that OpenOffice.org won't be able to easily convert your included TeX image equations to black and white, as it can do with its own equations, if you print out your slides to a black and white printer.

Requirements

The first two are extremely standard utilities and come with any modern Linux distribution. (The ImageMagick package may not be installed by default, but you should install it.) If you don't have the last one on this list, then you don't care about any of this. You may also need The Gimp, and although these instructions don't cover their use, you may find the netpbm utilities useful.

Write your TeX File

You can either write one TeX file with every equation you might use, and then later crop out each equation individually with The Gimp. Alternatively, each equation can be put into a separate TeX file, and then a couple of shell commands (which may be aliased for convenience) will convert your equation into an image suitable for inclusion in your OpenOffice.org Impress presentation.

Make sure that the background color of the page matches as close as possible the background color you will be using in Impress. In LaTeX, this can be accomplished with the standard color style file. For the example of this page, I had a presentation with the standard OpenOffice.org "blue" background (which, looking at the OpenOffice.org colors, is (r,g,b)=(0,0,128). I wanted a "LightCyan" (r,g,b)=(0,0,255) foreground. This is the LaTeX file I used:

\documentclass{article}
\usepackage{color}
\definecolor{bg}{rgb}{0,0,0.501}
\definecolor{fg}{rgb}{0,1,1}
\pagestyle{empty}
\pagecolor{bg}
\begin{document}
\color{fg}
$$H_0d_M = \frac{1}{\left|\Omega_k\right|^{1/2}}\ \mathrm{sinn}\left\{
   \left|\Omega_k\right|^{1/2} \int_0^{z_1}
   (1+z)^2(1+\Omega_\mathrm{M}z)-z(2+z)\Omega_\Lambda]^{-1/2}dz\right\}$$
\end{document}

The 0.501 in the blue for the background corresponds to 128 on a scale of 0-255. (0.5 maps to 127, hence the additional 0.001.)

Convert your TeX to Postscript

Do this in the standard manner:

latex file.tex
dvips file -o

This will write file.ps. Of course, substitute your actual file's name for "file".

Convert the image

The single command below will take care of this:

convert -units PixelsPerInch -density 300 -trim -border 4x4 -bordercolor \#000080 -matte -transparent \#000080 -type PaletteMatte +repage file.ps file.png

(All of that must be on one line!)

You must customize this as follows: replace file.ps and file.png with the name of the PostScript file written from TeX and the PNG graphics file to be written, respectively. Replace 000080 with an RGB hex triplet for the background color of your image. This must correspond exactly to the background color that was written from TeX and dvips. If you don't know what it is, you can figure it out by looking at the image with The Gimp. Finally, you may want to tune the number after "-density". The number given will probably work for many cases, giving you nice anti-aliased fonts for resolutions where presentations are likely to be used. Smaller numbers mean lower resolution (smaller files, but potentially blockier text), larger numbers mean higher resolution.

Some bits of explanation (unnecessary for using this). First, the -border is not strictly necessary, but I like to have a little bit of padding around my images. The Postscript file written by TeX will be the size of a full page; -trim crops the image down to just the size where there is text (plus whatever border width you specify). The transparency options (including everything with the word "matte" in it) aren't necessary if you're just going to have the equation on a solid background. However, if anything might be underneath it, without transparency the background color of the image would block out those objects. The use of the "PaletteMatte" type mixes the image down to an 8-bit PNG file, which should be more than sufficient for a solid color equation. Additionally, as of version 1.0.1, OpenOffice.org doesn't seem to properly handle PNG transparency with 24-bit PNG images, but does handld it with 8-bit images.

Results

Below is a screen shot of OpenOffice.org impress with this equation. Whee! Of course, this equation is a bit long to include on one line in a presentation like this....

[Screen Shot]


Last modified: 2005-February-08, by Rob Knop

This page may not render correctly with Netscape 4.xx or with MSIE 4 or lower; these browsers are out of date and their support of the web standards is buggy. Upgrade to current versions of your browser, or to Mozilla.