OthersLatexRender

Information and discussion about other tools not listed above.
Post Reply
User avatar
julianms
Posts: 1
Joined: Sun Apr 24, 2011 11:09 am

LatexRender

Post by julianms »

I have a shared website on HostGator .. and a lots of problem with LatexRender... maybe because of the HostGator policy ...
---------------------------------------
Q: How can I install LaTeX on my website like you have on the TeXer and your message board?

A: We used LatexRender, which can be found here. You will need to be able to install LaTeX and imagemagick on your server to use this. That site also has a TeX Converter that doesn't require LaTeX and Imagemagick.
---------------------------------------

http://latexrender-ng.sourceforge.net/install.html
(the archive latexrender-ng-latest.tar.gz has only about 30 KB)

This is the LatexRender-ng Project Install Instructions

- Requirements common to all installations
LatexRender is capable of rendering LATEX fragments into png, gif or svg images seamlessly and beautifully embedded in your pages. For that you will also need the following pieces of software:

* A decent installation of LATEX , including the preview, and AMS packages. Note: you can do without the AMS packages, but you will have to remove the corresponding \usepackage commands from class.latexrender.php file. However, you cannot do without the preview package, and the file preview.sty must be present.
* If you are rendering png or gif images, the dvipng program must have been installed
* If you are planning to experiment with svg images, then the dvisvgm program must have been installed. Note: in this case, your pages must be coded in xhtml instead of plain html and will not work with Internet Explorer, but should work beautifully with Firefox, Opera and Safari.
* Your webserver should be able to execute php 5 code.
* The graphics library gd should be installed and the gd php extension should be loaded. Otherwise, the ImageMagick tools should be present as a fallback. In this case, please adjust the path to the identify program in class.latexrender.php


- Installation in Moodle

[......]

- Installation in a regular website

What I mean by regular websites are those which were coded by you in plain html or php and do not possess a content-management infrastructure.
In that case, you can still use LatexRender but you'll have to do some extra coding as explained below.

First unpack the distribution files somewhere in your website tree and locate the subfolders named pictures and tmp in latexrender. You must change the ownership of these folders to the same user your webserver runs on. In some linux distros, this user might be apache or www-data. This is required so that LatexRender can have write access to these folders.
Next, open up the file named latex.php whose contents are reproduced below.

Code: Select all

<?php
// To customize the filter funcionality, please consider setting the
// the parameters located on the top of class.latexrender.php
//
require_once('[system path to latexrender installation]/class.disk_cache.php');
require_once('[system path to latexrender installation]/class.latexrender.php');
function latex_content ($text)
{
$latexrender_path = '[system path to latexrender installation]';
$latexrender_path_http = '[http path to latexrender installation]';
$cache = new DiskImageCache($latexrender_path.'/pictures', $latexrender_path_http.'/pictures');
$latex = new LatexRender($cache,$latexrender_path_http, $latexrender_path."/pictures",$latexrender_path_http."/pictures",$latexrender_path."/tmp");
$latex->_image_format = "png";
return $latex->latex_content($text);
}
?>
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
In this file, replace the [System path to latexrender installation] and [http path to latexrender installation] with the appropriate values. For instance, suppose that your site is physically located in the folder /var/www/htdocs/mathsite and latexrender was unpacked inside this folder. In this case, the System path to latexrender should be /var/www/htdocs/mathsite/latexrender.

Important: As the superuser you should issue the following commands:
chown www-data:www-data /var/www/htdocs/mathsite/latexrender/pictures
chown www-data:www-data /var/www/htdocs/mathsite/latexrender/tmp
so that LatexRender can write to those folders. Furthermore, the http path to latex render should probably be equal to /mathsite/latexrender

Finally assume that you have a page named fibonacci.html and you want to insert beautiful LATEX formulas in it. Then write down the following code:

Code: Select all

<?php
include_once("[System path to latexrender installation]latex.php");
$text = file_get_contents("fibonacci.html");
echo latex_content($text);
?>
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
and name it fibonacci.php. Now instead of linking to to fibonacci.html, change your website's links to point to fibonacci.php instead.
Not you can insert LATEX fragments like those in the examples page in your page using the [tex]...[/tex] constructs. For instance, if you type [tex]F_{n}=F_{n-1}+F_{n-2},\ n\ge 2[/tex] inside fibonacci.html, you should see :
Image

- Customizing your installation

The topmost part of class.latexrender.php contains several variable definitions and establishes their default values. Although the default values could be suitable to most installations, you might want to tweak with them. Please notice that these values are overriden by the values which were set in the filter settings dialog.
If your LATEX formulas appear too bit or too small, try changing the values of _default_font_size (in pt) and/or _formula_density (in DPI).
The _xsize_limit and _ysize_limit determine the maximum absolute site of the image produced by rendering a single fragment.
// ------------------------------------------------------------------------
// Variable Definitions - you may adjust these values to suit your install
// ------------------------------------------------------------------------
var $_popupwindow = true; // Set this to true if you want popup windows
var $_default_bgcolor="#FFFFFF"; // Default background color (transparent)
var $_image_format = "png"; // default image format: png, gif or svg
var $_html_use_file_ext = true; // htmo uses image format extension?
var $_html_input = true; // Set to true if you use textarea for input
var $_formula_density = 120;
var $_xsize_limit = 1024;
var $_ysize_limit = 500;
var $_string_length_limit = 5000;
var $_default_font_size = 12;
var $_align_to_baseline = true;
var $_latexclass = "article"; //install extarticle class if you wish to have smaller font sizes
var $_font_encoding = "utf8"; // Default character encoding
var $_splashwindow = true; // Disable if you don't want the splash window
// ------------------------------------------------------------------------
// These might also have to be changed depending on you operating system
// and/or distro
// ------------------------------------------------------------------------
var $_latex_path = "/usr/bin/latex"; // path to latex executable
var $_dvipng_path = "/usr/bin/dvipng"; // path to dvipng executable
var $_identify_path="/usr/bin/identify"; // path to identify exec.
var $_dvisvgm_path="/usr/bin/dvisvgm"; // path to dvi->svg converter

Enjoy!

************************************************

I like very much the http://www.CodeCogs.com Latex editor, I use it externally somewhere. But I would like to embed CodeCogs editor but having all those pictures on my server.
So I began the work with LatexRender (I saw MathTex from http://www.forkosh.com/ is even more difficult for HostGator ... and I'm not interested in mimetex)

Finally, after several error caused by paths I arrived to the error "Unparseable or potentially dangerous latex formula. Error 4: the LaTeX compiler exited catastrophically." (the formula is 1+1=2)

************************************************
How can I find where the file preview.sty must be found on server ?
Can I simply upload it ? ... I have only a shared webhost, I don't have root privileges ...

--------------

Is there anyone who managed to have LatexRender being on HostGator ? (on a shared web host ...)

PS. I've had some Chat with the technicians of HostGator and it appears that those packages and that file are not present on servers ...

Is there a solution for this situation ?...

Thanks !
Julian M.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply