How can I write a Template.pm filter to generate PNG output from LaTeX source code?

I am looking for a way to generate PNG images of equations from L A T E X source code embedded in templates. For example, given:

[% FILTER latex_display ] \begin{eqnarray*} \max && U(x,y) \\ \mathrm{st} && 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 appear as:

Consumer's Optimization Problem

I use ttree to create documents offline. I know about Template :: Plugin :: Latex, but it aims to create real documents from L A T E X templates.

Any suggestions?

Update:

I appreciate the suggestions (and I voted for them). However, they are not exactly what I need. I would really appreciate some tips on getting started with the plugin or filter for the Template Toolkit.

+4
source share
3 answers

Wikipedia does something similar to what you want. They use a program called texcv . Then you also have MathJAX , which is more focused on dynamic math visualization on web pages.

texcv matches the link page written in OCaml, but since the rest of Mediawiki is written in PHP, I donโ€™t think you will have problems reprogramming the program for use with Perl.

+2
source

you should take a look at jsMath , MathML or mathjax

+1
source

I would really appreciate some tips on getting started with the plugin or filter for the Template Toolkit

These documents on the Template Toolkit website should provide all the necessary information to configure the plugin or filter:

After you sort L A T E X into PNG, 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 this helps.

/ I3az /

+1
source

Source: https://habr.com/ru/post/1306409/


All Articles