From EPrints Documentation
Revision as of 18:29, 11 August 2009 by Tdb01r (talk | contribs) (New page: <!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost. -...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


EPrints::Latex - Module for handling rendering latex equations in metadata as images.


Some repositories may want to spot latex style equations in titles and abstracts and render these as images instead. This module provides that functionality.


 $xhtml = EPrints::Latex::render_string( $session, $field, $value )

This function is intended to be passed by reference to the render_single_value property of a metadata field. It returns just an XHTML DOM string unless it spots anything which looks like a latex style equation, if so the equation is replaced with and img element, the URL of which is a CGI script which will render the equation as an image.

For example the equation

$x = \frac{-b_+_^-^\root{b^2^-4ac}}{2a}$ 

is the quadratic equation. If you're not a physics academic then that probably dosn't mean much to you, but that's how the physics community like to write their equations!


 $imgfile = EPrints::Latex::texstring_to_png( $session, $texstring )

Return the location of a PNG image file containing the latex fragment $texstring.

This uses a directory to generate and cache the images. So the system only has to go to the effort of rendering any equation once. The directory is "latexcache" in the htdocs directory of the repository.

The filename of the cached png is the md5 of the latex equation as a string of hex characters.

The images always have a white background.

This uses the rather obvious system of creating a latex file with $texstring in, running latex on it, running dvips on the resulting dvi file to get a postscript file of a page with the equation in the corner. Then uses GNU convert crop the postscript and turn it into a PNG.