Putting on LaTeX …

As you can see I have switched from the nice but common layout to this darker theme. I also set up some links you might find interesting.

The main topic of this post is about the inclusion of (La)TeX in HTML. To keep the promises I’ve made in my mission statement, nice formulae will play an important role in this blog, so I was looking for a solution to this problem.
I found some code that was supposed to generate images using a server but that didn’t work very well. I’m kind of a DIY-guy, so I set up this minimalistic piece of code that generates a dvi-file and converts it into a png-image.

This is the LaTeX file:

\pagestyle{empty} % clipping won't work with headers/footers

And to compile it type:

latex NameOfYourFile.tex
dvipng NameOfYourFile.dvi -D 100 -T tight

The optional -T tight clips off all borders around the formula (that’s why it is important to set \pagestyle{empty}).
You can adjust the image’s size by altering the resolution (the png below was created using -D 200) if something should be illegible (fractions!).

Normal Distribution (PDF)

The Normal Distribution's probability density function (PDF) rendered in LaTeX

On the right you can see the result of the above code (not really: I manually inverted the colors).

I must admit that this approach isn’t very efficient if you need a lot of formulae, but if you only occasionally want to impress people visiting your site with a little math this might be worth a try.

Tags: ,

Thursday, February 5th, 2009 LaTeX

1 Comment to Putting on LaTeX …

  • Andres says:

    Love this i’m going to use it if you don’t mind on my own attempt to explain myself latex.
    Thanks again! Excel2latex sounds like great stuff too!

  • Leave a Reply