JsMath

Summary: Add markup to display and embed mathematical formulas in wiki pages using TeX.
Version: 20160803
Prerequisites: pmwiki-2.2.58
Status: Obsolete - use MathJax
Maintainer: Ben Woodruff - You should consider using MathJax instead. MathJax is the new jsMath.
Categories: Markup Math PHP72
Discussion: JsMath-Talk

You should consider using MathJax instead of jsMath. MathJax is the successor of jsMath. - added by Ben Woodruff

Questions answered by this recipe

  • How can I include mathematical formulas in my webpage, using TeX/LaTeX notation.
  • Can I use both $ $ and $$ $$ LaTeX environments, so that I can have equations automatically centered when needed. For example: \sqrt{n}, \int_a^b f(x) dx, \displaystyle \int_a^b f(x) dx and
    \sqrt{n}, \int_a^b f(x) dx

Notice that you can double click on images to see the LaTeX code.

  • Can I get mathematical formulas to change size as the text changes size? (Yes. You can either install the TeX fonts, adjust the options in the jsMath control panel, or reload your page once you get to the desired size, and the images will download correctly.)
  • Is there a way to print crisp clean mathematics directly from the webpage?

Description

Embed scalable mathematics in webpages with high print quality.

Notes

You can download jsMath from the author's website at http://www.math.union.edu/locate/jsMath. It is a javascript method of embedding mathematics into webpages. Users can either view mathematics output using precompiled images on the server, or users can download and install TeX fonts on their computer which speed up the view experience and increase the quality printing.

  1. Download jsMath.phpΔ and put it in the cookbook/ directory
  2. Download and install the latest jsMath archive from Sourceforge into your PmWiki's pub/ directory, as pub/jsMath/ . Or, you can install jsMath wherever you wish, and edit config.php to set $JSMathUrl to the url of the jsMath directory.
  3. Download and install the appropriate fonts from the author's website here
  4. Add the following line to a local customization file:
    include_once('cookbook/jsMath.php');

That's it! The script adds {$$ ... $$} and {$...$} markups that display LaTeX-style math equations, the first form centers the equation, while the second generates the equation "inline".

  • You will find your experience to be better if you actually download

and install the jsMath fonts, but the site can be viewed just the same without.

  • The math graphic for the GUI toolbar is available at .

Using jsMath without ~80 MB of fonts

You can force jsMath to work without with font files. This only works if users are willing to download the font files to their computers. I modified the jsmath.php file as follows (not sure if some of this is redundant):

 $HTMLHeaderFmt['jsMath'] = '
    <script> jsMath = {Controls: {cookie: {scale: 120}}} </script>
    <script src="$JSMathUrl/plugins/noImageFonts.js"></script>
    <script src="$JSMathUrl/plugins/autoload.js"></script>
 ';
 $HTMLFooterFmt['jsMath'] = '
    <script src="$JSMathUrl/plugins/noImageFonts.js"></script>
    <script>
        jsMath.Autoload.Check();
        jsMath.Process(document);
    </script>
 ';

Release Notes

  • 20180417 Updated for PHP 7.2 (by Petko).
  • 20160803 Updated for PHP 5.5 (by Petko).

Comments

See Discussion at JsMath-Talk

Disable message "No jsMath TeX fonts found"

I'm not sure what the newest developments of this recipe are, but I didn't care about font quality as long as one could read the formula on the screen. So I simply disabled the red message box above by adding the following line to config.php before (!) the include_once statement of this recipe (my reference):

$HTMLStylesFmt[] = "#jsMath_Warning {display: none}";

Frank, 14-Dec-2008

See Also

Cookbook /
AMmathjax  Add markup to embed math using ASCII MATH by MathJax. (Stable)
ASCIIMath  Display MathML rendered ascii formula into PmWiki 2.x pages (Stable)
Formula  Lightweight rendering of mathematical formulas in wiki pages (Beta)
FractionsPlus  Adds simple markup to write fractions. (Maintained)
LaTeXMathJax  MathJax support for PmWiki (stable)
LaTeXMathML  Translating LaTeX math notation dynamically to Presentation MathML (Stable)
LinuxTex  Enable TeX markup
LuaExecute  Lets Lua scripts dynamically generate parts of your wiki page (Beta)
MathJax  Add markup to embed math using TeX syntax. (Stable)
Mathtex  Add markup to display and embed several lines of mathematical formulas in wiki pages (testing)
MimeTeX  Add markup to display and embed mathematical formulas in wiki pages (Stable)
SageCell  This allows you to embed an interactive SageCell into your webpage. Sage is an open source alternative to MathLab, Mathematica, and Maple. (Stable)
SimpleJsMath  Notes on modifying the jsMath for a skin (not a complete recipe)
TrueLatex  Enables interpretation and rendering of real LaTeX markups in PmWiki. Support for XeLaTex included in v1.8. (Working perfectly. Very simple to use, customizable and comes with lots of options.)

Contributors

Ben Woodruff

User notes +3: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.