# Extension talk:MathJax

Please note that most of the comments on this page are related to previous versions of the MathJax Extension. The old messages should probably be moved to an archive page. |

### Local Mathjax version not contained in downloadEdit

When I wanted to use the local MathJax version instead of CDN, I discvovered that the MathJax - path referenced in the ext.MjLocal.js does not exist. More concretely, the folder "MathJax" inside the folder "modules" is missing from the github repo, see: "github.com/xeyownt/mediawiki-mathjax/tree/master/modules"

I found the folder by looking at the github repo of SimpleMathJax: "github.com/jmnote/SimpleMathJax/tree/master/modules"

After downloading this MathJax folder and placing it into the module-folder, it works. Thus, @xeyownt : Could you place this MathJax folder into your repo so that people later will not have the issue?

I also added a remark in the installation instruction of the extension that can be removed after the folder is added to the repo. Thank you very much for all the work already put into this extension!

### Latex formulas end templates when they contain two consecutive closing curly bracketsEdit

```
{{SomeTemplate
|SomeVariable=
A formula like the following will cause mediawiki to end the template and the whole page won't show right (because it contains }}):
$D-\cup_{C\in\mathcal{C}}C$ by $T$.
}}
```

89.177.138.242 10:24, 29 July 2016 (UTC)

The problem might be because of the fact that mediawiki treats text and nontext (like templates) differently. I also noticed this when I was updating the code, but I regarded this as an exceptional case and didn't wanted to make the code more complicated by counting many other possible situations. Taking count of many possible situations and being involved in mediawiki internals would make the extension harder to maintain and update, if needed.

I'd be much appreciated if somebody else could do that for all of us, too, but as a non-developer who just wanted simple and light way of rendering math(jax), keeping the code as simple as possible in expense of giving up many useful features made more sense. -- hbshim (Aug 9, 2016)

### [FIXED] MathJax only renders when ?action=purge is inserted at the end of the page's URLEdit

Running Mediawiki v1.19.1 with MathJax 2.0

**UPDATE2: Error also occures on Mediawiki v1.19.2 with MathJax Extension 0.7. Adding "$wgParserCacheType = CACHE_NONE; to LocalSettings.php fixed the issue.**

MathJax appears to be installed correctly, and will render if I place "?action=purge" at the end of the URL. However, if I reload the page without the purge, it stops rendering, and looks like this:

\( \sqrt{5} \)

Suggestions?

**UPDATE: Adding "$wgParserCacheType = CACHE_NONE;" fixed this issue. The extension page suggests this, although it is pretty vague on what issues you might encounter that can be solved using this command.**

### [FIXED] The require_once call crashes the entire wiki (but not other wikis in the wiki family)Edit

Running MediaWiki v1.17 with MathJax 2.0 installed.

MathJax tests properly from the command line. But as soon as I add the "require_once("$IP/extensions/MathJax/MathJax.php");" line (without quotes, of course) to the localsettings file, I end up getting a Server 500 error on all pages of the wiki. (This is in Chrome. Other browsers just show a blank page.)

Server is running Apache. Any suggestions?

Probably similar to this error, but I am using the most up to date extension available...

**Update: Upgraded to MW v1.19.1 and no more problems. Compatibility issue?**

### [UNRELATED] MathJax and Extension:CollectionEdit

How to use the MathJax Extension together with the Collection printing extension? TomBombadil 08:59, 8 August 2011 (UTC)

- I have no idea what you mean? MathJax is not meant for printing but for web content mathematics...

### [FIXED] Error in Internet explorerEdit

Hi. Please excuse me if this is not a right place to ask about my issue.

I can't see formulas with microsoft internet explorer. That's important since some of my friends use it, and I want them to be able to read my pages. At the same time mathjax test page displays perfect. Tested with IE 6 and 8.

You can find sample wiki on my machine at http://138.26.76.81/gt MathJax is installed at http://138.26.76.81/mathjax MathJax test page: http://138.26.76.81/mathjax/test

Any help would be very appreciated.

--Alexey ( kaikaikai@yandex.ru )

**UPD: I changed script mwMathJaxConfig.js - it contained lists like {a, b, c,} and IE didn't work because of last comma. So changing those scripts to like {a, b, c} resolved the problem.**

- Thanks for noticing. I new about this comma problem but didn't realize I had comma's in there. I've put a modified configuration file online. Thanks again! --Dirk Nuyens 15:58, 15 February 2011 (UTC)

### [FIXED] Error in the MathJax.php scriptEdit

In later versions of MediaWiki $parser::MARKER_SUFFIX; should be $parser->mMarkerSuffix;

The MathJax.php file should be modified to work with marker suffixes for all versions. I would do it if I knew any php. Which I don't :-) --Preceding unsigned comment added by 83.109.137.194 on 23:52, 30 November 2010.

- This has been fixed in the new version (0.5.1). --Dirk Nuyens 12:43, 1 December 2010 (UTC)

### [FIXED] Multiple \tag ?Edit

It there a reason that

\begin{equation}\label{foo} x = y \tag{$\star$} \end{equation}

gives an error? --Preceding unsigned comment added by 184.77.153.207 on 2 February 2011.

This has been fixed in the new version (0.5.2). The eqrefs are now also hyper linked to the formula. --Dirk Nuyens 15:15, 3 February 2011 (UTC)

### [UNRELATED] Math not renderingEdit

I have MathJax installed at webroot/mathjax/, and MediaWiki installed at webroot/w/. The problem is that I have $wgArticlePath = "/wiki/$1". When I remove this everything works fine. Not sure how to change the line:

$wgMathJaxJS = array("/mathjax/MathJax.js" => "$IP/extensions/MathJax/mwMathJaxConfig.js");

Any ideas? --Joejoebob 16:29, 6 February 2011 (UTC)

- This is a problem with your local config, not with this extension. I have multiple wikis running, some of them using $wgArticlePath, some of them without; all of them play nicely with the MathJax extension. Try getting your config correct before playing with any extensions, then you at least know your MW setup is correct. --Dirk Nuyens 16:40, 7 February 2011 (UTC)

Found a simmilar error, until i found out paths in MathJaxJS are case-sensitive.

### [COULD NOT REPRODUCE] Math does not render after <pre></pre> tags on pageEdit

Just like it says in the title. All the math before the <pre></pre> tags renders just fine, but it refuses to render after them on the page.

- Can't reproduce this. Can you give an explicit example? It could be the formatting is messed up due to some other reason and therefore MathJax isn't able to detect the maths. (I did notice that eqref does not work inside the pre tags though.) --Dirk Nuyens 16:40, 7 February 2011 (UTC)

### [EXTERNAL CAUSE] Equation numbers not visible when rendering equations in mathml modeEdit

The equation numbers render fine in html-css mode but are not visible when rendering in mathml mode (selected from the menu after right clicking on an equation). (this may just be a mathjax issue)

- It is indeed a MathJax issue. You could try it out with the MathJax sample files, e.g., mathjax/test/sample-dynamic.html: enter a formula using \tag{1} and then observe the rendering with mathml and html-css. There is no support for \tag's with mathml ;( Anyway, mathml doesn't look nice enough for my taste... --Dirk Nuyens 16:40, 7 February 2011 (UTC)

### [HINT] Settings Can Lead to Speed IncreaseEdit

FYI, I noticed a large increase in the speed of rendering when I changed

$wgMathJaxJS = array("http://mysite.com/MathJax/MathJax.js" => "/home/user/web/mysite/extensions/MathJax/mwMathJaxConfig.js")

to

$wgMathJaxJS = array("/MathJax/MathJax.js" => "$IP/extensions/MathJax/mwMathJaxConfig.js");

which is closer to the instructions you have posted. This may be worth pointing out to other users.

- Thanks for the remark, I added it to the main page. Feel free to add clarifications there yourself if you want to. --Dirk Nuyens 16:40, 7 February 2011 (UTC)

## [UNRELATED] Math in transclusion variablesEdit

I have a template {{equation}} which takes in variables l,r. When I place math with }}'s, the transclusion is prematurely ended, resulting in a nice mess.

