Writing mathematic equations..

Re: Writing mathematic equations..

by Marc Grober -
Number of replies: 17
http://moodle.org/mod/forum/discuss.php?d=142785&parent=650402
Yes, you can download and replace meta.php, but review the settings in the file as you will likely need to change the tokens to be used and if you are not using asciimathml, drop the invocation of asciimathml.
In reply to Marc Grober

Re: Writing mathematic equations..

by Frank Park -
I do not know where I can download the meta.php file. Do you think you can provide a link so that I can download it? Upon downloading the meta.php file, where would I put this file into?

So I just have to acquire that meta.php file, place it in the correct folder, change the tokens and it should work? Id love to give this a try. Please let me know where I can get the meta.php file. Thanks!
In reply to Frank Park

Re: Writing mathematic equations..

by Marc Grober -
Frank,
I posted the URL in this thread in response to your first request for it.
In reply to Marc Grober

Re: Writing mathematic equations..

by Frank Park -
Was the link http://fpg87.netsons.org/eq_editor/editor_eq.php

That link does not work for me. 404 error
is that the wrong one?
In reply to Frank Park

Re: Writing mathematic equations..

by Marc Grober -
Yes, Frank, its the wrong one. Frankly I don't know how you could have missed ther right one. Check here: http://moodle.org/mod/forum/discuss.php?d=149359&parent=658746
In reply to Marc Grober

Re: Writing mathematic equations..

by Frank Park -
Oh ok.. I see it. Did not realize the file was on the top right.

But I am still wondering where this file would go. Would it go in the theme i am using? or the public_html folder? should I rename it meta.php? Or transfer it as is?

Sorry for all the questions. This is the first time I am doing this and I need all the help I can get .. Your help is appreciated.
In reply to Frank Park

Re: Writing mathematic equations..

by Marc Grober -
If you look at the doc on asciimathml, that will explain what you will be doing, as the file you found is simply a standard theme meta.php file amended by addition of references to asciimathml and mathjax.

So download the file and edit it so that it references the correct locations of any files. You can comment out the asciimathml references if you are not using it. Backup your existing meta.php, upload the version with mathjax references and cp to meta.php. You should be in business. Test with tokens identified in meta.php. Assuming it's working, you can tweak the mathjax settings and asciimathml settings so that they work together. The file I posted, I believe, had asciimathml doing Tex, but you can turn that behavior off in asciimathml (or comment out asciimathml altogether) and change/add tokens for online or display use by mathjax.

At some point it would be helpful if moodle.org provided a theme(s) that users could employ to address such features, and there is a tracker item for this for asciimathml which you could vote for.
In reply to Marc Grober

Re: Writing mathematic equations..

by Frank Park -
I am sorry. I am a bit confused. is the metaforasciimathandmathjax php file the meta.php file? Do the contents of that file go into my meta.php file in my theme folder?

For what I did, I placed the metaforasciimathandmathjax php file into my lib folder. I also placed the contents of metaforasciimathandmathjax into my meta.php file in the theme. I am not sure if I am getting close, or if I just totally missed the mark.

Even if I placed the right php files into the right places, I am still unsure what to do inside the php files.

Anyways, thank you for working with me. You have been a lot of help so far.
In reply to Frank Park

Re: Writing mathematic equations..

by Marc Grober -
Yes Frank, it is a replacement for the meta.php file. See my explanation above.
In reply to Marc Grober

Re: Writing mathematic equations..

by Frank Park -
Hi Marc. I am making some progress and I thank you for your help and assistance thus far.

As far as using the language "replace" I mean I changed something in that line.

As far as the line
<script src="http://fqdn/MathJax/MathJax.js" type="text/javascript" >
I changed fqdn with mysite.com Nothing else was changed. so it would read http://mysite.com/MathJax/MathJax.js I even typed that in a web browser and it came out as all text codes.

I deleted the line that invokes asciimath

Based on the meta.php file, I wanted to know if I can have double$ be the delimiter of my math equations. I am confused on what you mean when you advise me to use the tokens that are provided \(texexpression\) or \texexpression\] . Would using double$ as the token cause problems? In other words, what do I need to change in order to have double$ as the tokens?

I think this line
tex2jax: {displayMath: <a href="https://docs.moodle.org/en/%27LB%2BLB%27%2C%27LB%2BLB%27%5D%2C%5B%27%5C%5C%5B%27%2C%27%5C%5C%5D%27" title="Moodle Docs - 'LB+LB','LB+LB'],['\\[','\\]'">'LB+LB','LB+LB'],['\\[','\\]'</a>, inlineMath: <a href="https://docs.moodle.org/en/%27double%40%27%2C%27double%40%27%5D%2C%5B%27%5C%5C%28%27%2C%27%5C%5C%29%27%5D%2C%5BMJX%2CMJX" title="Moodle Docs - 'double@','double@'],['\\(','\\)'],[MJX,MJX">'double@','double@'],['\\(','\\)'],[MJX,MJX</a> },

needs to be changed. I replaced the double@','double@ for double$','double$ That did not do the trick.

Sorry for naming @@ or $$ with double@ and double$. If I use the real ones, it seems to produce a syntax error.

Id appreciate the assistance. Thank you in advance.


In reply to Frank Park

Re: Writing mathematic equations..

by Marc Grober -
Frank,

Debugging is a slow process that relies on one's ability to isolate and remove causes of error one bit at a time.....

Yes, you will be able to use double dollar signs, but the first think to do is to make sure that the hub file works as it was delivered with only two changes, addition of the fqdn (which you indicate was done properly) and the deletion of the asciimath invocation (one line).

