Trouble getting Mathjax to render on Mediawiki

372 views
Skip to first unread message

I C Loser

unread,
Sep 8, 2011, 1:47:20 AM9/8/11
to MathJax Users
I followed all the steps in the official page for the MathJax
extension.

1. Downloaded the latest zip distribution, uploaded and extracted it
to `/home/user/public_html/wiki/` (the directory where the wiki
installation lies)

2. Checked that it works by going to `/mathjax/test/sample.html` Here
I see nicely rendered math.

3. Placed `MathJax.php` and `mwMathJaxConfig.js` on the folder
`public_html/wiki/extensions/MathJax`

4. Appended to `LocalSettings.php` as instructed by adding the
following code:

require_once("/home/user/public_html/wiki/extensions/MathJax/
MathJax.php");
$wgMathJaxJS = array("/mathjax/MathJax.js" => "/home/user/public_html/
wiki/extensions/MathJax/mwMathJaxConfig.js");

I have tediously checked that the directory paths are all right and
removed any errors. I do not get any errors anymore, but the MathJax
just won't render. I have mathjax running on Drupal succesfully, how
do I get mathjax to work on my wiki? Is there an alternative solution?

mauno

unread,
Sep 8, 2011, 3:45:33 AM9/8/11
to MathJax Users
The problem might be caused by cache - check
http://www.mediawiki.org/wiki/Manual:FAQ#How_do_I_purge_a_cached_page.3F

( add &action=purge or ?action=purge to the end of the page's dynamic
URL )

You don't actually need MathJax extension to render mathjax in
mediawiki. You can as well edit your mediawiki skin (depending on
version of mediawiki) - for example in the latest version I added to
skins/Vector.php and there to the end of public function
initPage( OutputPage $out )

$out->addHeadItem( 'mathjax','<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({config:["TeX-AMS-MML_HTMLorMML.js"],jax:["input/
TeX","input/MathML","output/HTML-CSS"],extensions:
["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],tex2jax:
{displayMath: [['."'$$','$$']], inlineMath: [['$','$'".']]},TeX:
{extensions:
["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]}});
</script>'
);

and Mathjax is rendered just fine without extension.

I C Loser

unread,
Sep 8, 2011, 4:05:00 AM9/8/11
to MathJax Users
I did this. However Mathjax still isn't rendering. Here is how the
public function looks like in Vector.php

public function initPage( OutputPage $out ) {
global $wgLocalStylePath, $wgRequest;

parent::initPage( $out );

// Append CSS which includes IE only behavior fixes for hover
support -
// this is better than including this in a CSS fille since it
doesn't
// wait for the CSS file to load before fetching the HTC file.
$min = $wgRequest->getFuzzyBool( 'debug' ) ? '' : '.min';
$out->addHeadItem( 'csshover',
'<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
htmlspecialchars( $wgLocalStylePath ) .
"/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
);
$out->addHeadItem( 'mathjax','<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({config:["TeX-AMS-MML_HTMLorMML.js"],jax:["input/
TeX","input/MathML","output/HTML-CSS"],extensions:
["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],tex2jax:
{displayMath: [['."'$$','$$']], inlineMath: [['$','$'".']]},TeX:
{extensions:
["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]}});
</script>'
);

}


What am I doing wrong?

On Sep 8, 3:45 am, mauno <mauno.korpelai...@hyvinkaa.fi> wrote:
> The problem might be caused by cache - checkhttp://www.mediawiki.org/wiki/Manual:FAQ#How_do_I_purge_a_cached_page.3F

mauno

unread,
Sep 8, 2011, 4:31:09 AM9/8/11
to MathJax Users
That looks correct - did you try to purge cache by adding ?
action=purge or &action=purge to te end of your test page url ?

Are you using double dollars $$ for displaymath and dollars $ for
inlinemaths in mediawiki or some other delimiters ?
> > > do I get mathjax to work on my wiki? Is there an alternative solution?- Piilota siteerattu teksti -
>
> - Näytä siteerattu teksti -

mauno

unread,
Sep 8, 2011, 4:38:57 AM9/8/11
to MathJax Users
The easiest way to check that code is there is to check source from
browser toolbar (or with mouse right click) - you should see the
script tags before <head> if your skin is the one where you added
script tags and if cache is purged.

I C Loser

unread,
Sep 8, 2011, 4:55:17 AM9/8/11
to MathJax Users
I did the purge the cache. No effect. The delimiters I use are $...$
for inline and $$...$$ for display mode, however, I have also tried \
(...\) and \[...\] delimiters.


Here is the sample ...

If $A_1,A_2,\cdots A_k$ are mutually non overlapping subsets whose
union is $S$, i.e they constitute a [http://en.wikipedia.org/wiki/
Partition_of_a_set partition of a set], then for any subset $X$ of S,
the cardinality is $$|X| = \sum_{i=1}^k |A_i\cap S| $$

In a similar spirit, it may be convenient to enlarge $X$ into a
superset $Y$ and have $|X| = |Y| - |Y-X|$

I had out up screenshots of all Mathjax running the same thing
onDrupal and Wordpress but not on mediawiki, on imageshack, but google
gives me an error.

In wordpress, there was an issue with the delimiters and the inline $..
$ wasn't working, but the \(...\) were, so I could live with that. But
I do not know what the problem with mediawiki is. On the above sample
text I have posted, I have shuffled the delimiters to all possible
combinations and neither work. I also used the purge action. No
changes.

I C Loser

unread,
Sep 8, 2011, 4:56:13 AM9/8/11
to MathJax Users

As it works on Drupal : http://img847.imageshack(dot)us/img847/9672/screenshot5df.png
As it works on Wordpress: http://img708.imageshack(dot)us/img708/2742/screenshot7cj.png
As it does not work on Mediawiki: http://img821.imageshack(dot)us/img821/200/screenshot8tx.png

I C Loser

unread,
Sep 8, 2011, 4:57:42 AM9/8/11
to MathJax Users
Please remove the (dot) and replace with . in above posted links.
Message has been deleted
Message has been deleted

der.step...@gmail.com

unread,
Sep 8, 2011, 5:07:27 AM9/8/11
to mathja...@googlegroups.com
In the page source the relevant code at the end of <head> 


<!--[if lt IE 7]><style type="text/css">body{behavior:url("/wiki/skins/vector/csshover.min.htc")}</style><![endif]--><script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({config:["TeX-AMS-MML_HTMLorMML.js"],jax:["input/
TeX","input/MathML","output/HTML-CSS"],extensions:
["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],tex2jax:
{displayMath: [['$$','$$']], inlineMath: [['$','$']]},TeX:
{extensions:
["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]}});
</script></head>

mauno

unread,
Sep 8, 2011, 5:16:35 AM9/8/11
to MathJax Users
Strange - could some whitespace break code (when you copied tags to
your skin), try to delete extra spaces, line breaks etc from your
script tags...

Or maybe some conflict with some other javascript / extension in your
mediawiki (did you remove mathjax extension before testing skin
script? )


On 8 syys, 12:00, I C Loser <der.steppenwo...@gmail.com> wrote:
> In the code, here is where the relevant script is..
> > > changes.- Piilota siteerattu teksti -

I C Loser

unread,
Sep 8, 2011, 5:01:28 PM9/8/11
to MathJax Users
This morning, logging in to my wiki I get the following message, is
this relevant:

MathJax no longer loads a default configuration file; you must specify
such files explicitly. This page seems to use the older default config/
MathJax.js file, and so needs to be updated. This is explained further
at
http://www.mathjax.org/help/configuration


I checked that my script had no whitespaces or linebreaks in utf
format. I removed the mathjax extension also.

mauno

unread,
Sep 9, 2011, 12:33:39 AM9/9/11
to MathJax Users
Basicly that notice is explained in http://www.mathjax.org/docs/1.1/upgrade.html#combined-configurations
- the strange thing is that we had similar script tags (that you
attached to your previous post) and my mediawiki does not complain
about default configuration, yours does.

Try to use different combined configuration with

http://www.mathjax.org/docs/1.1/upgrade.html#change-in-default-tex-delimiters

with <script type="text/x-mathjax-config">...</script> tags before
actual mathjax script tags


On 9 syys, 00:01, I C Loser <der.steppenwo...@gmail.com> wrote:
> This morning, logging in to my wiki I get the following message, is
> this relevant:
>
> MathJax no longer loads a default configuration file; you must specify
> such files explicitly. This page seems to use the older default config/
> MathJax.js file, and so needs to be updated. This is explained further
> athttp://www.mathjax.org/help/configuration
> > > - Näytä siteerattu teksti -- Piilota siteerattu teksti -

Richard Morris

unread,
Sep 9, 2011, 3:45:10 AM9/9/11
to MathJax Users
it might be caused by some of the idiosyncrasies of MediaWiki. Are you
sure that your using the Vector skin? What does Special:MyPage/skin.js
redirect to? If its not vector.js then its a different skin. There
might also be a problem with where the code gets called in the
rendering pipeline. The wikicode goes through one transition and then
it goes though HTMLTidy, you tags may have been removed at some stage.
Try using different actions eg action=raw, see http://www.mediawiki.org/wiki/Action#Actions.
On wikipedia the <math> tag is used to markup the maths text, these
may work better than $$. There is a implementation which work on
wikipedia see http://en.wikipedia.org/wiki/User:Nageh/mathJax to see
how it was done.

Davide P. Cervone

unread,
Sep 9, 2011, 4:50:17 PM9/9/11
to mathja...@googlegroups.com
I suspect that this means that Mauno is right, and there is a problem with the configuration code, so that the content of the script tag doesn't actually compile, and so it never runs, and so MathJax thinks that you haven't provided a configuration and gives the message you report.

I'm wondering particularly if there isn't a linebreak between "input/" and the following "TeX" (as there is in the message here). That would cause a javascript compilation error like what I suggest above. Did you look at the error console for your browser to see if there are any error messages?

Did you use "View source" in your browser to see if the configuration block is actually being sent as part of the page source? And if so, are there any unwanted linebreaks there?

Your configuration actually includes more than is needed, since the combined configuration file takes care of most of what you have. So you should be able to get away with

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
config:["TeX-AMS-MML_HTMLorMML.js"],


tex2jax: {displayMath: [['$$','$$']], inlineMath: [['$','$']]}

});
</script>

Also, the recommended approach is to use a separate configuration block (since your version is no longer valid in HTML5):

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
config:["TeX-AMS-MML_HTMLorMML.js"],


tex2jax: {displayMath: [['$$','$$']], inlineMath: [['$','$']]}

});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>

See if using one of these helps, and check the error console for messages.

Davide

mauno

unread,
Sep 10, 2011, 1:19:36 AM9/10/11
to MathJax Users
Or there might also be some problem with order of single and double
quotes - I tested different versions of configurations and in single
line

$out->addHeadItem( 'mathjax','<script type="text/x-mathjax-
config">MathJax.Hub.Config({tex2jax:{displayMath:[['."'$$','$
$']],inlineMath:[['$','$'".']]}});</script><script type="text/
javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?
config=TeX-AMS-MML_HTMLorMML"></script>'
);

in Vector.php works as well
> >>> - Näytä siteerattu teksti -- Piilota siteerattu teksti -

Davide P. Cervone

unread,
Sep 10, 2011, 6:34:33 AM9/10/11
to mathja...@googlegroups.com
Thanks for the updated code. Note that you could use double quotes
instead of single quotes for the displayMath and inlineMath delimiters:

$out->addHeadItem( 'mathjax','<script type="text/x-mathjax-

config">MathJax.Hub.Config({tex2jax:{displayMath:[["$$","$
$"]],inlineMath:[["$","$"]]}});</script><script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
"></script>');

should work fine.

I had considered suggesting using ?config= instead of the config
array, as you have here, but didn't want to complicate things further,
since you were already using a custom configuration anyway.

Davide

Reply all
Reply to author
Forward
0 new messages