Converting Latex Formulas To Images

If you are preparing a PowerPoint or OpenOffice Impress presentation with lots of mathematical formulas, you have probably noticed how clumsy it is to use their built-in formula generators. If you’d like to have Latex-quality formulas in your presentation, you need to convert your formulas into images. Here is one way to do it:

Typeset your formula in a separate Latex file and convert it to Postscript (the .ps extension). I use Lyx which is a very powerful Latex editor and postscript generation takes one mouse click in it.

Next, download the free ImageMagick image processing package. We will be using the convert command from this package.
sudo apte-get install imagemagick
Then save the following code in a file named conv:


#! /bin/bash
convert -background skyblue -density 300 "$1.ps" -trim -border 35 "$1.jpg"

Make the file executable:

chmod +x conv

Now you can do the conversion as follows:

./conv yourfile.ps

The script is a very simple one-liner that takes a .ps file name as its command line argument, interprets the postscript with a 600 dpi resolution, changes the background color to a very light blue/gray color (which I personally prefer to a bright pure white), then converts it to .jpg and finally trims the image so that it contains only the actual text plus a 30 px margin on each side.

You can then insert these images into your presentation, add shadows, etc.

Here is an example of the images created using this method:

A sample presenation slide with equations generated as described here.

Tagged with: , , , , , , ,
Posted in Computing, Notes
2 Comments » for Converting Latex Formulas To Images
  1. فاخته says:

    سلام نوید:)
    خوبی؟ چه خبرا؟ خیلی وقت خبری ازت نداشتم تا اینکه تصادفی به اینجا رسیدم!

    روش خوبی بود ولی اگر با کمبود وقت مواجه بودی شاید این بهتر باشه:
    http://www.codecogs.com/latex/eqneditor.php

    شاد باشی
    فاخته.

  2. Navid Dianati says:

    Hi Fakhteh! I’m so glad to here from you :) and also, It’s really cool that a friend of mine can randomly end up here looking for a technical solution. Good sign for the website’s traffic ;)

    Thanks for the link! That is definitely faster. I chose my method because 1- I love opensource solutions, 2- It seems to be more customizable if you do it yourself.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Follow Navid on Twitter
Tags
Links
News
Archives
Meta