Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

JsMath-Talk

The tex isn't processing ...

The classic problem: Even with the default skin jsMath didn't work --
it would just load as the tex. Using the test page in the jsMath
installation, I was able to verify that jsMath itself worked, when
called from a correct html page. What's happening?

The short answer is that you will need to change the template file
for your skin. It is located in /pub/skins/skinname/skinname.tmpl.
You can use one of the following solutions. Don't try to use both,
it will confuse jsMath.

Solution 1: easyload with header

This recipe adds a header to your skin template that tells pmwiki
to follow the instructions in pmwiki/pub/jsMath/easy/load.js.

  1. Go to the directory of your skin and open the skin template. For example,
    I use notsosimple, so I opened pmwiki/pub/skins/notsosimple/notsosimple.tmpl
  2. Add the following script to the header:
	<SCRIPT SRC="pub/jsMath/easy/load.js">
	</SCRIPT>

So your skin.tmpl file should look like

    OTHER STUFF
   <head>
      OTHER STUFF
        <SCRIPT SRC="pub/jsMath/easy/load.js">
	</SCRIPT>
   </head>

If this doesn't work (it should), open the load.js file and make sure that
root: is set to the root jsMath directory. (J Millar, 2/8/8)

Solution 2: Autoload with footer

The page code generated by my wiki was indeed lacking the footer code
<!--HTMLFooter-->
  <script>
    jsMath.Autoload.Check();
    jsMath.Process(document);
  </script>

I just added all five lines right above the </body> tag in the skin template
(I'm using notsosimple), and things work fine (Note: ust adding <!--HTMLFooter--> ,
a previous suggestion on this page, does nothing.) It seems that I set everything up
correctly, and it is disturbing that not even with the default skin things worked. In my
experience every little add-on (pmwiki and others as well) requires hours of fooling
around to make it work. Kind of sad. On the other hand, it's great that people make
the effort to write software like this, thanks!
[GG, 15-July-2007] http://www.physics.umanitoba.ca/~gwinner/pmwiki/pmwiki.php?n=Main.HomePage(approve links)

Why doesn't jsmath work with the default skin!??


The original version of the code did not require the skin to load the HTMLFooter.
This is a copy of the code that I used originally.

$HTMLHeaderFmt['jsMathstuff'] =
  '
<SCRIPT>
    jsMath = {
      Controls: {cookie: {scale: 133}},
      Autoload: {
        loadFonts: ["msam10","msbm10"],
        loadFiles: "extensions/AMSsymbols.js"
      },
	Font: {Message: function () {}}
    }
</SCRIPT>
<SCRIPT SRC="JSMathUrl/plugins/autoload.js"></SCRIPT>
    <SCRIPT>
      window.onload = function () {
        jsMath.Autoload.Check();
        jsMath.Process(document);
      }
    </SCRIPT>
';

Pm suggested to change the code as shown below.

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

The original code above is sloppy, and Pm's was in improvement.
However it did require that the skin load the HTMLFooter.
Sorry for this disadvantage.

Ben

Config file -- remember to use jsMath instead of jsmath

I was having trouble getting the tex to process until I changed

include_once('cookbook/jsmath.php');

to

include_once('cookbook/jsMath.php');

Now it seems to be working. This was on a FreeBSD 6.2 server.

Maintaining math mode across lines

There is an error in the jsmath cookbook that means displayed math
doesn't process across lines. To fix this, open up jsmath.php from
pmwiki/cookbook/jsmath.php. Replace the lines

 // This line gives you LaTeX $$ $$ display equations in the center
 Markup('{$$', '<{$',
  '/\\{\\$\\$(.*?)\\$\$\\}/e',
  "Keep('<div class=\"math\">'.PSS('$1').'</div>')");

 //  This line gives you $ $ equations in line.  You can then use 
 //  \displaystyle as normal to get pretty print equations inline.
 Markup('{$', 'directives',
  '/\\{\\$(.*?)\\$\\}/e',
  "Keep('<span class=\"math\">'.PSS('$1').'</span>')");

with

 // This line gives you LaTeX $$ $$ display equations in the center
 Markup('{$$', '<{$',
  '/\\{\\$\\$((.|\\n)*?)\\$\$\\}/e',
  "Keep('<div class=\"math\">'.PSS('$1').'</div>')");

 //  This line gives you $ $ equations in line.  You can then use 
 //  \displaystyle as normal to get pretty print equations inline.
 Markup('{$', 'directives',
  '/\\{\\$((.|\\n)*?)\\$\\}/e',
  "Keep('<span class=\"math\">'.PSS('$1').'</span>')");

or equally well, replace with

   Markup('{$$', 'fulltext',
     '/\\{\\$\\$(.*?)\\$\$\\}/es',
     "Keep('<div class=\"math\">'.PSS('$1').'</div>')");

   Markup('{$', '>{$$',
     '/\\{\\$(.*?)\\$\\}/es',
     "Keep('<span class=\"math\">'.PSS('$1').'</span>')");

This will cause the ... markups to be processed before the text is broken into separate lines.

Print quality

Make sure users install the TeX fonts
The print quality is nicer if users install the TeX fonts on their
computer. Details are available at http://www.math.union.edu/locate/jsMath.
However, I did notice that onscreen readability is not quite as good
if you use the TeX fonts and your website has small text. I wanted to
use jsMath because I use PMWiki for classroom use, and I wanted a
tool that could give students immediate access to notes, while at the
same time being useable on a projector for presentations. MimeTeX
did not work for classroom use because the graphics did not rescale.
Perhaps it is possible to rescale the graphics in MimeTeX. I am also
much happier with the print quality of jsMath.

