Extension talk:Math/Archive 1

From MediaWiki.org
Jump to navigation Jump to search

Installation on Windows 7 SP1 x64

Added January 25, 2015 09:27 EST
This is my solution to installing Extension:Math on a private mediawiki v1.23.5 under Windows 7 Ultimate SP1 x64 with LaTeX installed locally. Your performance will vary.

being comments
If one of my students turned in this software for a grade I'd give them an F for the software and an F- for the documentation. end comments

Wikipedia faces the same choices as us and they settled on this solution. So adopt it since it would take more time and aggravation to write your own solution.

1. Install from Cygwin dvipng, ghostscript, and LaTeX.
1.1 The LaTeX executable is pdftex.exe. Since the Cygwin UNIX-links do not work in Windows 7 copy the bin\pdftex.exe to bin\latex.exe. Make sure the directory links point to bin\pdftex.exe so they do not break after an update.
2. Install and compile Math\math and Math\texvccheck without any modifications. Do not run the update.php until last.
3. Add this line to the ImageMagick section in the LocalSettings.php file.
$wgImageMagickIdentifyCommand = "C:\\Program Files\\ImageMagick-6.9.0-Q16\\identify.exe";

4. Add the below to the LocalSettings.php file.

# Extension::Math 2.4 23-JAN-2015
# Working configuration
require_once "$IP/extensions/Math/Math.php";
// See below for installation requirements and configuration settings:
$wgUseTeX= true; // enables the <math/> tag

# texvc binary
$wgTexvc = "$IP/extensions/Math/math/texvc.exe";

$wgDefaultUserOptions['math'] = MW_MATH_LATEXML;
$wgMathValidModes[] = MW_MATH_LATEXML; // adding LaTeXML as rendering option

$wgTexvcBackgroundColor = 'transparent';
$wgMathTexvcCheckExecutable = "$IP/extensions/Math/texvccheck/texvccheck.exe";
$wgUploadDirectory = "$IP/images";
$wgMathPath = "$IP/images/math";
$wgMathDirectory = "$IP/images/math";
$wgTmpDirectory = "$IP/images/temp";

# Disable MathJax

$wgDefaultUserOptions['mathJax'] = false;

# Set the default rendering mode to pictures
$wgMathDisableTexFilter = true; # true any LaTeX expression is parsed. false a safer subset is used.

$wgLaTexCommand  = "C:\\cygwin64\\bin\\pdftex.exe";
$wgDvipsCommand  = "C:\\cygwin64\\bin\\dvips.exe";

# End Math 2.4 configuration

5. Now run the update.php to add the database changes.
Note: There are LaTeX/MathML GUI equation editors available where you can create a complex mathematical equation and the equivalent LaTeX or MathML script is produced.

this solution works well --MarkYin

This is certainly unclear for me also.

1º for Cygwin new users. What packages do we need to install those 3 programs? As i am not pretty sure what to do when i type for example "Latex" and i have 9 packages in there, or when i type "dvipng" and nothing appears.

2º How to compile Math\math and Math\texvccheck? --Maiser

Please see math/README to configure. in /var/www/wiki/extensions/Math/MathInputCheckTexvc.php on line 65

I found this error in my php error log:

[14-Apr-2015 02:17:50 America/New_York] PHP Notice:  Missing <code>texvccheck</code> executable. Please see math/README to configure. in /var/www/wiki/extensions/Math/MathInputCheckTexvc.php on line 65

Looking around the web, I found numerous other wikis with the same error.

It is fixed by compiling the texvccheck extension:

# cd /var/www/wiki/extensions/Math/texvccheck
# make

Haribo~mediawikiwiki (talk) 06:04, 4 May 2015 (UTC)

Thanks. That did the trick at our wiki, too. Thanks for sharing. Dennisroczek (talk) 16:18, 24 September 2015 (UTC)

A lot of errors

Hi there, I get a lot of errors when I'm using the math extension. I was able to solve some issues on my own, but there are still some left.

http://www.mediawiki.org/wiki/Extension:Math Was the installation guide I used.