{{equation | l=\frac{4\frac{4}{4}}{4} | r=1}}

This error can be avoided by adding a space between the two }'s, but is quite inconvenient. Is there a way around this? --Joejoebob 02:28, 8 February 2011 (UTC)

- This is a parsing problem with WM. Same thing happens if you want to use a pipe symbol inside your formula, e.g., |x| as absolute value of x. That won't work either since WM considers this the separation mark for template arguments. In that case you could use \mid or so instead of |. --Dirk Nuyens 13:23, 8 February 2011 (UTC)

- Using <nowiki>|</nowiki> is an alternative that doesn't add the extra spacing (Michael Doob, 1 October 2012).

## [FIXED] Doesn't work in a subpage?Edit

Hello. The extension doesn't work in a subpage?

You can see a test of this in: [1]

In this page there are a link to a subpage... The page and its subpage have the same latex code - $\Gamma$

Thanks.

- Fernando Carpani 20:27, 1 March 2011 (UTC)
- SOLVED !
- The problem was that I put a
path in the**really relative***$wgMathJaxJS*! :-)- array( "../../../mycommonsdir ..." => ...)

- That's not a good idea. :-)
- Fernando Carpani 19:57, 4 March 2011 (UTC)

- The problem was that I put a

## [FIXED] NoWiki BrokenEdit

I've found a bug with the MathJax extension. It breaks the standard wiki syntax. Specifically, <nowiki><code></nowiki> ends up being rendered as <span class="tex2jax_ignore"><nowiki><code></nowiki></span> in the final output. It is normally rendered and should be rendered as <tt>

- This is really needed for fix especially when we want to use syntaxhighlight extension for some codes. If there's any part of code matching preprocessing delimiters, there's no way to avoid this problem. I guess we need some option for part of page (or global option to turn on/off delimiters like jsMath extension does) being skipped from preprocessing. As an example, following command will not display correctly:

`echo $file | sed 's/\(.*\.\)jpg/\1png/'`

- Any suggestions on how to fix? I posted this as a bug to the MathJax github and they had some suggestions on how to fix the mediawiki extension. Unfortunately, I don't know php well enough to suggest a fix. Could any kindly people who are having the same problem share their fix?
- https://github.com/mathjax/MathJax/issues/166

- UPDATE: I resolved this same problem by making sure to use the mathjax javascript locally as opposed to calling it from the webpage. Somehow this fixed everything.

