javascriptlatexmediawikimathjaxmediawiki-extensions

MathJax in MediaWiki: escaped syntax is shown, console has 404 errors


I've installed mediawiki-1.26.2 on a private server and want to display latex formulas in that. So I decide to use Extension:MathJax.

At first I installed a local copy of MathJax to render the equations (at top level of server:/var/www/html/mediawiki-1.26.2/). After completing the installation I tested it by visiting http://(Server)/MathJax/test, where the page tells me that "MathJax Appears to be Working!".

Then I downloaded the extension, extracted archive, renamed it to "MathJax" and moved it to “extensions” sub directory of mediawiki-1.26.2. After that I created symbolic link to "mwMathJaxConfig.js" in [local MathJax location]/config/local which is "/var/www/html/mediawiki-1.26.2/MathJax/config/local" directory. So already there exists two files:

  1. local.js
  2. mwMathJaxConfig.js (symbolic link)

Then I changed the last line of "mwMathJaxConfig.js" from:

MathJax.Ajax.loadComplete("_SUBSTITUTE YOUR URL___/mathjax/config/local/mwMathJaxConfig.js");

to this:

MathJax.Ajax.loadComplete("http://localhost/MathJax/config/local/mwMathJaxConfig.js");

Because extension page says: "You might need to modify mwMathJaxConfig.js file to make this work ... ".

After all of them, I tested did extension installed correctly? (wiki → special pages → version → Installed extensions part) And name of "MathJax" was there.

But when I try to show a latex in mediawiki, even simple terms like these:

We consider, for various values of $s$, the $n$-dimensional integral
:<math> \frac{f}{g} </math>

do not shown correctly. Results are:

We consider, for various values of $s$, the $n$-dimensional integral
 \[ \frac{f}{g} \]

You can see :<math> is replaced by \[ and </math> by \]. So I guess MathJax is loaded but does not load correctly and problem is in about last line of mwMathJaxConfig.js.

Also I saved page as html and looked at to its code and only this part of code was related to MathJax:

<script type="text/javascript" src="./PageName_files/MathJax.js"> </script>

Above code was not in head and PageName is the name of saved page. I think that is replaced instead of this code which is described in MathJax docs:

<script type="text/javascript" async src="path-to-MathJax/MathJax.js?config=TeX-MML-AM_CHTML"></script>

I looked at Third-party Extensions in MathJax docs but did not understand its meaning.

Also I checked local.js file in [local MathJax location]/config/local whose last line is:

MathJax.Ajax.loadComplete("[MathJax]/config/local/local.js");

Do I have to change the last line of that and replace another string instead of [MathJax]?


Solution

  • The solution which worked for Davide Cervone and hasanghaforian:

    Name of directory of local MathJax must be mathjax and not MathJax, then \frac{f}{g} is displayed correctly.

    Two errors are shown in the browser console:

    These two files are part of a third-party extension called XyJax for handling commutative diagrams called xypic. I suspect that the MediaWiki extension you installed is configured to load that, you would would need to obtain it separately from the link above. I don't know a lot about the extension, but I think that the references are to an old version, and that both xypic.js and fp.js have been combined in later versions. If you don't want to do commutative diagrams, you can remove them from the mwMathJaxConfig configuration file.