# SimpleJsMath

## Questions answered by this recipe

Is there a simpler, more robust way to get jsMath features?

## Description

{Instead of using a plugin for jsMath which (1) doesn't always work and (2) requires using {} around math expressions, learn (1) to make a simple edit to your current skin template and (2) some little tricks to use jsMath. In retrospect, this recipe should really be called "Advanced jsMath"!}

## Notes

Thanks to Ben Woodruff for creating the jsMath plugin recipe. However, I had some problems using it. Inline math didn't always render properly. Also, I discovered some little problems arising from the fact that PmWiki does some necessary text processing prior to generating html that messes up jsMath which works on the html.

My solution is brutish, but does work! If someone can figure out a way to package it in an actual recipe PHP file, that would be great. The brutishness of my solution probably stems from not learning enough about the jsMath package first.

The steps are:

- Edit the jsMath/easy/load.js file for some necessary options (that's how you do it)
- Edit the template file of the skin you are using
- Remember to use escaped versions of & and \\] any time you need them, for instance equation arrays and arrays.

Step 1: Certain options for the load.js method are hard coded into that file. Make sure the appropriate lines near the top of the file look like:

------
`processSlashParens: 1, // process \(...\) in text?`

`processSlashBrackets: 1, // process \[...\] in text?`

`processDoubleDollars: 1, // process $$...$$ in text?`

`processSingleDollars: 1, // process $...$ in text?`

`processLaTeXenvironments: 1, // process \begin{xxx}...\end{xxx} outside math mode?`

`fixEscapedDollars: 1, // convert \$ to $ outside of math mode?`

`doubleDollarsAreInLine: 0, // make $$...$$ be in-line math?`

`allowDisableTag: 1, // allow ID="tex2math_off" to disable tex2math?`

------

Step 2: Edit the skin template file. The skin information goes in `./pub/skins/<skin folder>`

. Look in there for a file ending in `.tmpl`

, probably called `<skin name>.tmpl`

. Just before the `</head>`

closing tag, paste the line\\

`<script src="path-to-jsMath/easy/load.js"></script>`

\\

If you have put jsMath in ./pub, then the line should be\\

`<script src="./pub/easy/load.js"></script>`

\\

Step 3: When using latex array environments such as `\begin{eqnarray}...\end{eqnarray}`

, you separate array elements with an ampersand "&". For safety, pmWiki converts all ampersands to "&". This confuses jsMath. Also, pmWiki markup has a special purpose for "\\". So, if you are going to use array environments, best to enclose each line in "`[= ... =]`

". For example:

------
`[= $$ \begin{array} =]`

`[= 1 & 2 & \\ =]`

`[= 3 & 4 & \\ =]`

`[= \end{array} $$ =]`

------

Good luck, and let me know how it goes!

## A solution

{$$ [= \left( \begin{array} \\ 1 & 2 \\ 3 & 4 \\ \end{array} \right) =] $$} |

{$$ \left( \begin{array} \\ 1 & 2 \\ 3 & 4 \\ \end{array} \right) $$} |

## Release Notes

## 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)
- JsMath Add markup to display and embed mathematical formulas in wiki pages using TeX. (Obsolete - use MathJax)
- 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)
- 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.)