I tried all of this: http://www.mediawiki.org/wiki/Manual:Troubleshooting_math_display_errors#.22Failed_to_parse_.28PNG_conversion_failed.3B_check_for_correct_installation_of_latex.2C_dvips.2C_gs.2C_and_convert.29.22

But it didn't work at all. I still get the message "Failed to parse (PNG conversion failed; check for correct installation of latex, dvips, gs, and convert)" and another message which tells me that a command was unknown.

Any Idea what I could still do?

Mediawiki version is 1.24.1

REL_1.25 doesn't work with MediaWiki 1.25!

Just an FYI: The commit tagged REL_1.25 doesn't work with MediaWiki 1.25.1; the extension uses a logging API (MWLoggerFactory) that was renamed before MW 1.25 was released. Current HEAD isn't playing nice with VisualEditor; I had to go back to 81dbee82 to get a version that worked.

MW 1.25 is complaining about extension.json. I was not able to install it on MW 1.25.

<Note: I had this same issue, loaded the latest development version and it worked>

MathJax removed

See phabricator:T99369. Please update the page to say that the latest version has no MathJax and how people can install a version before its removal if they so desire. --Nemo 19:28, 20 July 2015 (UTC)

Done, if only roughly. --Rob Kam (talk) 11:08, 21 July 2015 (UTC)
I tweaked a bit. Sad to see this go. Now we have the schizoid mathoid which is not even documented. --[[kgh]] (talk) 09:10, 27 July 2015 (UTC)

How to get VisualEditor to render math in real time?

I just installed VisualEditor and Math in a wiki. However, the behavior is not the same as in Wikipedia, where after you have entered a math formula it is rendered and displayed on the editable surface. Instead, my installation shows the <math>formula</math> that makes up the image.

Does anybody know what could be going on?

I also have this problem. Anyone? -- 20:13, 23 June 2016 (UTC)
It seems like a bug. Until they fix this, you can use this workarround replacing all content from extensions/Math/modules/ve-math/ve.ce.MWMathNode.css:
 * Hide math tag completely to avoid extra bounding boxes for Chrome, Safari, Android...
 * Browser-specific hacks are bad but let's use that for now...
 * See http://browserhacks.com
