views:

76

answers:

3

I am looking for a way of generating PNG images of equations from LATEX source code embedded in templates. For example, given:

[% FILTER latex_display ]
\begin{eqnarray*}
\max && U(x,y) \\
\mathrm{s.t.} && p_x x + p_y y \leq I \\
&& x \geq 0, y \geq 0
\end{eqnarray*}
[% END %]

I would like to get the output:

<div class="latex display"><img src="equation.png" width="x" height="y"></div>

which should ultimately display as:

Consumer's Optimization Problem

I am using ttree to generate documents offline. I know about Template::Plugin::Latex but that is geared towards producing actual documents out of LATEX templates.

Any suggestions?

Update:

I appreciate the suggestions (and I have voted them up). However, they are no quite what I need. I would really appreciate a few pointers towards getting started with a Plugin or Filter for Template Toolkit.

+2  A: 

Wikipedia does something similar to what you want. They use a program called texcv. Then you also have MathJAX which is more aimed at dynamic math rendering in web-pages.

texcv is according to the linked page written in OCaml however since the rest of Mediawiki is written in PHP I don't think you should have any problem with repurposing the program to use with Perl.

adamse
+1  A: 

you should take a look at jsMath, MathML, or mathjax

Mica
+1  A: 

I would really appreciate a few pointers towards getting started with a Plugin or Filter for Template Toolkit

These docs on Template Toolkit site should provide all necessary info to setup a plugin or filter:

Once you have your LATEX to PNG conversion sorted then you probably need to save it as a file using redirect. Example from POD:

[% PROCESS my/png/generator 
    FILTER redirect("images/logo.png", binmode=1) %] 

Hope that helps.

/I3az/

draegtun