DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:mathjax

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
plugin:mathjax [2016-03-26 16:10] – Add note on enabling AsciiMath liffitonplugin:mathjax [2020-12-15 05:58] – [MathJax Plugin] liffiton
Line 6: Line 6:
 email      : liffiton@gmail.com email      : liffiton@gmail.com
 type       : action, syntax type       : action, syntax
-lastupdate : 2015-06-17 +lastupdate : 2020-12-14 
-compatible : Ponder Stibbons, Rincewind, Angua, Adora Belle, Weatherwax, Binky, 2014-09-29 "Hrun", Detritus+compatible : Hogfather, Greebo, Frusterick Manners, Ponder Stibbons, Rincewind, Angua, Adora Belle, Weatherwax, Binky, 2014-09-29 "Hrun", Detritus, Elenor of Tsort
 depends    :  depends    : 
 conflicts  : creole, indexmenu2, revealjs, s5 conflicts  : creole, indexmenu2, revealjs, s5
Line 22: Line 22:
  
 This plugin adds [[http://www.mathjax.org/|MathJax]] to your wiki pages to let you easily write mathematical formulas that will be typeset and displayed cleanly.  It is written to be as simple as possible; it loads and configures the script, protects TeX math expressions from other parsing, and no more. This plugin adds [[http://www.mathjax.org/|MathJax]] to your wiki pages to let you easily write mathematical formulas that will be typeset and displayed cleanly.  It is written to be as simple as possible; it loads and configures the script, protects TeX math expressions from other parsing, and no more.
 +
 +It has been tested with MathJax version 2.7.x, the default MathJax version loaded by the plugin is 2.7.x, and all of the links to documentation here point to the v2.7 documentation.  The plugin //does not// work with MathJax v3.x without modifications ([[https://github.com/liffiton/dokuwiki-plugin-mathjax/issues/37|work in progress]]).
  
 ===== Installation ===== ===== Installation =====
  
-Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually. +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
- +
-==== Workaround for IE and Old Dokuwiki Versions ==== +
- +
-Dokuwiki versions 2012-01-25 'Angua' and earlier have a bug that prevents this plugin from working when using Internet Explorer.  [[bug>2563|The bug]] has been fixed and shouldn't be a problem in later releases, but 2012-01-25 and before need the following workaround applied for math to render in IE: +
- +
- Edit ''inc/template.php'' and change lines 375-377 (assuming the 2012-01-25 "Angua" release) in ''_tpl_metaheaders_action()'' to: +
- +
-  $attr['_data'] = "/*<![CDATA[*/\n"+
-      $attr['_data']. +
-      "\n/*!]]>*/";+
  
 ===== Examples/Usage ===== ===== Examples/Usage =====
Line 77: Line 69:
 The plugin installs with a default configuration that should work for most users.  It is ready to go upon installation, and extra configuration is only required for specific needs. The plugin installs with a default configuration that should work for most users.  It is ready to go upon installation, and extra configuration is only required for specific needs.
  
-The URL to the MathJax script can be set in the Configuration Manager.  By default, it uses the [[http://docs.mathjax.org/en/latest/start.html#mathjax-cdn|MathJax CDN]], loading the latest version of MathJax from a remote server maintained and updated by the MathJax team.  The default URL loads MathJax securely (via HTTPS) if the wiki itself is served securely.+The URL to the MathJax script can be set in the Configuration Manager.  By default, it loads the script from the [[https://cdnjs.com/libraries/mathjax|CDNJS CDN]].  The default URL loads MathJax securely (via HTTPS).
  
 You can host your own installation of MathJax instead, in which case you can change the URL to point to your own installation, either as a complete URL or as an absolute path to the MathJax directory on your server (from the web root, e.g., "/scripts/mathjax.js" for "%%http://your.site/scripts/mathjax.js%%"). You can host your own installation of MathJax instead, in which case you can change the URL to point to your own installation, either as a complete URL or as an absolute path to the MathJax directory on your server (from the web root, e.g., "/scripts/mathjax.js" for "%%http://your.site/scripts/mathjax.js%%").
Line 83: Line 75:
 Additionally, you can configure MathJax via commands given in a configuration string and/or loaded from files; both methods can be controlled in the Configuration Manager.  Note that the default URL loads a reasonable configuration from the CDN, and the default configuration string modifies it slightly. Additionally, you can configure MathJax via commands given in a configuration string and/or loaded from files; both methods can be controlled in the Configuration Manager.  Note that the default URL loads a reasonable configuration from the CDN, and the default configuration string modifies it slightly.
  
-For more information on configuring MathJax, see [[http://docs.mathjax.org/en/latest/config-files.html|Common Configurations]] and [[http://docs.mathjax.org/en/latest/options/index.html|MathJax Configuration Options]] in the [[http://docs.mathjax.org/en/latest/|MathJax documentation]].+For more information on configuring MathJax, see [[https://docs.mathjax.org/en/v2.7-latest/config-files.html|Common Configurations]] and [[https://docs.mathjax.org/en/v2.7-latest/options/index.html|MathJax Configuration Options]] in the [[https://docs.mathjax.org/en/v2.7-latest/|MathJax documentation]].
  
-==== AsciiMath ====+==== Third-Party Extensions ====
  
-MathJax has the ability to parse and render [[http://asciimath.org/|AsciiMath]] markup, but it is not enabled in the default configuration of this plugin.  One easy way to enable the AsciiMath preprocessor is to use a different [[http://docs.mathjax.org/en/latest/config-files.html|configuration file]]set ''plugin»mathjax»url'' to ''%%//%%cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML''.  (That configuration enables both TeX and AsciiMath; see the list of configuration files for other options. You may want to modify some [[https://mathjax.readthedocs.org/en/latest/options/asciimath2jax.html#configure-asciimath2jax|AsciiMath-specific settings]] as well.+Some [[https://docs.mathjax.org/en/v2.7-latest/options/ThirdParty.html|third-party MathJax extensions]] may require a different configuration than the plugin's default to operate properly.  For example, it has been reported that the XyJax extension does not function with the "CHTML" renderer.  In that case, set the Dokuwiki configuration option ''plugin»mathjax»url'' to ''%%https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML.js%%'' (changing it to use the ''Tex-AMS_HTML'' MathJax configuration rather than ''TeX-AMS_CHTML'') to allow XyJax to work. 
 + 
 +==== AsciiMath ====
  
 +MathJax has the ability to parse and render [[http://asciimath.org/|AsciiMath]] markup, but it is not enabled in the default configuration of this plugin.  One easy way to enable the AsciiMath preprocessor is to use a different [[http://docs.mathjax.org/en/v2.7-latest/config-files.html|configuration file]]: set ''plugin»mathjax»url'' to ''%%https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=AM_CHTML.js%%''.
 ==== Automatic Equation Numbering ==== ==== Automatic Equation Numbering ====
  
-MathJax 2.0 introduces [[http://docs.mathjax.org/en/latest/tex.html#automatic-equation-numbering|automatic equation numbering]], but it is not enabled in the default configuration.  To enable it, go to your wiki's configuration editor and change the ''plugin»mathjax»config'' setting to something like this:+MathJax 2.0 introduces [[https://docs.mathjax.org/en/v2.7-latest/tex.html#automatic-equation-numbering|automatic equation numbering]], but it is not enabled in the default configuration.  To enable it, go to your wiki's configuration editor and change the ''plugin»mathjax»config'' setting to something like this:
  
   MathJax.Hub.Config({   MathJax.Hub.Config({
Line 104: Line 99:
 The line ''TeX: { equationNumbers: {autoNumber: "AMS"} }'' enables the equation numbering. The line ''TeX: { equationNumbers: {autoNumber: "AMS"} }'' enables the equation numbering.
  
-See the [[http://docs.mathjax.org/en/latest/tex.html#automatic-equation-numbering|MathJax documentation]] or the [[http://cdn.mathjax.org/mathjax/latest/test/examples.html|MathJax examples page]] for the syntax for creating automatic references to equations, as well.+See the [[http://docs.mathjax.org/en/v2.7-latest/tex.html#automatic-equation-numbering|MathJax documentation]] or the [[https://cdn.rawgit.com/mathjax/MathJax/2.7.7/test/examples.html|MathJax examples page]] for the syntax for creating automatic references to equations, as well.
  
 +==== Changing default size or scale ====
 +
 +The default size of equations can be changed by adding the "CommonHTML" section and using the "scale" parameter. A value of "125" means "125%".
 +
 +  MathJax.Hub.Config({
 +    tex2jax: {
 +        inlineMath: [ ["$","$"], ["\\(","\\)"] ],
 +        displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
 +        processEscapes: true
 +    },
 +  CommonHTML: {
 +    scale: 125
 +  }
 +  });
 ===== Development ===== ===== Development =====
  
Line 113: Line 122:
  
 Alternatively, feel free to report issues in the Discussion section below. Alternatively, feel free to report issues in the Discussion section below.
 +
 +
 +===== Notes on Older Versions =====
 +
 +==== Workaround for IE and Old Dokuwiki Versions ====
 +
 +Dokuwiki versions 2012-01-25 'Angua' and earlier have a bug that prevents this plugin from working when using Internet Explorer.  [[bug>2563|The bug]] has been fixed and shouldn't be a problem in later releases, but 2012-01-25 and before need the following workaround applied for math to render in IE:
 +
 + Edit ''inc/template.php'' and change lines 375-377 (assuming the 2012-01-25 "Angua" release) in ''_tpl_metaheaders_action()'' to:
 +
 +  $attr['_data'] = "/*<![CDATA[*/\n".
 +      $attr['_data'].
 +      "\n/*!]]>*/";
 +
 +
 +==== CDN Update - March, 2017 ====
 +
 +Until March 31, 2017, this plugin was using the MathJax CDN for loading MathJax.  MathJax has [[https://www.mathjax.org/cdn-shutting-down/|shut down]] its CDN as of April 30, 2017.
 +
 +The default URL from which the plugin loads MathJax has been changed to use CDNJS as the MathJax maintainers recommend. If you have not changed the URL in your configuration, just update the plugin to its latest version, and your wiki should start using the new URL automatically. If you **have** modified the URL and are still using the MathJax CDN, you will need to update it in the wiki configuration manager (e.g. following the recommendation in the [[https://www.mathjax.org/cdn-shutting-down/|shutdown notice]]). And if you are not using the MathJax CDN, this should not affect you.
 +
  
 ===== FAQ ===== ===== FAQ =====
Line 143: Line 173:
  
   * [[http://www.dessci.com/en/products/mathtype/|Mathtype]]   * [[http://www.dessci.com/en/products/mathtype/|Mathtype]]
-    * :!: Update: Do not expect too much from Mathtype. In Word 2007, simple symbols like the dot product or a hat (^) will abort the conversion to Latex. For automated batch conversion of even slightly complex math, you're screwed --- Johan+    * __Update__: Do not expect too much from Mathtype. In Word 2007, simple symbols like the dot product or a hat (^) will abort the conversion to Latex. For automated batch conversion of even slightly complex math, you're screwed --- Johan
   * [[http://www.grindeq.com|GrindEQ]]   * [[http://www.grindeq.com|GrindEQ]]
   * [[http://www.word2tex.com|Word2tex]]   * [[http://www.word2tex.com|Word2tex]]
Line 176: Line 206:
 :?: Are ''\newcommand'' and other custom macro/environment definitions supported? :?: Are ''\newcommand'' and other custom macro/environment definitions supported?
  
-**Answer**: [[http://docs.mathjax.org/en/latest/tex.html#defining-tex-macros|Yes]], either in your page inside math delimiters or through the configuration script.+**Answer**: [[http://docs.mathjax.org/en/v2.7-latest/tex.html#defining-tex-macros|Yes]], either in your page inside math delimiters or through the configuration script.
  
 ---- ----
Line 209: Line 239:
      
 (taken from the [[https://docs.mathjax.org/en/v2.5-latest/tex.html#tex-macros|mathjax docu]]) (taken from the [[https://docs.mathjax.org/en/v2.5-latest/tex.html#tex-macros|mathjax docu]])
 +
 +----
 +
 +:?: How to configure the MathJax plugin step by step so that we can use XyJax in DokuWiki? 
 +
 +The section on third-party extensions that mentions XyJax has been updated to correct the URL for the new CDN.  For instructions on installing/using XyJax, there's [[https://github.com/sonoisa/XyJax|the XyJax README]].  It will involve modifying and hosting the XyJax javascript file yourself (it isn't available on a CDN as far as I can tell), which is outside of the scope of this plugin.
 +
 +(Here are the steps of installation/configuration: a) Change the value of ''plugin>>mathjax>>url'' according to the Section of Third-Party Extensions. b) Follow the five steps of Installation Method 1 at [[https://github.com/sonoisa/XyJax|the XyJax README]]. For details, see https://forum.dokuwiki.org/thread/12374)
 +
 +----
 +
  
 ===== Discussion ===== ===== Discussion =====
Line 220: Line 261:
  
 > **Printing** (via the browser ''File > Print'') yields **overlap** between inline Mathjax content and the normal non-Mathjax text that follows. --- Johan > **Printing** (via the browser ''File > Print'') yields **overlap** between inline Mathjax content and the normal non-Mathjax text that follows. --- Johan
->> The [[http://docs.mathjax.org/en/latest/output.html|Mathjax documentation]] says, "The HTML-CSS output uses web-based fonts so that users don’t have to have math fonts installed on their computers, which introduces some printing issues in certain browsers."  And later, "The SVG output mode is high quality and slightly faster than HTML-CSS, and it does not suffer from some of the font-related issues that HTML-CSS does, so prints well in all browsers."  If you right-click on a math expression, you can change the renderer temporarily for that page to "SVG."  In my browser (FF 18), that will re-render the page such that it prints correctly.  You could change the renderer for all pages to SVG in your wiki's Mathjax configuration, or just do it within a page each time you want to print. --- Mark+>> The [[http://docs.mathjax.org/en/v2.7-latest/output.html|Mathjax documentation]] says, "The HTML-CSS output uses web-based fonts so that users don’t have to have math fonts installed on their computers, which introduces some printing issues in certain browsers."  And later, "The SVG output mode is high quality and slightly faster than HTML-CSS, and it does not suffer from some of the font-related issues that HTML-CSS does, so prints well in all browsers."  If you right-click on a math expression, you can change the renderer temporarily for that page to "SVG."  In my browser (FF 18), that will re-render the page such that it prints correctly.  You could change the renderer for all pages to SVG in your wiki's Mathjax configuration, or just do it within a page each time you want to print. --- Mark
  
 > **Spacing** in vertical direction around displayed equations ''$$e = mc^2$$'' are larger than desired if such an equation is preceeded and followed by a blank line. However, removal of blank lines reduces the source readability. What is the best practice? --- Johan > **Spacing** in vertical direction around displayed equations ''$$e = mc^2$$'' are larger than desired if such an equation is preceeded and followed by a blank line. However, removal of blank lines reduces the source readability. What is the best practice? --- Johan
plugin/mathjax.txt · Last modified: 2024-02-13 04:53 by liffiton

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki