Extension talk:Math/Archive 1

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.

Steps

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.

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 &lt;code&gt;texvccheck&lt;/code&gt; 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:
 * 1) cd /var/www/wiki/extensions/Math/texvccheck
 * 2) 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.



MathJax removed
See 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. --&#91;&#91;kgh&#93;&#93; (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 $$formula$$ that makes up the image.

Does anybody know what could be going on?


 * I also have this problem. Anyone? --189.41.24.14 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:
 * --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
see above--Debenben (talk) 18:22, 29 November 2015 (UTC)

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

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 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 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.

Best,

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


 * Amen. --146.137.70.70 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  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: $wgAutoloadClasses['MathLatexRender.php']

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 &lt;e-mail address removed in Extension_talk:Math&gt; * --- * 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 &lt;e-mail address removed in Extension_talk:Math&gt; * => @author Gunnar Werner for HAWK HHG &lt;e-mail address removed in Extension_talk:Math&gt; * @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, $wgMathPath, $wgTmpDirectory, $wgLaTexCommand, $wgDvipsCommand, $wgImageMagickConvertCommand, $wgImageMagickIdentifyCommand;

$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 if(!file_exists($wgMathDirectory)){@mkdir($wgMathDirectory);} if(!file_exists($wgTmpDirectory)){@mkdir($wgTmpDirectory);}

// 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 = 'url.'" title="'.$alt_latex_formula.'" alt="'.$alt_latex_formula.'" />'; }   else{ $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 /*   unlink($this->_tmp_dir."/".$this->_tmp_filename.".tex"); ...   */    $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; if(file_exists($tmp_file)){ unlink($tmp_file); }     $tmp_file = ""; }

chdir($current_dir); } }



Nothing shows up after saving the page
I just set up the math extension and tried to test it with. 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  and the expected string has a  ).

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

Documentation
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.....

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`"'

'"`UNIQ--postMath-00000005-QINU`"'

The source for the code is: Test: $${\vec{F}=m\vec{a}}$$

$$\begin{array}{lcl} z       & = & a \\ f(x,y,z) & = & x + y + z \end{array}$$

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?