Extension:SimpleMathJax
SimpleMathJax Release status: stable |
|
---|---|
Implementation | Tag |
Description | Allows to render mathematical formulas using MathJax with MediaWiki math style |
Author(s) | jmnote, vedmaka, jamesmontalvo3, badshah400 |
Latest version | 0.8.4 (2023-11-04) |
MediaWiki | 1.29+[1] |
Database changes | No |
License | MIT License |
Download | GitHub:
<translate> Note:</translate> README |
Example | zetawiki.com |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
The SimpleMathJax extension enables MathJax, a JavaScript library, for typesetting TeX formula in MediaWiki inside math environments.
This extension will load resources from cdn.jsdelivr.net
on all wiki pages that have math or chem tags.
<math>E=mc^2</math>
- Advantages
- Simple
- Lightweight
- UTF-8 Support
- Mobile View OK
- Setting Font Size
- chem tag support for chemistry
- additional inlineMath symbols pairs support
- MediaWiki Style! Look at the samples.
Installation
- <translate> <tvar name=1>Download</tvar> and place the file(s) in a directory called <tvar name=name>
SimpleMathJax
</tvar> in your <tvar name=ext>extensions/
</tvar> folder.</translate> - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'SimpleMathJax' );
- If necessary configure at your convenience
- File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
Or you can git clone.
$ git clone --depth 1 https://github.com/jmnote/SimpleMathJax.git
If you want to use local MathJax scripts (and not a CDN), then you can use git clone recursive.
In most cases, CDN is much faster than your server.
However, a CDN may not be available if you have a hardened PHP installation due to disabled_functions
restrictions.
$ git clone --depth 1 --recursive --shallow-submodules https://github.com/jmnote/SimpleMathJax.git
SimpleMathJax is meant to be used as an alternative to the Math extension. If the Math extension is installed it may take precedence and cause SimpleMathJax to not work. The SimpleMathJax extension is the only thing you need to start rendering equations.
Configuration settings
The following variables can be defined in LocalSettings.php after calling wfLoadExtension( 'SimpleMathJax' );
. Note that for a simple site adding $wgSmjScale = 1.1;
might be all you need to make it Just Work™.
Version | Setting name | Default value | Description |
---|---|---|---|
0.7.0+ | $wgSmjUseCdn | true
|
Using CDN or Local resource |
0.7.0+ | $wgSmjUseChem | true
|
enable <chem> tags( defaults to use chem tags ) |
0.8.0+ | $wgSmjEnableMenu | true
|
Make MathJax context menu available This setting is missed since 0.8.0; it would be a mistake |
0.8.0+ | $wgSmjExtraInlineMath | []
|
can add some additional inlineMath symbols pairs |
0.8.1+ | $wgSmjScale | 1
|
The default font size for SimpleMathJax |
0.7.4 | $wgSmjShowMathMenu | false | <translate> (removed)</translate> (replaced by $wgSmjEnableMenu) |
0.6.1 | $wgSmjSize | 110 | <translate> (removed)</translate> (replaced by $wgSmjScale) |
0.6.1 | $wgSmjInlineMath | [] | <translate> (removed)</translate> (replaced by $wgSmjExtraInlineMath) |
0.6.1 | $wgSmjDisableChem | false | <translate> (removed)</translate> (replaced by $wgSmjUseChem) |
0.6.1 | $wgSmjScripts | ['//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/extensions/TeX/mhchem.js'] |
<translate> (removed)</translate> (replaced by $wgSmjUseCDN) can use local or another remote scripts ( defaults to use cloudflare CDN ) |
0.6 | $wgSimpleMathJaxSize | 125 | <translate> (removed)</translate> (replaced by $wgSmjSize) |
0.6 | $wgSimpleMathJaxUseCDN | true | <translate> (removed)</translate> (replaced by $wgSmjScripts) |
0.6 | $wgSimpleMathInlineMath | [] | <translate> (removed)</translate> (replaced by $wgSmjInlineMath) |
If you want to change font size, set $wgSmjScale
like below.
wfLoadExtension( 'SimpleMathJax' );
$wgSmjScale = 1.5;
If you want to enable some additional inlineMath symbol pairs, set $wgSmjExtraInlineMath
like below.
wfLoadExtension( 'SimpleMathJax' );
$wgSmjExtraInlineMath = [ [ "$", "$" ], [ "\\(", "\\)" ] ];
If you want to use local module, set $wgSmjUseCdn
like below.
wfLoadExtension( 'SimpleMathJax' );
$wgSmjUseCdn = false;
SimpleMathJax and Live Preview (versions < 0.8.0)
Prior to version 0.8.0, the following had to be added to MediaWiki:Common.js in order to have the Live Preview in the editor show rendered math output instead of raw LaTeX source code:
function waitForMathJax($content) {
if (typeof MathJax === 'undefined') {
setTimeout(function () { waitForMathJax($content); }, 1000);
} else {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();
}
}
mw.hook('wikipage.content').add(waitForMathJax);
Samples
- Comparison
- en:user:Jmkim dot com/TeX Samples (rendering with wikipedia math engines, English)
- ko:user:Jmkim dot com/TeX 샘플 (rendering with wikipedia math engines, Korean)
- http://zetawiki.com/wiki/TeX_샘플 (rendering with SimpleMathJax)
- More examples
- http://zetawiki.com/wiki/TeX_문법 (Grammar)
- http://zetawiki.com/wiki/TeX_행렬 (Matrix)
- http://zetawiki.com/wiki/TeX_특수문자 (Special Characters)
- http://zetawiki.com/wiki/Mhchem_테스트 (chem tags)
See also
External links
File:OOjs UI icon information-progressive.svg | <translate> This extension is included in the following wiki farms/hosts and/or packages:</translate>
<translate> This is not an authoritative list.</translate> <translate> Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.</translate> <translate> Always check with your wiki farms/hosts or bundle to confirm.</translate> |
- ↑ SimpleMathJax 0.8.0+ uses manifest_version 2. Manual:Extension.json/Schema
- Pages with script errors
- Pages with broken file links
- Stable extensions
- Extensions without an image
- Tag extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- MIT licensed extensions
- Extensions in GitHub version control
- ParserFirstCallInit extensions
- All extensions
- TeX
- Math display extensions