Now create a moodle web page and put a tex expression between the existng tokens, for example between the double@. YOur tex expression should be displayed properly., If so, we can then change tokens, but if that doesn;t work then we have to address other possible issues, and we dont want to confuse things by changing too much at once. I can tell you already that if the file you have in place contains the line you typed above, mathjax will not work.

You can find an explanation of the various brackets and commas in the documentation I added to the meta file. In short, displayMath is set so that you can use ££\frac{2}{3}££. You could also use double euros, but the var Euro has been commented out. Also you can use backslash opensquare bracket texexpression backslash closesquarebracket as in \[\frac{2}{3}\]

For inlineMath the file is currently set to double at signs, slash paren, as in \(\frac{a}{x}\), and MJX

Once you are clear on hos these tokens work, and confirm that they do, then we can carefully edit the file by for example replacing double euros with double dollars.

But note that there is a difference between inlineMath and displayMath, so you want to be careful as to which tokens you use for each (i.e. you don;t want to use the same tokemns for both.)

In reply to Marc Grober

Re: Writing mathematic equations..

by Frank Park -
I am a bit confused by what inlineMath is and what displayMath is. Whats the difference of those two and Mathjax and latex?
So far, double dollars, at, euro, £, slash parenthesis do not display any kind of latex expression or equation.

You note: "// Added displayMath setting to alter from doubledollars. Now set at Alt 128 though I had intended €" in your meta.php file. What does that mean? Do I need to add something myself to that line?

As far as my equations are, they are all in this format:
double$\frac{a}{b}double$
I do not use any @s or parentheses or brackets except when needed.


I have attached my (your) meta.php file. Is there a way you can look at it and see what is wrong with it?
Maybe I am not so close after all. Anyways, I appreciate the help.
In reply to Frank Park

Re: Writing mathematic equations..

by Mauno Korpelainen -

Maybe this image helps:

InlineMath vs displayMath

Attached a simple example of input/output code in meta.php for mathJax - it does not have to be so complex...and if you need asciimathml you can simply add a script tag like

<script src="<?php echo $CFG->httpswwwroot ?>/path_to_your_asciimathml_script/AsciiMathML.js" type="text/javascript"></script>

or if it's an external address replace <?php echo $CFG->httpswwwroot ?> with the actual address...

Note that in this meta.php MathJax.js is installed to my moodle test site sub folder lib/MathJax/ so tags src="<?php echo $CFG->httpswwwroot ?>/lib/MathJax/MathJax.js" find the script from correct place.

In reply to Mauno Korpelainen

Re: Writing mathematic equations..

by Frank Park -
Hi Mauno. Thank you for the meta.php file. Though I have tried to use that in my theme, I still do not display mathjax on my site.

<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>lib/MathJax/MathJax.js">
For this line, I changed lib/MathJax/Mathjax,js to wherever my MathJax.js is and it didn't work. I also placed my whole MathJax Folder into the lib folder, and that didn't work. Do I need to write "public_html/" before lib/? Also, Is there anything else I would need to change on that line? Perhaps place my url somewhere? Everything is pointed to the right direction, I don't see why this wouldn't work.
I have tried double @,$ pound, euro, MJX.

Any assistance would be great, thank you.
In reply to Frank Park

Re: Writing mathematic equations..

by Mauno Korpelainen -

One possible reason is that your custom theme config.php does not have a row

$THEME->metainclude = true;

and it does not read meta.php at all

You could use standard theme meta.php if you custom theme config.php has

$THEME->standardmetainclude = true;

but otherwise it is good to set in your custom theme

$THEME->standardmetainclude = false;

and

$THEME->metainclude = true;

if you use custom meta.php

Both

<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/MathJax/MathJax.js">

and

<script src="http://satmasters.net/MathJax/MathJax.js" type="text/javascript" >

should work if your MathJax folder is in http://satmasters.net/MathJax/

so either meta.php is not read or some other script is blocking MathJax.js ...

In reply to Mauno Korpelainen

Re: Writing mathematic equations..

by Mauno Korpelainen -

You can also test that mathJax itself is working fine in http://satmasters.net/MathJax/test/

And if you don't want to use meta.php for script tags (with $THEME->metainclude = true; in theme config.php) you can always add them for example to theme header.html

In reply to Mauno Korpelainen

Re: Writing mathematic equations..

by Frank Park -
Awesome! Mathjax seems to be working on my moodle site now!! I changed the config.php files to

$THEME->standardmetainclude = false;

and

$THEME->metainclude = true;


that did the trick, and the meta.php file is now read by the theme. Thank you so much for your help. I really appreciate it.

Thanks to Marc as well for being so helpful throughout this whole process. Both of you have been very helpful and I cannot thank you all enough for your time and assistance.

In reply to Frank Park

Re: Writing mathematic equations..

by Marc Grober -
Frank,

Perhaps you might do as I suggested? I have provide below text which should be able to copy and paste into a new Moodle web page to test MathJax.

Once you confirm that MathJax is working by following my directions, you will be able to not only SEE the difference between inline and display math, but you will be able to tweak the Hub file to your hearts content.

However, it is very easy to corrupt the expressions used because of the nested brackets, and you need to start with a known working solution. If MathJax works with the double at signs in the web page you create, then we can proceed to tweak the file to change the tokens.

There are also some other things we need to do to clean up your file, but we will do those ONLY when everything is working.

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

This is an exemplar for Frank's MathJax Test web page. Here is an example of inlineMath MJX\frac{x}{y}MJX so that you can see how inlineMath can be used. And here is an example of what we mean by display math using MathJax displayMath settings which currently use double pound sign as in ££\frac{x}{y}££. These alternative tokens demonstrate MathJax's flexibility.