Difference between revisions of "API:EPrints/Latex"

From EPrints Documentation
Jump to: navigation, search
(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. -...)
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- 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.
+
This page has been automatically generated from the EPrints 3.4 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{Pod2Wiki}}{{API:Source|file=EPrints/Latex.pm|package_name=EPrints::Latex}}[[Category:API|Latex]]<!-- End of Pod2Wiki -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Latex.pm|package_name=EPrints::Latex}}[[Category:API|LATEX]]<div><!-- Edit below this comment -->
<!-- Pod2Wiki=head_name -->=NAME=
+
 
 +
 
 +
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 +
==NAME==
 
'''EPrints::Latex''' - Module for handling rendering latex equations in  metadata as images.
 
'''EPrints::Latex''' - Module for handling rendering latex equations in  metadata as images.
  
<!-- End of Pod2Wiki -->
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
<!-- Pod2Wiki=head_description -->=DESCRIPTION=
+
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_description -->
 +
==DESCRIPTION==
 
Some repositories may want to spot latex style equations in titles and abstracts and render these as images instead. This module provides that functionality.
 
Some repositories may want to spot latex style equations in titles and abstracts and render these as images instead. This module provides that functionality.
  
<!-- End of Pod2Wiki -->
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
<!-- Pod2Wiki=item_render_string -->==render_string==
+
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_methods -->
 +
==METHODS==
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
  
  $xhtml = EPrints::Latex::render_string( $session, $field, $value )
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_render_string -->
 +
===render_string===
  
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.  
+
$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  
 
For example the equation  
Line 22: Line 47:
 
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!
 
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!
  
<!-- End of Pod2Wiki -->
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
<!-- Pod2Wiki=item_texstring_to_png -->==texstring_to_png==
+
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
  
  $imgfile = EPrints::Latex::texstring_to_png( $session, $texstring )
 
  
Return the location of a PNG image file containing the latex fragment $texstring.
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_texstring_to_png -->
 +
===texstring_to_png===
  
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.
+
$imgfile = EPrints::Latex::texstring_to_png( $session, $texstring )
 +
Returns the location of a PNG image file containing the latex fragment <tt>$texstring</tt>.
 +
 
 +
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 <tt>latexcache</tt> 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 filename of the cached png is the md5 of the latex equation as a string of hex characters.  
Line 35: Line 66:
 
The images always have a white background.  
 
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.
+
This uses the rather obvious system of creating a LaTeX file with <tt>$texstring</tt> in, running <tt>latex</tt> on it, running <tt>dvips</tt> on the resulting DVI file to get a postscript file of a page with the equation in the corner. Then uses GNU <tt>convert</tt> to crop the PostScript file and turn it into a PNG.
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_copyright -->
 +
==COPYRIGHT==
 +
{{API:Copyright}}
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
  
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
+
</div>
 +
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->

Latest revision as of 00:51, 12 January 2022

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

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


NAME

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

User Comments


DESCRIPTION

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

User Comments


METHODS

User Comments


render_string

$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!

User Comments


texstring_to_png

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

Returns 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 to crop the PostScript file and turn it into a PNG.

User Comments


COPYRIGHT

© Copyright 2023 University of Southampton.

EPrints 3.4 is supplied by EPrints Services.

http://www.eprints.org/eprints-3.4/

LICENSE

This file is part of EPrints 3.4 http://www.eprints.org/.

EPrints 3.4 and this file are released under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation unless otherwise stated.

EPrints 3.4 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints 3.4. If not, see http://www.gnu.org/licenses/.

User Comments