@media screen and (-webkit-min-device-pixel-ratio:0) {
	.ve-ce-mwMathNode .mwe-math-mathml-a11y {
		display: none !important;
	/* Default style for the image fallback. */
	/* Note: We had to use !important rules because of conflicts with the style
	   generated by Mathoid. See https://gerrit.wikimedia.org/r/#/c/166213/ */
	.mwe-math-fallback-image-inline { display: inline-block; vertical-align: middle; }
	.mwe-math-fallback-image-display { display: block; margin-left: auto !important; margin-right: auto !important; }

	/* Default style for the source fallback. */
	.mwe-math-fallback-source-inline { display: inline; vertical-align: middle; }
	.mwe-math-fallback-source-display { display: block; margin-left: auto; margin-right: auto; }

@-moz-document url-prefix() { .mwe-math-mathml-a11y { display: unset !important }
--Mths0x5f (talk) 02:04, 24 June 2016 (UTC)---~~

Math function revert to text after going to visual editor?

I have the math function working in the standard wikipedia text editor. But, the next time when i use visual editor, the math function got reverted back to text as such [math]]I= 1.5 \cdot I_{rated} = 0 [/math] What can i do to prevent this from happening?

Extension talk:Math/Roadmap#inline vs. blockstyle

see above--Debenben (talk) 18:22, 29 November 2015 (UTC)

Impossible to make Math work with latest MW (1.26.2) on shared hosting


After upgrading MW from 1.22 to 1.26 I spent hours trying to make the Math extension work. With no success.

The documentation is completely outdated and confusing. Different articles ([1], [2], [3], [4], [5], [6]) say different things and apparently about different versions. It also seems that some big changes have been made to the extension code lately without keeping backward compatibility.

Check this quote from https://www.mediawiki.org/wiki/Extension:Math/Roadmap : " The Math extension (or, more broadly, the rendering of the <math> tag) has a long history. It has been modified by a number of different people with different goals, different ideas, and different and programming styles, using different underlying technologies. As a result, the extension's current implementation is more a grown than a well-designed or -documented structure. "

The currently available installation instructions seemed promising (mentioning a relatively recent version of MW (1.23)), but simply downloading math, adding the "require_once" directive to LocalSettings.php and running the update script - as instructed in such page - are clearly not enough to make it work.

In my case, I was stuck when trying to compile texvc (never mentioned on the installation instructions, btw) on a shared host without OCaml (note: I bet most shared-host installations can't meet these requirements). Couldn't find an alternative or a workaround for this.


Rbirmann (talk) 03:22, 29 December 2015 (UTC)

Amen. -- 00:21, 7 January 2016 (UTC)
I have exactly the same problem trying to get the Math extension working on shared hosting with MW 1.24, I don't even have access to make - this is a major issue! --Eboyle1 2016 (talk) 11:48, 15 January 2016 (UTC)
One workaround is mentioned at https://www.mediawiki.org/wiki/Extension:Math/advancedSettings#On_a_shared_host_with_a_limited_shell_access, basically compile texvc on a local version of the shared hosting OS version (presumably Linux) and then upload to your shared hosting server - not an ideal solution, but it might work. --Eboyle1 2016 (talk) 12:11, 15 January 2016 (UTC)
Sorry but the documentation is only as good as you make it. If it's not good enough then re-write it yourself, nobody else will.
The Wikimedia Foundation supports its own powerful expensive hosting. It's just fortunate that it mostly still runs on shared hosting. Shared hosting isn't actively supported by the developers, outside users have to find their own solutions. Use Extension:SimpleMathJax instead of Math.
--Rob Kam (talk) 12:05, 15 January 2016 (UTC)
Extension:SimpleMathJax worked for me on shared hosting and might be a good alternative, thanks Rob Kam --Eboyle1 2016 (talk) 12:27, 15 January 2016 (UTC)
Extension:SimpleMathJax worked great for me as well. Rob Kam, thanks for that. As for "the documentation is only as good as you make it" - true, but here is where we would start discussing bad docs before changing it, so....... Anyway.. I would add a link to SimpleMathJax to the extension page, but you beat me at that ;) Thanks again. Rbirmann (talk) 21:30, 18 January 2016 (UTC)

Not for shared hosting

There ought to be a warning that if you're using shared hosting don't waste your time trying to install this extension. Rob Kam (talk) 15:05, 23 February 2016 (UTC)

Try switching on the mathml mode. From what I can tell it shouldn't need further configuration. -- Prod (talk) 20:27, 27 February 2016 (UTC)

Find pages with math formulas

Is there an easy way to find pages where there are math formulas? Perhaps something similar to Extension:GraphViz's tracking category or Extension:DynamicPageList3's tracking template? -- Prod (talk) 17:21, 28 February 2016 (UTC)

It depends on what you consider to be easy;-) You could use the build in search insource:/\<math/ or if you are importing a d dump you can use https://github.com/physikerwelt/wikiFilter
More complicated is Extension:MathSearch. Maybe you can explain what you are trying to do? --Physikerwelt (talk) 17:02, 7 March 2016 (UTC)
On a 3rd party wiki, I'd like to be able to find instances of math usage to validate things are working. We using the default mediawiki search functionality, so insource doesn't seem to work. -- Prod (talk) 17:40, 7 March 2016 (UTC)

Description update

When will be the extension page be updated to reflect 1.26.x changes?

What is the relationship between $wgMathFullRestbaseURL and mathoid, exactly?

If we set up mathoid, what do we do with $wgMathFullRestbaseURLto make it actually work? What do we put?

Given that this extension does not work without either of these, this seems... important. -— Isarra 00:00, 17 April 2016 (UTC)

Math REL-1_23 with MW1.23LTS on Windows with ImageMagick, MikTeX, GhostScript and class LatexRender

The math extension in MW1.23 replaces the file math.php from the includes directory in older MW versions like 1.16. For using ImageMagick/MikTeX/GhostScript on Windows instead of Texvc there was a file Math.php with class LatexRender for older MW versions.

The math extension REL-1_23 has no exe files for texvc and texvccheck, so there will occur errors on Windows systems. A way could be to use a modified file math.php with class LatexRender instead of compiling exe files. Three files have to be modified:

  • Math.php with class LatexRender from older MediaWiki version
  • Math.php from extension Math
  • MathRenderer.php from extension Math

All files with AutoLoadClasses of the Math extension are named like "Math..." so the modified file Math.php with class LatexRender from Benjamin Zeiss, 2003, should be called MathLatexRender.php with a class MathLatexRender and should be stored in the extensions directory "Math". All Changes are described below.

Add in file Math.php of extension Math, for example between line 191 and 192:


Change the new object creation from MathTexvc to MathLatexRender in file MathRenderer.php below "default", line 123:

$renderer = new MathLatexRender( $tex, $params ); #$renderer = new MathTexvc( $tex, $params );

In file MathLatexRender.php instead of functions LatexRender(...) in class LatexRender and renderMath(...) in class MathRenderer a new function __constructor(...) and only the class MathLatexRender should be used. Class MathLatexRender extends class MathRenderer like other classes of the Math extension. Changes:

  • Rename class LatexRender to MathLatexRender extending class MathRenderer
  • Constructor function __constructor(...)
  • Delete or set as comment function LatexRender(...)
  • Delete class MathRenderer
  • Since MathLatexRenderer is a subclass of MathRenderer there has to be a new function render().
  • For newer PHP versions in function "htmlentities(...)" use parameters for XHTML and UTF-8 or what you need
  • The variables $url and $text should be set to class variables.
  • To prevent warnings in case of trying to delete non-existing files in function cleanTemporaryDirectory() a file check should be added.
  • In function renderLatex() a file check should be added, too.
 * LaTeX Rendering Class
 * Copyright (C) 2003  Benjamin Zeiss <e-mail address removed in Extension_talk:Math>
 * -----------------------------------------------------------------------
 * Changed to MathLatexRender Class for HAWK HHG by Gunnar Werner 2016
 * to be used with MW 1.23 LTS and extension Math REL-1_23...
 * for Windows with GhostScript+ImageMagick+MikTeX instead of Texvc
 * Notice 1: In file Math.php loading this class has to be added:
 * $wgAutoloadClasses['MathLatexRender'] = $dir . 'MathLatexRender.php';
 * Notice 2: In file MathRenderer.php new default object $renderer has to be changed:
 * $renderer = new MathLatexRender( $tex, $params ); #$renderer = new MathTexvc( $tex, $params );
 * -----------------------------------------------------------------------
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * @author Benjamin Zeiss <e-mail address removed in Extension_talk:Math>
 * => @author Gunnar Werner for HAWK HHG <e-mail address removed in Extension_talk:Math>
 * @version v0.8 => v0.8.2016.05
 * @package latexrender => class MathLatexRender for extension Math

// "extends MathRenderer" new by changes 2016
class MathLatexRender extends MathRenderer {
  // new by changes 2016
  var $url = "";
  var $text = "";
  /* function replaced with function __constructor() below by changes 2016
  function LatexRender($picture_path,$picture_path_httpd,$tmp_dir) {
  // new constructor combining old function LatexRender()
  // and function renderMath() from old class MathRenderer
  // by changes 2016
  public function __construct ($latex_formula, $params = array() ) {
    global $wgMathDirectory,

    $latex_formula = '\displaystyle ' . $latex_formula;

    // from old function LatexRender()
    $this->_picture_path = $wgMathDirectory;
    $this->_picture_path_httpd = $wgMathPath;
    $this->_tmp_dir = $wgTmpDirectory;
    $this->_tmp_filename = md5(rand());

    // check Math dir

    // Objects $latex and $url replaced with $this by changes 2016
    $this->_latex_path = $wgLaTexCommand;
    $this->_dvips_path = $wgDvipsCommand;
    $this->_convert_path = $wgImageMagickConvertCommand;
    $this->_identify_path = $wgImageMagickIdentifyCommand;

    $this->url = $this->getFormulaURL($latex_formula);

    // htmlentities for newer PHP versions changed 2016
    $alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES|ENT_XHTML, "UTF-8");
    $alt_latex_formula = str_replace("\r", "", $alt_latex_formula);
    $alt_latex_formula = str_replace("\n", "", $alt_latex_formula);
    $alt_latex_formula = str_replace('\displaystyle ', "", $alt_latex_formula);

    if($this->url != false){
      $this->text = '<img src="'.$this->url.'" title="'.$alt_latex_formula.'" alt="'.$alt_latex_formula.'" />';
      $this->text = '[Unparseable or potentially dangerous latex formula. Error '.$this->_errorcode.' '.$this->_errorextra.']';
  // new for abstract function in "MathRenderer.php" by changes 2016
  public function render(){
    return $this->text."\n";
  function renderLatex($latex_formula) {
    // create temporary dvi file
    $status_code = exec($command);
    // added checking file by changes 2016
    if (!$status_code || !file_exists($this->_tmp_filename.".dvi")) {
      $this->_errorcode = 4;
      return false;
  function cleanTemporaryDirectory() {
    // check existence before deleting to prevent warnings added by changes 2016
    $file_types = array("tex", "aux", "log", "dvi", "ps", $this->_image_format);
    foreach($file_types as $f_typ){
      $tmp_file = $this->_tmp_dir."/".$this->_tmp_filename.".".$f_typ;
      $tmp_file = "";


MathLatexRender.php Quelltext als pdf-Datei

— Preceding unsigned comment added by G Wer (talkcontribs) 08:05, 9 May 2016

Nothing shows up after saving the page

I just set up the math extension and tried to test it with <math>{\vec{F}=m\vec{a}}</math>. Nothing shows up when saved. The MathStatus page shows the following two errors:

  • Test Comparing the generated SVG with the reference failed.
  • Test Checking if the link to SVG image is correct failed.

(Returned string has mode=mathml' and the expected string has a mode=5).

What's the issue here? How do I fix this?

— Preceding unsigned comment added by KarthikeyanKC (talkcontribs) 07:17, 14 May 2016


I know this is not productive, but documentation is shit. How is it possible that the variables that Math is using are not properly documented? I could continue, but.....

— Preceding unsigned comment added by (talkcontribs) 07:02, 7 June 2016

Problem installing on MediaWiki 1.27

I have installed Math extension on current MediaWiki version (1.27). In LocalSettings.php I have:

wfLoadExtension( 'Math' );
$wgMathValidModes[] = 'mathml';
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathFullRestbaseURL = 'https://api.formulasearchengine.com/';

But rendering formulas fails, instead I have the following results:

Test: ?'"`UNIQ--postMath-00000004-QINU`"'?


The source for the code is:


z        & = & a \\
f(x,y,z) & = & x + y + z  

When wisiting Special:MathStatus, the results are:

Math status
This page displays information about the enabled math rendering modes.
The following rendering modes are enabled:
PNG images
LaTeX source (for text browsers)
MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools)
Running backend tests for rendering mode MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools).
Test Rendering the input "x^2+\text{a sample Text}" succeeded.
Test Comparing to the reference rendering succeeded.
Test Rendering of a+b in plain MathML mode succeeded.
Test Checking the presence of '+' in the MathML output succeeded.
Test Comparing the generated SVG with the reference failed.
Test Checking if MathML input is supported succeeded.
Test Rendering Presentation MathML sample succeeded.
Test Checking if the link to SVG image is correct succeeded.
Backend tests for rendering mode MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools) completed. 

Is it a server (https://api.formulasearchengine.com/) problem, or something is wrong with my installation?

— Preceding unsigned comment added by DBobak (talkcontribs) 09:27, 24 September 2016