Unanswered questions and older stuff

Symbol for natural numbers

 I have installed everything and the Tex things looks really great, but how can I insert the symbol for the natural numbers like N=\{1,2,3,4,\ldots \}? So I want the symbol \N \N .

comment Do you mean you want blackboard math for N, i.e ℕ ?

TeX not processing

I downloaded the jsMath packages (jsMath-3.4.zip and jsMath-fonts-1.3.zip), and unzipped them into /PmWiki/pub/jsMath/. I also downloaded the file jsMath.php into /PmWiki/cookbook/jsMath.php, and added the line 'include_once('cookbook/jsmath.php');' to /PmWiki/local/config.php. In the editor, I get the \sqrt{n} icon. However, when I insert an equation, I just get the TeX syntax for it. I can see the equation 5 \sqrt{n} - \alpha properly on my browser. Any idea what is going wrong?

What skin are using? I had exactly the same problem using the beeblebrox skin. Using the default or for example monobook everything works fine...

I have run into the same problem with other skins - getting just lines of tex. Is the source of this particular problem known yet? Is there an alternative solution?

I have figured out the problem -- essentially, the jsMath package relies on the skin to include the HTMLFooter directive, but many skins don't do this (Beeblebrox among them). So the solution is to simply add the line <!--HTMLFooter--> to the skin's template file, somewhere near the end.

"That's it"!? Well, it does not work with the TriadSkin from Hans. That's a pity! Yes, I've checked the procedure twice and the <!--HTMLFooter--> line does exist as well in the template file. Still, it's only the source code shown on the page. Has someone another hint? /VolkerM


The original version of the code did not require the skin to load the HTMLFooter. This is a copy of the code that I used originally.

$HTMLHeaderFmt['jsMathstuff'] =
  '
<SCRIPT>
    jsMath = {
      Controls: {cookie: {scale: 133}},
      Autoload: {
        loadFonts: ["msam10","msbm10"],
        loadFiles: "extensions/AMSsymbols.js"
      },
	Font: {Message: function () {}}
    }
</SCRIPT>
<SCRIPT SRC="JSMathUrl/plugins/autoload.js"></SCRIPT>
    <SCRIPT>
      window.onload = function () {
        jsMath.Autoload.Check();
        jsMath.Process(document);
      }
    </SCRIPT>
';

Pm suggested to change the code as shown below.

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

The original code above is sloppy, and Pm's was in improvement. However it did require that the skin load the HTMLFooter. Sorry for this disadvantage.

Ben


Hello, could someone please explain to me how to get the boldsysmbol extension to work with this markup? I tried to follow the instructions, but I can't get it to work. Thanks a lot! June 6, 2007, MS

Sandbox

x^3

\int_i^k x^2

Equation:
\sum_{i=0}^k x^2
Another:

\sum_{i=0}^k x^2

\mathcal N

\mathrm{corr}(X,Y)= \frac{\displaystyle \sum_{i=1}^n(x_i-\overline x)(y_i-\overline y)} {\displaystyle\biggl[\sum_{i=1}^n(x_i-\overline x)^2 \sum_{i=1}^n(y_i-\overline y)^2\biggr]^{1/2}}
T_{sys} \propto \frac{T_{sys}}{\sqrt{\tau B}}
\mathrm{corr}(X,Y)= \frac{\displaystyle \sum_{i=1}^n(x_i-\overline x)(y_i-\overline y)} {\displaystyle\biggl[\sum_{i=1}^n(x_i-\overline x)^2 \sum_{i=1}^n(y_i-\overline y)^2\biggr]^{1/2}}
\mathrm{corr}(X) = \frac{1}{(2\pi)^{N/2}}
f_X(x_1...x_N) = \frac {1}{(2\pi)^{N/2} {\left| \Sigma \right|} ^{1/2}} \exp \left(-\frac{1}{2}(x -\mu)^t \Sigma^{-1} (x-\mu) \right)
f_X(x_1...x_N) = \frac {1}{(2\pi)^{N/2} {\left| \Sigma \right|} ^{1/2}} \exp \left(-\frac{1}{2}(x -\mu)^t \Sigma^{-1} (x-\mu) \right)

Experimenting with eqnarray:

\begin{eqnarray} f & = & g \\ & = & h + i \\ & & +j \end{eqnarray}

Inline equations, does it get the vertical spacing correct?

Here is x some x^2 text x^i_j and x^{h^3}_{e_f} some |x\rangle more.

\frac{x}{y}

Problems (9 Aug 07)

  1. Thanks; this is quite a cool cookbook, apart from the software engineering problem of requiring other cookbooks (i.e., apparently most other skins) to be changed to make this work. However...
  2. When I display this page, none of the above math is formatted; I see just the source. Since, this is on the pmwiki.org server, with the skin chosen by this page's author, what can I do differently to make it work?
  3. On my own server, I changed jsMath.php to the former version as shown above. My own test page still fails.

Tiny little detail

Thanks

Everything works fine now. See http://www.ecse.rpi.edu/Homepages/wrf/pmwiki/Main/jsMath(approve links)

Edit - History - Print - Recent Changes - Search
Page last modified on February 08, 2008, at 08:20 AM