- The handling of <nowiki> has been changed, everything should now work as expected (similarly for <code>. The example from above should be wrapped in <nomathjax> (or <code> as that looks more semantically correct). 94.225.163.72 23:45, 22 April 2012 (UTC)

## [ADDED AS DEFAULT] Using MathJax CDNEdit

Didn't know if this was the best way to go about doing this, but I added the following to my copy of the extension (in extensions/MathJax.php) to get it to work with the new CDN. I made it so that if wgMathJaxJS is left empty, it would automatically link to it. The config file loads a bit differently in the new version of MathJax. Not sure if anything in 1.1 breaks what is currently being used in the config...

if(empty($wgMathJaxJS)) { // use cdn global $IP; $out->addScript("<script type='text/x-mathjax-config'>" . file_get_contents("$IP/extensions/MathJax/mwMathJaxConfig.js") . "</script>\n"); $out->addScript("<script type='$wgJsMimeType' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>"); } else { //... the old way of adding scripts with the foreach($wgMathJaxJS) }

More about CDN: http://www.mathjax.org/docs/1.1/start.html

--Evan

Another possibility is, to set the `$src`

-variable in the presented Installation to the cdn-URL of MathJax. Worked finde for me without installation of MathJax. Maybe one might add that to the installation instructions --Ronny

- That's weird... I also did that before, where in the wgMathJaxJS I mapped mathjax-cdn-url => "" (to be empty), and it didn't work for me. If I remember correctly the math tag worked but other delimiters did not, which seems a bit strange to me. Maybe the other delimiters worked but not the math tag. In any case, this way preserves the configuration in mwMathJaxConfig.js, if there is anything extra in there... --Evan

- I've changed the way this works and have the usage of the CDN now as the default. Dirk Nuyens (talk) 23:47, 22 April 2012 (UTC)

## [ADDED] Disable $ Delimiter for math modeEdit

Is there an easy way to disable the $ delimiter with the extension? We love this extension but have several pages on our wiki with markup like:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib echo $LD_LIBRARY_PATH

Which renders like:

When wrapped in source tags the problem disappears.

- I have added a <nomathjax> tag for this. You can also disable processing of
`$`

by disabling it in the new config by doing`MathJax_Parser::$do_dollar = false;`

or turn it off on a page by page basis by using`__MATHJAX_NODOLLAR__`

on that page. Dirk Nuyens (talk) 23:53, 22 April 2012 (UTC)

### [FIXED] UpdateEdit

By editing $IP/extensions/MathJax/mwMathJaxConfig.js I'm able to disable inline parsing on $. However I have a new problem: generated pre tags are different. Here is some example mediawiki markup

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib echo $LD_LIBRARY_PATH $herp $derp

With the MathJax extension disabled this is the resulting HTML:

```
<pre>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib
echo $LD_LIBRARY_PATH
$herp
$derp
</pre>
```

With the MathJax extension enabled I get (Note the space before echo and $herp):

```
<pre>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib
echo $LD_LIBRARY_PATH
$herp
$derp
</pre>
```

I assume the extra spaces are being added after $IP/extensions/MathJax/MathJax.php parses the mediawiki markup but I don't know how to fix it.

--Spt5007 16:39, 23 March 2011 (UTC)

- Maybe this is related to the problem seen here:
- Test on Wikipedia (ok)
- Same test on GeoGebraWiki (wrong!)
- Helder 17:19, 30 April 2011 (UTC)

- This has been fixed in the new version as well. Dirk Nuyens (talk) 23:53, 22 April 2012 (UTC)

### [FIXED] $100,000 causes rendering with MathJaxEdit

While testing, we found that any value that is is writing with a leading $ such as $100,000 are getting rendered with MathJax. The description said that only what is inside $...$ would get rendered (single leading $ should not be recognized by MathJax). Any help on how to resolve this would be much appreciated --MWJames 17:43, 23 June 2011 (UTC)

This is a **big** issue for me also, because I have to replace all single $ by USD , in all my wikipedia-like pages... this is tedious !
Phcalle 15:22, 1 October 2011 (UTC)

- You can now wrap this in <nomathjax> tags or disable the dollar sign in the new config by doing
`MathJax_Parser::$do_dollar = false;`

or turn it off on a page by page basis by using`__MATHJAX_NODOLLAR__`

on that page. Actually wrapping this in <nowiki> is also an option... Dirk Nuyens (talk) 23:53, 22 April 2012 (UTC)

## [FIXED] *$* sign prevents some wiki code from being parsedEdit

I have disabled single $ sign in the configuration - see an excerpt below:

inlineMath: [ ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: false,

However, when a page contains some **$** signs, the generated HTML code contains unparsed wiki code, as in the example below:

- Bug when the MathJax extension is loaded:

<p>Testing $ sign problem: and a $2.4M budget - which we abbreviate as our <a href="/wiki/50/2/2" title="50/2/2">50/2/2</a> program. </p><p>\( \sfrac{a}{b} \) - Is MathJax active? </p><p><br /> See <a href="/wiki/Crash_course_on_OSE" title="Crash course on OSE">Crash course on OSE</a> (replace <i>2.4M dollars budget</i> with <i>$2.4M budget'') ==Overview for New People== Test $2</i> </p>

- After disabling the MathJax extension (by removing the line
**require_once("$IP/extensions/MathJax/MathJax.php");**from LocalSettings.php), I get this:

<p>Testing $ sign problem: </p><p>and a $2.4M budget - which we abbreviate as our <a href="/wiki/50/2/2" title="50/2/2">50/2/2</a> program. </p><p>\( \sfrac{a}{b} \) - Is MathJax active? </p><p><br /> See <a href="/wiki/Crash_course_on_OSE" title="Crash course on OSE">Crash course on OSE</a> (replace <i>2.4M dollars budget</i> with <i>$2.4M budget</i>) </p> <h2><span class="editsection">[<a href="/w/index.php?title=User:Elifarley/mathjax&action=edit§ion=1" title="Edit section: Overview for New People">edit</a>]</span> <span class="mw-headline" id="Overview_for_New_People">Overview for New People</span></h2> <p>Test $2 </p>

And here's some version info:

- MathJax.js v1.1.7
- TeX Input Jax v1.1.1
- HTML-CSS Output Jax v1.1.5
- mml Element Jax v1.1.1
- tex2jax Extension v1.1.3
- MathMenu Extension v1.1.4
- Chrome v14.0.835.202 — otf fonts
- MediaWiki 1.16.0

--Elifarley 00:30, 17 October 2011 (UTC)

- This has been fixed and amended in the new version. You can turn of dollar parsing or protect your dollar sign. The parser will also not touch any white space anymore. Dirk Nuyens (talk) 23:57, 22 April 2012 (UTC)

## mwMathJaxConfig.js and MW 1.17 ResourceloaderEdit

Do you have any idea how to get MathJax/mwMathJaxConfig.js working with the 1.17 Resourceloader, it would be nice to know how this can be achieved since all Javascripts in 1.17+ can be loaded through MW's own Resourceloader. --MWJames 13:47, 22 June 2011 (UTC)

## [ADDED] Using magic words to enable/disable MathJax functionality per pageEdit

Is it possible to have some magic words such as __USEMATHJAX__ and __NOMATHJAX__ to enable or disable mathjax rendering on a page level.

We encountered that on pages with large amount of content and no mathematical formula present, the MathJax script still tries to render the page which costs some display performance. We would rather like to see a possibility that on pages that uses mathematical formulas MathJax can be activated individually by using the magic word (or used in templates etc.) or by default the extension always tries to render but as soon as __NOMATHJAX__ is present the extension would skip the step and does not interact with MathJax. --MWJames 11:32, 23 June 2011 (UTC)

- Any update on this? Dc321 05:46, 5 September 2011 (UTC)

- Configuration can now be done through such words like
`__MATHJAX__`

and`__NOMATHJAX__`

. Similar for other options of the MathJax parser. Dirk Nuyens (talk) 00:00, 23 April 2012 (UTC)

- Configuration can now be done through such words like

## [Fixed]Landing page corrupted if not logged inEdit

`Problem disappeared after adding ``"HTML-CSS": {minScaleAdjust: 110},`

to the configuration an clearing the caches (no idea why).

**looks like**

[[FibonUndefined control sequence \(-1--QINU? Biblio\)ek==Appel,Gerld - Power-Tools für die Tecnisce AnlyseBollinger,Jon - Bollinger Bänder

Bulkowski, TosN.−EnzyklopädiederCndles\(icks VTAD-Gü\)esiegel

....

Pesler,Oliver−TecnisceIndikoren[[Roller,Krin - Icioku-TrMisplaced &Misplaced &;VTAD-Gü\)esiegel

[[Scriek,Riund−BesseriBeviorl FinUndefined control sequence \(-2--QINU? Lexikon ==

**instead of**

Fibonacci Bibliothek

Appel, Gerald - Power-Tools für die Technische Analyse

Bollinger, John - Bollinger Bänder

Bulkowski, Thomas N. - Enzyklopädie der Candlesticks VTAD-Gütesiegel

.....

Nowacki, Jürgen; Altmann, ... - Trading Welten VTAD-Gütesiegel

Paesler, Oliver - Technische Indikatoren ......

**See at** http://vtadwikialt.vtad.de/index.php/VTADwiki:Portal

## Undefined property: Parser::$mUniqPrefix, MathJax.php on line 226Edit

While testing MathJax, a fatal error occurred:

Notice: Undefined property: Parser::$mUniqPrefix in ...extensions\MathJax\MathJax.php on line 226

Fatal error: Call to a member function getMaxIncludeSize() on a non-object in ...\includes\parser\Parser.php on line 2827 --MWJames 02:10, 2 July 2011 (UTC)

`\eqref{}`

's in image captions are not linked to the referenced equation - the global `$MathJax_eqnumbers`

isn't set. Possible workaround:

$wgHooks['ParserAfterTidy'][] = 'efParserAfterTidy'; function efParserAfterTidy( &$parser, &$text ) { global $MathJax_eqnumbers; $text = preg_replace_callback('(\\\\(eq)?ref\\{(.*?)\\})', 'MathJax_replace_eqrefs', $text); return true; }

--Jlerner 15 August 2011

## Does not render MathjaxEdit

I followed all the steps.

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. How do I get mathjax to work on my wiki?

- Do not unzip the distribution into the wiki folder, but instead into the your document root, for you: /home/user/public_html/mathjax. The test file should be at http://www.yourdomain/mathjax/test/sample.html Also, did you probably disable JavaScript in your browser?

# User Settings not possible / ignoredEdit

Hi,

first: thanks for this plugin (and for MathJax, if any of its developers reads this). The rendering is beautiful.

After installing the extension, there is no configuration property in the user setting page to enable or disable MathJax. The setting is left to "PNG". It works but is slightly unpretty (as, sometimes, users might want to change the rendering method). Is there a way to add the corresponding configuration property? Or did I miss something? --06:55, 21 October 2011 (UTC)

# [FIXED] Problems with labels in \begin style and display style environmentsEdit

This code causes mis-numbered equations (example)

$$ \label{mylabel} e^{i\pi} +1 = 0 $$ We consider, for various values of $s$, the $n$-dimensional integral \begin{align} \label{def:Wns} W_n (s) &:= \int_{[0, 1]^n} \left| \sum_{k = 1}^n \mathrm{e}^{2 \pi \mathrm{i} \, x_k} \right|^s \mathrm{d}\boldsymbol{x} \end{align}

128.54.254.180 18:44, 21 November 2011 (UTC)

- Anyone figure this out? 128.54.254.180 20:49, 16 January 2012 (UTC)

- Yes, thanks for that! I now parse the numbering twice and this numbers the formula's in order of appearance... Dirk Nuyens (talk) 00:02, 23 April 2012 (UTC)

# [ADDED] changes to get 1.18 to workEdit

I modified the MathJax.php to get it to work (hopefully I didn't break anything), just modified it so that everything is consistent with the newer StripState. Attached is the patch file.

Basically I just changed prefixes/suffixes and used addNoWiki()

http://math.nyu.edu/~chou/MathJaxExtension118Patch.diff

(Well, I would attach but I'm not in autoconfirmed users yet)

--EvanChou 22:45, 29 November 2011 (UTC)

- well, it works. thanks. --9peppe 02:56, 14 January 2012 (UTC)

- Thanks! The new version now works with 1.18. Dirk Nuyens (talk) 00:05, 23 April 2012 (UTC)

## [RESOLVED] Renders all equations in plain text inside of \( \) symbolsEdit

We are just trying to get the MathJax extension working on our wiki. We have followed the steps given on the extension page: we have the MathJax JS library installed on the server, the configuration files in the /extensions/MathJax/ folder and we have enabled the extension in LocalSettings.php. The MathJax test page works perfectly well, but the math on the wiki pages shows up as plaintext between \( \) symbols. For example, if we have inline:

<math>f(x)</math>

then it renders as \(f(x)\) inline. Any assistance is much appreciated.

-- Chad Lieberman, 6 December 2011

- exactly same problem for me -- David M. 21 March 2012
- Had the same problem after patching MW 1.18, but it is actually the $wgMathJaxJS path there is wrong. Try with the full url instead "$wgMathJaxJS = array("FULL_URL_TO_MATHJAX/mathjax/MathJax.js?config=default" => "$IP/extensions/MathJax/mwMathJaxConfig.js");" -- Søren M. 31 March 2012

- New version just uses the CDN in its default install so you don't have to do anything anymore. The configuration variable has been removed (in place of another one and method).

- I've got a similar problem but in different circumstances. First, I installed a wiki (MW 1.19) in a subdomain - the MathJax extension worked perfectly, then I decided to install two wikis in two subfoldes of the subdomain and the MathJax extension rendered a sort of \(f(x)\). So using Søren's recommendation above I entered the following line into LocalSettings.php: . After that everything worked fine. Let me draw your attention that I used not only FULL_URL_TO_MATHJAX = "http://cdn.mathjax.org" but also inserted "latest/" between "mathjax/" and "MathJax.js". So, my conclusion is that some corrections in the MathJax extension are needed. Any way tanks a lot to Søren -- Oleg Bondarenko, 7 May 2012
$wgMathJaxJS = array("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default" => "$IP/extensions/MathJax/mwMathJaxConfig.js");

- I've rejoiced too early. Immediately after I logged out the MathJax extension stopped rendering formulas -- Oleg Bondarenko, 7 May 2012

- The configuration you are using is incorrect for the current version of the MathJax Extension (which is the one I think you would be using as you have MW1.19). The configuration variable
`$wgMathJaxJS`

is not in use anymore and so should not have any effect. Please check if you are using the latest version of the extension. Dirk Nuyens (talk) 15:07, 10 May 2012 (UTC)

- The configuration you are using is incorrect for the current version of the MathJax Extension (which is the one I think you would be using as you have MW1.19). The configuration variable

# MathJax extension gives empty pagesEdit

Hello, I have installed MediaWiki via BitNami MAMPStack+MediaWiki, and MathJax extension per instructions. MathJax test page works fine, but if I have some math in a wikipage, I get served an empty page (that is completely empty, no wiki menus or anything). I rechecked the paths many times and these should be fine. Thanks for any help.

17 January 2012

- This probably means there is a problem with the php code. You are using an old version of the MathJax extension with a newer MediaWiki. You find the errors in a file called
`php.log`

and`error.log`

. Use the updated extension, then it should work.

- When I had this issue then I updated to MW v1.19.1 and it went away. I was using 1.17.

# [RESOLVED] php error in MathJax.phpEdit

I have installed MathJax following the instructions. When I try to add some math, I get the following error:

Fatal error: Call to a member function setPair() on a non-object in /Users/dddd/Sites/mediawiki/extensions/MathJax/MathJax.php on line 424

Thanks for any help.

--Ivan, 17 Jan 2012

**Sorry, it works fine after applying the above patch for 1.18.**

- New version includes that patch (and is now a complete rewrite).

## Recent changes breaksEdit

After I follow the steps described (install MathJax in public_html/mathjax) and add MathJax extention I can see the test page properly rendered. Though after the lines

require_once("$IP/extensions/MathJax/MathJax.php"); $wgMathJaxJS = array("$IP/mathjax/MathJax.js" => "$IP/extensions/MathJax/mwMathJaxConfig.js");

are added to the LocalSetting.php the RecentChanges will not display and when I try to add a page which contains any math tags it will not render them and return an error.

Are there any hints on what am I doing wrong? I beg pardon for a vague question.

- It might help to tell us what error you are seeing. Please try with the new version of the extension. This might have been a problem with the configuration specification of MathJax which has changed.

# MathJax not rendered in wiki on Internet Explorer (IE8 or IE9)Edit

The MathJax sample page renders correctly in all browsers which I have tested (IE8, IE9, Firefox, and Chrome).

However, when tested in a wiki page, the MathJax markup is NOT rendered in Internet Explorer (IE8 or IE9). But it is working correctly in Firefox and Chrome.

I am running MediaWiki version 1.17.1 and PHP 5.3.8 (apache2handler),

I did some more testing on the actual wiki server using IE8 and found something interesting.

- When I access the wiki via "localhost" ("http://localhost/wiki/Wiki_Sandbox#MathJax"), MathJax is rendered correctly.
- When I access the wiki via the server name ("http://wikiservername/wiki/Wiki_Sandbox#MathJax"), MathJax is NOT rendered.

Any ideas?

-Dan O, 24 January 2012

- My best guess would be something related to (relative) path names in the configuration file, but I'm not really sure. --EvanChou (talk) 01:21, 27 February 2012 (UTC)

- I guess you installed a local version of MathJax and your server config is blocking in the second case. The new version of the extension is using the CDN, this could help. Dirk Nuyens (talk) 00:10, 23 April 2012 (UTC)

# [FIXED/ADDED EXTENSION] Clash with automatic numbering from MathJax and from the extensionEdit

I want all equations, not just the ones with labels, to be numbered. This is possible with MathJax on it's own (using the `autoNumber: "AMS"`

or `autoNumber: "all"`

settings), but when using the MathJax extension for MediaWiki, the automatic numbering of the two methods clash: The extension reads in all `\label{}`

's and `\eqref{}`

's, and replaces them with `\tag{}`

's and references to those tag-numbers. The built-in automatic numbering of MathJax then ignores all the equations with a `\tag{}`

in them, and only numbers the equations that are left. Hence, you get sequences like *1, 2, 1 (labeled), 3, 4, 5, 2 (labeled)* when you really wanted *1, 2, 3 (labeled), 4, 5, 6, 7 (labeled)*.

Would it be possible to simply stop the extension from changing the `\label{}`

and `\eqref{}`

codes, such that the MathJax script could do it the right way?

- Pia Jensen (Bozack) (talk) 10:48, 15 March 2012 (UTC)

- After a bit of hacking around, I found a solution. In MathJax.php, comment out the following lines (they are in different places in the code):

`$text = preg_replace_callback('(\\\\(eq)?ref\\{(.*?)\\})', 'MathJax_replace_eqrefs', $text);`

`$eq = str_replace('\\label{'.$matches2[1].'}', '', $eq);`

`$eq = preg_replace_callback('(\\\\(label|tag)\{(.*?)\})', 'MathJax_register_eq', $eq);`

`if($MathJax_label) $stripped = '<span id="Eq-' . $MathJax_label . '"/>' . $stripped;`

- This should stop the script from replacing
`\eqref{}`

commands and`\label{}`

commands, and lets the native MathJax numbering work instead.

- - Pia Jensen (Bozack) (talk) 09:54, 16 March 2012 (UTC)

- I have added an option to not do the numbering. In the near future it might become the default to let MathJax handle the numbering, but for some reason it is not working properly when I try it. The option is
`MathJax_Parser::$do_number = false;`

. Dirk Nuyens (talk) 00:14, 23 April 2012 (UTC)

- I have added an option to not do the numbering. In the near future it might become the default to let MathJax handle the numbering, but for some reason it is not working properly when I try it. The option is

## I get an errorEdit

This is a mediawiki extensions and can't be run from the command line. Warning: Cannot modify header information - headers already sent by (output started at http://wiki.iq-infinity.com/wiki/lat/extensions/MathJax/MathJax.php:1) in /home/djordje/public_html/wiki/wiki/lat/includes/WebResponse.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at http://wiki.iq-infinity.com/wiki/lat/extensions/MathJax/MathJax.php:1)

I did nothing wrong

- I guess you copy/pasted the code from the wiki page and have an empty line in the beginning of the script. (There is a new version available, download only to prevent this mistake.) Dirk Nuyens (talk) 00:14, 23 April 2012 (UTC)

# - Maths in heading not rendered in TOC linkEdit

the title says it all OrenB | ^{talkcontib} 10:05, 5 May 2012 (UTC)

some other issues

- Could you specify which version of MediaWiki you are using? This works correctly on 1.18.2 and Extension:MathJax v0.7 when I test this. Please also tell us what rendering problem you have with the two other examples. They look correct when I test them. Dirk Nuyens (talk) 08:50, 6 May 2012 (UTC)

# [WORKAROUND] MathJax works in preview, but not in page displayEdit

I just installed MediaWiki v1.19.0 using BitNAMI under Mac OS X, which seems to be working fine. Then I installed MathJax extension v0.7 and left the code to default to the CDN. The combination works fine if I Show Preview during editing of the page, but the formula do not display correctly when I save and simply view the page. I have also tried local version of the MathJax, but with no success. Any suggestions?

I can verify this occurs under Windows 7 and Ubuntu 12.04 servers with clients using Chrome, Firefox, and IE8. All math environments produce the same results (displays correctly in Preview, but just shows plain text markup when saved and viewed).

The math displays correctly in Read mode as well, but only the first viewing of the page after LocalSettings.php has been modified. Another user has the same problem: http://www.mwusers.com/forums/showthread.php?18572-MathJax-problem-in-MediaWiki

- I have the same issue. Somehow it works in preview mode and only randomly in page display. I am new to mediawiki - is there a way I could debug the thing and provide you with more useful information?

- I am experiencing similar rendering problems. I'm using MW 1.19, and the trunk version of MathJax. The problems are as follows:

- After editing a page, the formulas don't render. I have to reload the page to have correctly rendered formulas. Update: but this does not always seem to work. What seems to work *always* is the following: save the LocalSettings.php file and reload.
- The tex sample from http://www.mathjax.org/demos/tex-samples/ "A Rogers-Ramanujan Identity" renders the "\text{for $|q| < 1$}." as "for ?UNIQ2884316a49654936-MathJax-1-QINU?." Changing the tex code to "\text{for}~|q| < 1." renders okay.

Request: please add MathJax.php and an up-to-date config file (mwMathJaxConfig.js) to the git repository. -- Ch Lin, 08:31, 17 May 2012 (UTC)

- I just found a workaround for the time being; disable some form of MediaWiki caching by adding the following line to your LocalSettings.php:

```
$wgParserCacheType = CACHE_NONE;
```

Happy writing!
-- Ch Lin, 09:51, 17 May 2012 (UTC)

- Thanks for the current fix. I will try to investigate this. In my personal configurations caching was also turned off. Dirk Nuyens (talk) 20:59, 20 May 2012 (UTC)
- Thanks for the fix. Still no fix for this? I just installed MediaWiki and MathJax was one of the first extensions that I added. Rendering problem still present. 217.190.111.61 12:08, 12 May 2013 (UTC)
- Rendering problem still present. 19 Aug 2014

I found a fix https://github.com/zalora/Mediawiki-MathJax/commit/880adf7f9da55dbe257043fe431f825211ee96e1

# [WORKAROUND] Blank lines for \newcommand definitionsEdit

When I define new commands using \newcommand, e.g.

```
$ \newcommand{\norm}[1]{\left|\left| #1 \right|\right|} $
```

I get a blank line for each such definition. See the blank lines below the current section title. My question is how this can be avoided? Ch Lin, 20:17, 4 June 2012 (UTC)

- Indeed, WM will render this as an empty paragraph which results in visual white space. You can avoid this effect by sticking the
`$\newcommand$`

part just in front of the first paragraph. E.g.:

` ````
==Some title==
$\newcommand{\norm}[1]{\left|\left| #1 \right|\right|}$
$\newcommand{\normF}[1]{\left|\left| #1 \right|\right|_F}$
Some text here (but no empty line before this sentence):
$$
\norm{x} < 1
$$
```

Dirk Nuyens (talk) 07:40, 11 June 2012 (UTC)

# Rendering math in page titlesEdit

Is there a way to render math in titles of pages? It'd be nice to be able to create a page with the title $e^{2\pi}$ and then have it rendered.

# With Extension:Maps applied at same page , and problem occurs...Edit

**My sample script including extension:MathJax and extension:Maps is as following:**

<math> f(x) = x^2 </math> {{ #display_point: 120.111111,23.0000000 }}

**then, right after saving, the page shows:**

Invalid marker: ?UNIQ50f065171c3f2e4e-MathJax-1-QINU? Backtrace: #0 D:\xampp\htdocs\mediawiki\includes\parser\StripState.php(32): StripState->addItem('nowiki', '?UNIQ50f065171c...', '\( f(x)=x^2 \)') #1 D:\xampp\htdocs\mediawiki\extensions\Mathjax\MathJax.php(360): StripState->addNoWiki('?UNIQ50f065171c...', '\( f(x)=x^2 \)') #2 [internal function]: MathJax_Parser::StripMath(Array) #3 D:\xampp\htdocs\mediawiki\extensions\Mathjax\MathJax.php(291): preg_replace_callback('/((\\\())(.*?)(...', 'MathJax_Parser:...', '\( f(x)=x^2 \)?...') #4 [internal function]: MathJax_Parser::Stage2(Object(Parser), '\( f(x)=x^2 \)?...', Object(StripState)) #5 D:\xampp\htdocs\mediawiki\includes\Hooks.php(216): call_user_func_array('MathJax_Parser:...', Array) #6 D:\xampp\htdocs\mediawiki\includes\GlobalFunctions.php(3847): Hooks::run('InternalParseBe...', Array) #7 D:\xampp\htdocs\mediawiki\includes\parser\Parser.php(1098): wfRunHooks('InternalParseBe...', Array) #8 D:\xampp\htdocs\mediawiki\includes\parser\Parser.php(345): Parser->internalParse('<math> f(x)=x^2...') #9 D:\xampp\htdocs\mediawiki\includes\WikiPage.php(1522): Parser->parse('<math> f(x)=x^2...', Object(Title), Object(ParserOptions), true, true, NULL) #10 D:\xampp\htdocs\mediawiki\includes\WikiPage.php(1290): WikiPage->prepareTextForEdit('<math> f(x)=x^2...', NULL, Object(User)) #11 [internal function]: WikiPage->doEdit('<math> f(x)=x^2...', '', 98) #12 D:\xampp\htdocs\mediawiki\includes\Article.php(1783): call_user_func_array(Array, Array) #13 D:\xampp\htdocs\mediawiki\includes\EditPage.php(1435): Article->__call('doEdit', Array) #14 D:\xampp\htdocs\mediawiki\includes\EditPage.php(1435): Article->doEdit('<math> f(x)=x^2...', '', 98) #15 D:\xampp\htdocs\mediawiki\includes\EditPage.php(960): EditPage->internalAttemptSave(Array, false) #16 D:\xampp\htdocs\mediawiki\includes\EditPage.php(357): EditPage->attemptSave() #17 D:\xampp\htdocs\mediawiki\includes\actions\EditAction.php(51): EditPage->edit() #18 D:\xampp\htdocs\mediawiki\includes\actions\EditAction.php(71): EditAction->show() #19 D:\xampp\htdocs\mediawiki\includes\Wiki.php(484): SubmitAction->show() #20 D:\xampp\htdocs\mediawiki\includes\Wiki.php(278): MediaWiki->performAction(Object(Article)) #21 D:\xampp\htdocs\mediawiki\includes\Wiki.php(593): MediaWiki->performRequest() #22 D:\xampp\htdocs\mediawiki\includes\Wiki.php(503): MediaWiki->main() #23 D:\xampp\htdocs\mediawiki\index.php(58): MediaWiki->run() #24 {main}

**By the way, all the settings in Localsetting.php of Mediawiki are written as what you taught in Extension:MathJAX page. And, the MathJAX is installed for locally use. When I remove anyone of the two extensions in this script, the other works. **
** Would you please get the solution to my question?? Thank you very much.**

Hi, I have a similar problem, If I have in the same page, extension MathJax and extension Geogebra. Any solution? Thank you very much.

Could this be a problem similar to the one with Extension:FootNote, and the use of `Parser::parse`

instead of `recursiveTagParse`

(see below)? Fuujuhi (talk) 16:25, 16 January 2014 (UTC)

# [FIXED] MathJax fails to render in ChromeEdit

I was unable to find information on this issue anywhere, so I am posting my solution here in the hopes that others will find it useful.

I installed this extension (version 0.7 in MediaWiki 1.19.1) and included the following in my LocalSettings.php:

require_once("$IP/extensions/MathJax/MathJax.php"); $wgParserCacheType = CACHE_NONE; # workaround for issues in MW 1.19

Math renders beautifully in Firefox 15.0, IE 9.0, and Safari (the latest; not sure which version). However, in a fresh installation of Chrome 21.0.1180.89, math does not render. Raw markup is displayed instead. Chrome's Javascript console (Tools > Javascript console) revealed the following:

[blocked] The page at [REDACTED] ran insecure content from http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML.

MathJax.org gives an alternative, secure URL for accessing the latest source code. It can be used with this extension by adding the following after the require_once line in LocalSettings.php:

MathJax_Parser::$MathJaxJS = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";

The main page for this extension mentions the existence of the secure CDN, but it does not mention that some browsers will require its use. I do not know if Chrome's same-origin policy has recently changed or if I overlooked sources explaining how to get this extension working in Chrome. However, it seems to me that the HTTPS URL should be used by default by the extension.

Anyway, I hope someone finds this helpful! --Jpgill86 (talk) 15:39, 2 September 2012 (UTC)

# Getting MathJax to work with the WikiEditor Preview tabEdit

WikiEditor is an extension that modifies the page editing tools. It is used on Wikipedia and other WikiMedia Foundation sites, including this one. WikiEditor has a 'wikieditor-preview' option (disabled by default) that allows editors to simply click a tab to switch between editing and previewing changes without needing to reload the page (by clicking the "Show Preview" button at the bottom). MathJax (extension version 0.7) fails to render in WikiEditor's preview (version 0.3.1). To fix this, minor changes need to be made to both the MathJax and WikiEditor extensions. The original conversation can be found here, but I will summarize it in case it disappears.

The MathJax JavaScript and configuration variables are not injected into the HTML if math is not detected when a page is initially loaded. On action=edit pages, there is initially no math to display, so MathJax is never loaded. (If you press the "Show Preview" button, math is detected in the conventional preview, and MathJax is loaded.) This is a problem for the WikiEditor preview, since it does not reload the page. My solution for this problem was to comment out the following line in /extensions/MathJax/MathJax.php:

if(self::$mark_n == 1) return true; // there was no math detected so don't include the MathJax Javascript

You may be able to come up with more elegant solutions.

The second step is WikiEditor needs to be told to render MathJax when it provides its preview. Make the following change in /extensions/WikiEditor/modules/jquery.wikiEditor.preview.js:

--- jquery.wikiEditor.preview.js 2012-09-02 12:58:41.434976589 -0400 +++ jquery.wikiEditor.preview.js 2012-09-02 13:03:19.051407692 -0400 @@ -76,6 +76,7 @@ context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ) .html( data.parse.text['*'] ) .find( 'a:not([href^=#])' ).click( false ); + MathJax.Hub.Queue(["Typeset",MathJax.Hub]); //process math }, 'json' );

If the authors of these two wonderful extensions coordinate their efforts, then MathJax and WikiEditor could work well together out of the box.

I hope others find this useful! --Jpgill86 (talk) 18:01, 2 September 2012 (UTC)

# [FIXED] Setting default options?Edit

Is it possible to set default options so that the scale, zoom trigger, etc. are set by default for each user?

The default options make it really hard to see the math and I'd like the zoom trigger to be hover-over. I know how to adjust my settings, but I worry that other users won't.

I am using the mediawiki MathJax extension Version 0.5.2 and running TeX-AMS-MML_HTMLorMML.js off of a local installation.

Thanks in advance, Dana

- double that, I want to know, how can I set the default value of formula's font size. Because surrounding each formula with <span style="font-size:150%"></span> is not the way. Wait... is it the only way? Abagnale
^{OS Ubuntu 11.04; MW 1.19.2; MySQL 5.1.61; PHP 5.2.17}10:55, 22 September 2012 (UTC)

- Yes you can: through the configuration of MathJax. The most straightforward way is if you have a local installation of MathJax and you modify the config file, but you have to do this for each rendering backend (HTML-CSS, MML and SVG). See from here http://www.mathjax.org/docs/2.0/options/index.html scroll down the page to "Configuration Options by Component" and click and the relevant back-end. The option is each time called "scale". If you want to do this for a CDN setup (the current default) then you can add in a local config file to set the same scale parameter(s) for those back-ends. See http://www.mathjax.org/docs/2.0/configuration.html#using-a-local-configuration-file-with-the-cdn. --Dirk Nuyens (talk) 19:33, 22 September 2012 (UTC)

- Thanks, I'll save it. Local settings file is a good option, I didn't know that (and was too lazy to find that part of the MathJax documentation). Meanwhile I found out another way to scale the size of formulas - using a temlate
*Formula*: <span style="font-size:130%">${{{f}}}$</span>. Example:

- Thanks, I'll save it. Local settings file is a good option, I didn't know that (and was too lazy to find that part of the MathJax documentation). Meanwhile I found out another way to scale the size of formulas - using a temlate

- {{Formula|f=x^2+y^2=z^2}}

- It's easy and it's a good thing in case sometime (I hope never) I will want to choose another extension for rendering TeX.

Abagnale^{OS Ubuntu 11.04; MW 1.19.2; MySQL 5.1.61; PHP 5.2.17}12:24, 24 September 2012 (UTC)

- It's easy and it's a good thing in case sometime (I hope never) I will want to choose another extension for rendering TeX.

# MediaWiki + MathJax + Mobile = ?Edit

I wanted to ask, what is the current status of usability of a MediaWiki installation with the MathJax extension on a mobile device?

I tried two things: First, using the MoblieFrontend extension, which unfortunately seems to destroy the MathJax rendering, and second, using the Desktop default view. Here, many mobile browser (Firefox, Chrome, Dolphin) automatically scale the textsize to a well readable level, while still displaying the full site width on the device. I actually find this view rather convenient, however, just like the menu and all other MediaWiki text(Discussion, User control, Edit, etc..) the MathJax rendered formulas stay in relation to the side width and do not get scaled, making them on the chosen zoom level unreadable. For an example to observe this behaviour, see for example Scholarpedia.

Other than setting the mobile browser to a default tiny textsize view, such that they stay constant in size relative to the site width (this certainly works, but is rather inconvenient for mobile reading) what solutions do you propose?

Thank you for any input! Felix Hoffmann (talk) 15:59, 31 October 2012 (UTC)

- I am not sure if my reply helps, but I tried to view and edit pages on my iPad using Safari, and everything worked perfectly! (I used MediaWiki 1.19.0 + MathJax 0.7. I also tried it with WikiEditor 0.3.1 (using the trick mentioned in this discussion by Jpgill86). In both cases it works!) --T0ur (talk) 22:02, 8 March 2013 (UTC)

- Hi T0ur, thanks for your feedback. I will still try to look into solutions for smartphone size devices, but it's great to know that the MediaWiki + MathJax scales well with tablet devices. Felix Hoffmann (talk) 09:05, 18 April 2013 (UTC)

# Does not work in Live previewEdit

I don't know if this a MathJax problem or Live preview's. But if you enable Live preview, mathjax won't work in previews (but after saving, the page renders correctly). (Tested on en.wikipedia) -- Dalba 15 Esfand 1391/ 07:19, 5 March 2013 (UTC)

- I've lately been experiencing some difficulty with MathJax myself. I thought that the problem was with wikEd, but maybe it's with Live Preview instead? I'd better deactivate it…
- — RandomDSdevel (talk) 00:31, 15 May 2013 (UTC)
- P.S.: You guys
*do*know that MathJax 2.1 is available and will soon be succeeded by MathJax 2.2 when it comes out of beta, right?

# Readability on the main pageEdit

Hi,

I find the main page a bit difficult to read, and did not find that it provides a nice, quick introduction to what the extension does. The section that made it click for me was the one titled "Difference with the default texvc+latex math handling". Perhaps it would help readability if you included a sentence in the introduction that summarized that "this is a replacement for the default texvc+latex math handeling for people who _______".

Also, you may want to add some h3 to "Difference with the default texvc+latex math handling" to distinguish between the technical reasons and usability reasons for using this extension.

Just some random thoughts!! 192.5.110.4 02:40, 8 March 2013 (UTC)

## Equation labels and the "id" attribute (How to make a reference to an equation on a different page)Edit

Sometimes one needs to make a reference from one page to an equation written on another page. The simplest way to do this seems to create an HTML link to the anchor which corresponds to the equation. Fortunately, Extension:MathJax encloses the LaTeX code in the tag "span", so it remains to set the value of its "id" attribute. For instance, if an equation has a label "my-equation", the reasonable value of "id" would be "my-equation". However the following wikitext

\[ a+b=c \label{my-equation} \]

results in the following HTML:

```
<span id="Eq-1">\[
a+b=c \tag{1}
\]</span>
```

So, the value of the "id" attribute (="Eq-1") does not coincide with the label of the equation (="my-equation")!

To fix this, I replaced the following code in MathJax.php (see function RegisterAndTempStripMath)

```
if(self::$label) $stripped = '<span id="Eq-' . self::$label . '">' . $stripped . "</span>";
```

with the following one:

```
$labelname="";
if (self::$remembered_label) {
$labelname=self::$remembered_label;
} else {
$labelname=self::$eqnumbers_rev[self::$label];
}
if(self::$label) $stripped = '<span id="' . $labelname . '" title="' . $labelname . '">' . $stripped . "</span>";
```

I also had to replace

```
return '(<a href="#Eq-' . self::$eqnumbers[$label] . '">' . self::$eqnumbers[$label] . '</a>)';
```

in MathJax.php (see function ReplaceEqrefs) with

```
return '(<a href="#' . $label . '">' . self::$eqnumbers[$label] . '</a>)';
```

After these replacements, the wikitext written above renders as

```
<span id="my-equation" title="my-equation">\[
a+b=c \tag{1}
\]</span>
```

as desired.

To make a link to the equation on a different page, one just has to write [[SourcePage#my-equation]].

In addition, the code above makes it possible to see the label of the equation without having to look into its code. To do this, hover the mouse cursor over the (rendered) equation. Wait a second and the label will be displayed (as the value of the "title" attribute of the "span" tag)!

--T0ur (talk) 14:56, 13 March 2013 (UTC)

P.S. I am new to HTML and PHP so I apologize if the terminology is not correct, and if my solution is not optimal. In anyway, hope my comment helps.

# Semantic Mediawiki with MathJaxEdit

We want to use the Extension:MathJax extension in combination with Semantic MediaWiki and we have run into an issue.

## SetupEdit

A clean setup on Windows Server 2003:

- MediaWiki 1.20.3
- PHP 5.3.8 (apache2handler)
- MySQL 5.5.19

- Semantic MediaWiki (Version 1.9 alpha)
- DataTypes (Version 0.1 alpha)
- DataValues (Version 0.1 alpha)
- ValueFormatters (Version 0.1 alpha)
- ValueParsers (Version 0.1 alpha)
- ValueValidators (Version 0.1 alpha)
- MathJax (Version 0.7)
- Validator (ParamProcessor) (Version 1.0 alpha)

**Note:***The same happens with Semantic Mediawiki 1.8.0.4 and Validator 0.5.1 and I am aware that the MathJax extension is still Beta but when we use it it can only get better.*

## ProblemEdit

On a clean Wiki with only the **Semantic MediaWiki** and **MathJax** extensions enabled I created a page called **Test** with the following content:

{{#set:Blabla={{{Blabla}}}}} ==Blabla==

When initiating `SMW_UpdateJob.php`

via the **Admin functions** or run an script on the server and then force the jobs to run on the server with `php runjobs.php`

the following error pops up and the updates are stopped:

2013-03-21 10:44:28 SMWUpdateJob Test STARTING Invalid marker: ¦UNIQ2d62e28b1b344275-h-0--QINU¦ Backtrace: #0 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\includes\parser\StripState.php(66): StripState->addItem('general', '¦UNIQ2d62e28b1b...', '') #1 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\includes\parser\Preprocessor_DOM.php(1168): StripState->addGeneral('¦UNIQ2d62e28b1b...', '') #2 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\includes\parser\Parser.php(3038): PPFrame_DOM->expand(Object(PPNode_DOM), 0) #3 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\includes\parser\Parser.php(1136): Parser->replaceVariables('{{#set:Blabla={...') #4 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\includes\parser\Parser.php(370): Parser->internalParse('{{#set:Blabla={...') #5 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\extensions\SemanticMediaWiki\includes\jobs\SMW_UpdateJob.php(59): Parser->parse('{{#set:Blabla={...', Object(Title), Object(ParserOptions), true, true, 5) #6 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\maintenance\runJobs.php(92): SMWUpdateJob->run() #7 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\maintenance\doMaintenance.php(110): RunJobs->execute() #8 D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediawiki-1.20.3\maintenance\runJobs.php(122): require_once('D:\Program File...') #9 {main}

This does not happen when MathJax is disabled. So it seems this is a MathJax issue.

The semantic updates work fine when there is:

**A.** No heading like:

{{#set:Blabla={{{Blabla}}}}}

**B.** The heading is before the #set call like:

==Blabla== {{#set:Blabla={{{Blabla}}}}}

**C.** The parameter has a default pipe `|`

like:

{{#set:Blabla={{{Blabla|}}}}} ==Blabla==

This seems to be a string handling problem. What can cause this behavior? Best regards --Jongfeli (talk) 11:00, 21 March 2013 (UTC)

Could this be a problem similar to the one with Extension:FootNote, and the use of `Parser::parse`

instead of `recursiveTagParse`

(see below)? Fuujuhi (talk) 16:27, 16 January 2014 (UTC)

## AsciiMath2jax possible?Edit

Is it "easily" possible to include MathJax' ability to treat AsciiMathML into this extension? The MathJax site seems to says that it is all laid out -- at least to my noobisch understanding. Though, I have no idea how to actually go about that.

I would suggest using (double-)back-ticks (`) as additional delimiters for AsciiMathML, keeping them separate from LaTeX.

Many thanks for this great extension! -- Sm8ps (talk) 23:17, 4 July 2013 (UTC)

# VisualEditor compatibilityEdit

Does anybody know if it's possible to integrate this extension with the new Extension:VisualEditor. When one clicks on the 'edit' tab, all of the equations are given for example as:

--- Since this 'outer product' of vectors is antisymmetric, and the inner product is symmetric, we can formulate the general product as being composed of symmetric and anti-symmetric parts:↵\begin{equation}↵{\bf a}{\bf b} = {\bf a}\cdot{\bf b} + {\bf a}\wedge{\bf b}↵\end{equation} ---

I imagine integrating VisualEditor and Mathjax would be very challenging, but is there an easy way to get it to stop putting in those annoying '↵' characters?

# Changing Font SizeEdit

It was asked under another topic here if it was possible to change the default font size of MathJax in MediaWiki; at least that was my search keywords which brought me here.

My issue was that math formulae tended to be over-sized when embedded into standard text rendering especially PDFs quite ugly. (This is also true for articles in Wikipedia BTW.) I found a quite simple solution that has worked really well. Maybe it is of use to other MediaWikiarians out there.

All credits go to the source but I copy the relevant parts her for anybody's reference. Using a scaling of 80% seems about right but to be honest, I do not know if that is independent of browsers etc. So YMMV.

Open $IP$/components/com_jwiki/extensions/MathJax/mwMathJaxConfig.js and add

"HTML-CSS": { scale:80 },

just before

TeX: {

--Sm8ps (talk) 20:33, 2 September 2013 (UTC)

## Update: STIX-FontsEdit

By using the STIX-fonts, the above work-around proved to be unnecessary. BTW, these fonts need to be installed on the client browser. (Yes, it *is* true that not everybody would know that by themselves!)

# [Resolved] MathJax not renderingEdit

I've installed a wiki on a private server and installed a local copy of MathJax to render the equations. After completing the installation I tested by visitng `http://(Server)/mathjax/test`

, where the page tells me that "MathJax Appears to be Working!" After this test I added the line `MathJax_Parser::$MathJaxJS = '/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML';`

after the `require_once`

line in my LocalSettings.php configuration file. (Basically I followed all the instructions and the initial test says it's installed correctly)

However, if I navigate to any of my wiki's pages, I still see the LaTeX syntax and not the rendered equations.

Using: MediaWiki 1.21.2 MathJax 0.7

Any idea why this may be happening? SpartanGuy07 (talk) 19:41, 23 September 2013 (UTC)

**Update**: So now after figuring out the correct MathJax_Parser path (I think-- 'http://(server)/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML') I find that the equations only render some of the time and that sometimes one or two gets missed. Any help as to why this might be happening is appreciated. SpartanGuy07 (talk) 15:28, 24 September 2013 (UTC)

- Are sure your math syntax is correct? Is "missing a formula" a random thing or is it always the same one? Are you using any form of PHP
**caching**on your server and is your wiki set up to use**Variable**caching with something like`$wgMainCacheType = CACHE_ACCEL;`

? If so you could try to disable php caching completely to see if that solves the problem. If that gets things working enable caching again and run MediaWiki with`$wgMainCacheType = CACHE_NONE;`

. If it is still working try`$wgMainCacheType = CACHE_ACCEL;`

with`$wgParserCacheType = CACHE_NONE;`

. When testing like this make sure you restart Apache between every step and use "CTRL-F5" to refresh your wiki pages. Regards, --Jongfeli (talk) 07:11, 26 September 2013 (UTC)

- Are sure your math syntax is correct? Is "missing a formula" a random thing or is it always the same one? Are you using any form of PHP

- Jonfeli, you were completely right, the issue was the parser cache! Setting
`$wgMainCacheType = CACHE_ACCEL;`

and`$wgParserCacheType = CACHE_NONE;`

make it work properly. Thank you for the help.SpartanGuy07 (talk) 18:59, 26 September 2013 (UTC)

- Jonfeli, you were completely right, the issue was the parser cache! Setting

# How to fix CSS?Edit

When beginning a line with ":<math>" MathJax_Display sets style="text-align: center;" which is inconsistent with the MediaWiki standard that leading colons specify indents. I can't trace the CSS responsible for this. Where/how can I fix it? Dbooksta (talk) 17:10, 19 November 2013 (UTC)

- Any news on this? centered formulas look horrible. They should be left-aligned and slightly indented from the left border. --2003:63:2F67:9600:AC45:A748:C3C0:5646 17:35, 5 April 2014 (UTC)

## Articlepath and Scriptpath on Special:VersionEdit

In my site if MathJax is enabled on Special:Version page the "Article path" and the "Script path" in table "Entry point URLs" cannot be displayed correctly. When MathJax disabled, they are ok. This problem occurs also on the site https://wiki.x2592.com/index.php?title=Special:Version .

# [FIXED] Invalid Marker when using Extension:MathJax with Extension:FootNoteEdit

The mediawiki distributed with Debian contains an extension called *FootNote*. This extensions causes an *Invalid marker* error similar to the one seen with Extension:Maps:

Invalid marker: ?UNIQ50f065171c3f2e4e-MathJax-1-QINU Backtrace: #0 D:\xampp\htdocs\mediawiki\includes\parser\StripState.php(32): StripState->addItem('nowiki', '?UNIQ50f065171c...', '\( f(x)=x^2 \)') #1 D:\xampp\htdocs\mediawiki\extensions\Mathjax\MathJax.php(360): StripState->addNoWiki('?UNIQ50f065171c...', '\( f(x)=x^2 \)') #2 [internal function]: MathJax_Parser::StripMath(Array) ...

The fix is to patch FootNote.php so that it uses `recursiveTagParse()`

(as suggested here):

```
diff --git a/footnote.php b/footnote.php
index 4d5c052..17c7fab 100644
--- a/footnote.php
+++ b/footnote.php
@@ -77,7 +77,7 @@ function insert_endnotes( &$parser, &$text ) {
return true;
}
-function parse_footnote( $text, $params, $parser ) {
+function parse_footnote( $text, array $params, Parser $parser, PPFrame $frame ) {
$ret = "" ;
global $footnoteNotes , $footnoteCount, $footnoteRecursionGuard ;
@@ -88,8 +88,7 @@ function parse_footnote( $text, $params, $parser ) {
}
$footnoteRecursionGuard = true;
- $ret = $footnoteParserObj->parse( $text , $parser->getTitle() , $parser->getOptions(), false ) ;
- $ret = $ret->getText();
+ $ret = $parser->recursiveTagParse( $text, $frame );
$footnoteRecursionGuard = false;
$footnoteNotes[$footnoteCount] = $ret;
```

## MathJax can't load certain fonts on WikipediaEdit

In my Wikipedia preferences, I have the MathJax experimental feature turned on.

Then sometimes when I open certain pages, for instance this one—Gauge, it takes a long time to load fonts, and in the end I get several failure messages, e.g., "can't load web-font TeX/SansSerif/Regular", "can't load web-font TeX/Math/BoldItalic". I checked my JavaScript console, and clearly there are three errors:

```
Failed to load resource: the server responded with a status of 404 (Not Found) https://bits.wikimedia.org/static-1.23wmf12/extensions/Math/modules/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Greek-BoldItalic.woff
```

```
Failed to load resource: the server responded with a status of 404 (Not Found) https://bits.wikimedia.org/static-1.23wmf12/extensions/Math/modules/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Greek-Bold.woff
```

```
Failed to load resource: the server responded with a status of 404 (Not Found) https://bits.wikimedia.org/static-1.23wmf12/extensions/Math/modules/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_WinIE6-Regular.woff
```

So these fonts are not on the server.

(I apologize if I'm reporting the bug at the wrong place—I couldn't figure out where to report on Wikipedia. Please direct me to the correct place if necessary. Thanks.)

WangPublic (talk) 06:58, 13 February 2014 (UTC)

## How to make to work nowiki, syntaxhighlight, code and so on with MathJax?Edit

* NOTE:* there is similar issue, but there is no solution.

When I tried to use syntaxhighlight from the page enabled mathjax, I've seen ?UNIQ9f529e669544ba57-syntaxhighlight-00000001-QINU? as a result of syntaxhighlight. nowiki and code produces similar result as well.

## user rights to load dynamically the mathjax libraryEdit

It seems that when I am connected as wikiSysop

the library is loaded

I see at the bottom of my firefox any tracelog as :

Loading(MathJax/Jax/output/HTML-CSS/autoload/mtable.js Processing Math : 56%

but when I am not connected or connect as user : Nothing is loaded and the display only shows the Text syntax with all the tags...

in the apparence preference of mediawiki the ckeckcase is PNG

**The problem has been solved by adding "$wgParserCacheType = CACHE_NONE;" at the end of my localsetting;php**

## MathJax not working in preformatted textEdit

I don't mean the pre tags, on wikis if you start a line with a space it becomes like text in pre, only it is parsed. I have a block which is formatted but has

[math]...[/math]

tags in it, this is obviously a bug.

Alec

## Very slow to renderEdit

The wiki page initially displays without any Mathjax rendering then about 15 seconds later the Mathjax get's rendered. There isn't an error in the rendering it's just painfully slow.

There is an error in the console displayed just as the Mathjax is rendered (i.e after about 15 seconds)

Font from origin 'null' has been blocked from loading by Cross-Origin Resource Sharing policy: Invalid response.

Any ideas what might be going on? It feels like something is timing out but I've no idea what.

I am using a local install of Mathjax Version 2.6 That runs quickly when I use it with Doxygen.(i.e under 0.5sec).

## Works on MediaWiki 1.26.2, MathJax 2.6.1, Ubuntu 15.10Edit

I have installed this on Mediawiki 1.26.2, MathJax 2.6.1, Ubuntu 15.10.

I can confirm slow rendering (ca. 15 sec delay) as described in an earlier note here. However, I could fix this as follows:

Instead of using the line

$wgMathJaxLocConf = "local/mwMathJaxConfig";

I used

$wgMathJaxLocConf = "default";

In order to enable single '$' delimiter pairs for inline TeX, I uncommented the corresponding line concerning the tex2jax parameters in MathJax/config/default.js.

So it seems the file mwMathJaxConfig.js is not suited to MW 1.26.2.

--Ulf Rehmann (talk) 11:02, 29 February 2016 (UTC)

## Resolving the pause issueEdit

Mediawiki 1.27 and Ubuntu 16.04

I resolved the 15 second pause issue by altering the last line of [mediawiki location]/extensions/MathJax/mwMathJaxConfig.js.

I changed localhost to my server name. I noticed that the browser on the client was looking on localhost for the configuration file and I think this caused the timeout. It also looked for the config file on the correct server and thus still worked. Perhaps the client is told in two different places where the config file is?