## Math MediaWiki extension with Texvc problem.

This puzzled me for a while. My math was rendered as $Hard to understand math goes here$ instead of a nice png. I don’t fully understand the problem but made it work anyway by hacking the Math extension sources.

First to make it work texvc must be installed (obviously). You must be able to run it as your web server (whatever that account is running on). So far the obvious part. Now you have to add the following to your LocalSettings.php in the root wiki dir in this order:

$wgMathValidModes[] = array( MW_MATH_MATHJAX, MW_MATH_PNG, MW_MATH_SOURCE ); // Define MathJax as one of the valid math rendering modes$wgUseMathJax = false; // Enable MathJax as a math rendering option for users to pick $wgDefaultUserOptions['math'] = MW_MATH_SOURCE; // Set MathJax as the default rendering option for all users (optional)$wgMathDisableTexFilter = true; // or compile "texvccheck" $wgUseTeX = true;$wgTexvc = '/usr/bin/texvc'; $wgUploadDirectory= "upload";$wgUploadPath = "upload"; $wgMathPath = "{$wgUploadPath}/math"; $wgMathDirectory = "{$wgUploadDirectory}/math"; $wgTmpDirectory = "{$wgUploadDirectory}/tmp"; $wgShowSQLErrors = 1; require_once "$IP/extensions/Math/Math.php";

Make sure the directories are created under your root wiki install so if the LocalSettings.php are in /home/wiki/ then there should be a dir

• /home/wiki/upload
• /home/wiki/upload/math and
• /home/wiki/math/tmp

(you can of course use other locations to make it more difficult to get it working 🙂 ).

Now for some reason the tmpDir ad wgTexvc don’t make it into the following file (don’t ask me why) or maybe tmpDir is not defined altogether. So I just hardcoded them (don’t forget to redo it if it works and you do an upgrade some time in the future). Update extensions/Math/MathTexvc.php as follows:

 public function callTexvc() { global $wgTexvc,$wgTexvcBackgroundColor, $wgHooks;$wgTexvc="/usr/bin/texvc"; wfProfileIn( __METHOD__ ); $tmpDir = wfTempDir(); if ( !is_executable($wgTexvc ) ) { wfDebugLog( 'texvc', "$wgTexvc does not exist or is not executable." ); wfProfileOut( __METHOD__ ); return$this->getError( 'math_notexvc' ); } $tmpDir="/tmp"; Then finally they appeared in the preview. But unfortunately my wiki is not in the root of the website and it didn’t use the complete URL in the final pages as it does in the preview. This can be solved as follows in MathTexvc.php. I just hardcoded (again) the prefix. return Xml::element( 'img',$this->getAttributes( 'img', $attributes, array( 'src' => "/mydir/mywiki/".$url

After that my png’s appear nicely in my wiki, great.

Hopes this helps someone out there.