Requirements common to all installationsLatexRender is capable of rendering 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:
Installation in MoodleTo install this filter in Moodle, simply unpack the the distribution inside Moodle's filter folder. This will create the latexrender subfolder. The default settings in class.latexrender.php should be go enough to start with, namely the usage of png images stored in a subfolder of the datadir. Next, log on to Moodle as the administrator and go on to Site Administration/Modules/Filters/Manage filters. You should see the filter Latexrender in the filters list. Click on the eye icon to activate the filter. Optionally, you can go on to Site Administration/Modules/Filters/Manage filters/Latexrender and change de filter defaults. Hit the Save Changes button when you are done. Please notice that if you change the image format after a while, you will have to clean the image cache manually. If you are using Moodle 1.9.5+, you might want to apply this security patch on moodle to let LatexRender filter user's input to remove potentially harmful commands. To apply it, go to the root of moodle's installation tree, make a backup of the whole of moodle's code, then issue the following command: patch -p1 < moodle-waldeck.patchThis assumes that the moodle-waldeck.patch file was placed in that same location. The patch file can be deleted afterwards. If the patch program reports errors or notices that certain hunks could not be applied, it might be the case taht you are trying to patch the wrong version of Moodle. In that case, please contact me for possible solutions, and roll back your Moodle code from the backup. Installation in a regular websiteWhat 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
<?php 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 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 formulas in it. Then write down the following code:
<?php 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 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 . Customizing your installationThe 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 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.
// ------------------------------------------------------------------------ Enjoy! |