Difference between revisions of "Enabling math markup"

From Organic Design wiki
(formatting)
m
Line 6: Line 6:
 
{{info|Use this procedure to add math rendering support which is not included in the [[install a new server]] procedure by default as it requires many additional program libraries (about 200MB worth)}}
 
{{info|Use this procedure to add math rendering support which is not included in the [[install a new server]] procedure by default as it requires many additional program libraries (about 200MB worth)}}
  
 
+
== Build the texvc binary ==
Enabling math markup requires latex, dvips, gs, and convert.
+
Enabling math markup requires latex, dvips, gs, and convert. OCaml 3.06 or later from [http://caml.inria.fr caml.inria.fr] is required to compile ''texvc''. On Debian-based systems the requirements can be installed with the following packages:
 
 
The file in path {$IP}/math/README explains how to compile ocmal and texvc. You can run an example from the command line
 
 
{{code|<pre>
 
{{code|<pre>
texvc <temp directory> <output directory> <TeX code> <encoding>
+
apt-get install dvipng tetex-extra cjk-latex ocaml
 
</pre>}}
 
</pre>}}
 
+
*Run ''make'' from within the MediaWiki's ''math'' directory to build the ''texvc'' binary on your system.
 +
*Make sure the directories ''tmp'' and ''math'' under 'images' exist and are writable.
  
 
e.g.  
 
e.g.  
 
{{code|<pre>
 
{{code|<pre>
texvc /Library/WebServer/Documents/mediawiki-biodev3-1.14.0/images/tmp \
+
texvc /Library/WebServer/Documents/mediawiki-biodev3-1.14.0/images/tmp \
 
       /Library/WebServer/Documents/mediawiki-biodev3-1.14.0/images/math "y=mc+c" iso-8859-1
 
       /Library/WebServer/Documents/mediawiki-biodev3-1.14.0/images/math "y=mc+c" iso-8859-1
 
</pre>}}
 
</pre>}}
Line 34: Line 33:
 
}}
 
}}
  
== Build the texvc binary ==
+
== LocalSettings.php changes ==
OCaml 3.06 or later from [http://caml.inria.fr caml.inria.fr] is required to compile ''texvc''
+
{{code|<php>
{{code|<pre>
+
$wgEnableUploads      = true;  # Change to allow uploads
apt-get install dvipng tetex-extra cjk-latex ocaml
 
</pre>}}
 
  
Run ''make'' from within the MediaWiki's ''math'' directory to build the ''texvc'' binary on your system.
+
$wgUploadDirectory  = "{$IP}/images";
 
+
$wgUploadPath      = "{$wgScriptPath}/images";
Make sure the directories ''tmp'' and ''math'' under 'images' exist and are writable.
+
$wgUseTeX          = true;
 
+
$wgMathPath        = "{$wgUploadPath}/math";
== LocalSettings.php customization ==
+
  $wgTexvc            = "{$IP}/math/texvc"; # Path to compiled texvc
The following lines need to be added;
+
$wgMathDirectory    = "{$wgUploadDirectory}/math";
{{code|<PHP>
+
$wgTmpDirectory     = "{$wgUploadDirectory}/tmp";
$wgUseTex = true;             # and
+
</php>}}
$wgTexvc  = 'usr/bin/texvc'# alternative location from 'sudo apt-get install mediawiki-math' installation
 
$wgMathDirectory = "$IP/images/math"; # optional
 
</PHP>
 
}}
 
 
 
== Transparency (not working on current versions) ==
 
The ''/wiki/math/render.ml'' script has notes about swtches that can be added to the ''convert'' and ''dvips'' commands to give transparency, but these images will not work correctly in Microsoft browsers prior to IE7. After making changes to ''render.ml'', you must rebuild the ''texvc'' executable by issuing a '''make clean && make'''.
 
 
 
For older codebases, we used the following ''render.ml'' hack instead.
 
{{code|<pre>
 
let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 480 " \
 
     ^ tmpprefix ^ ".ps -negate -unsharp 8 -resize 25% " ^ finalpath ^ " >/dev/null 2>/dev/null \
 
    && convert " ^ finalpath ^ " -fill black -colorize 100% " ^ finalpath ^ ".png \
 
    && composite -compose CopyOpacity " ^ finalpath ^ " " ^ finalpath ^ ".png " ^ finalpath
 
</pre>}}
 
  
 
== OSX Specific installation ==
 
== OSX Specific installation ==
Line 79: Line 61:
 
</pre>
 
</pre>
 
Now compile texvc with '''make''' to create a texvc executable that knows where the locations of the components are.
 
Now compile texvc with '''make''' to create a texvc executable that knows where the locations of the components are.
 
== LocalSettings.php changes ==
 
{{code|<php>
 
$wgEnableUploads      = true;  # Change to allow uploads
 
 
$wgUploadDirectory  = "{$IP}/images";
 
$wgUploadPath      = "{$wgScriptPath}/images";
 
$wgUseTeX          = true;
 
$wgMathPath        = "{$wgUploadPath}/math";
 
$wgTexvc            = "{$IP}/math/texvc";  # Path to compiled texvc
 
$wgMathDirectory    = "{$wgUploadDirectory}/math";
 
$wgTmpDirectory    = "{$wgUploadDirectory}/tmp";
 
</php>}}
 
  
 
== See also ==
 
== See also ==

Revision as of 07:49, 5 August 2010

Procedure.svg Enabling math markup
Organic Design procedure
Info.svg Use this procedure to add math rendering support which is not included in the install a new server procedure by default as it requires many additional program libraries (about 200MB worth)


Build the texvc binary

Enabling math markup requires latex, dvips, gs, and convert. OCaml 3.06 or later from caml.inria.fr is required to compile texvc. On Debian-based systems the requirements can be installed with the following packages:

apt-get install dvipng tetex-extra cjk-latex ocaml
  • Run make from within the MediaWiki's math directory to build the texvc binary on your system.
  • Make sure the directories tmp and math under 'images' exist and are writable.

e.g.

texvc /Library/WebServer/Documents/mediawiki-biodev3-1.14.0/images/tmp \
       /Library/WebServer/Documents/mediawiki-biodev3-1.14.0/images/math "y=mc+c" iso-8859-1

Example

The following maths code

<math>
e^x = \sum_{n = 0}^{\infty} {x^n \over n!} = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + \cdots
</math>

Should give the following output

[math]e^x = \sum_{n = 0}^{\infty} {x^n \over n!} = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + \cdots[/math]

LocalSettings.php changes

{{{1}}}

OSX Specific installation

  • Modify the file render.ml to include the full absolute paths to latex, dvips convert etc.
let cmd_dvips tmpprefix = "/usr/local/teTeX/bin/powerpc-apple-darwin-current/dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
      2 let cmd_latex tmpprefix = "/usr/local/teTeX/bin/powerpc-apple-darwin-current/latex " ^ tmpprefix ^ ".tex >/dev/null"
      3 (* Putting -transparent white in converts arguments will sort-of give you transperancy *)
      4 let cmd_convert tmpprefix finalpath = "/usr/local/bin/convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " \
        >/dev/null 2>/dev/nu        ll"
      5 (* Putting -bg Transparent in dvipng's arguments will give full-alpha transparency *)
      6 (* Note that IE have problems with such PNGs and need an additional javascript snippet *)
      7 (* Putting -bg transparent in dvipng's arguments will give binary transparency *)
      8 let cmd_dvipng tmpprefix finalpath = "/usr/local/teTeX/bin/powerpc-apple-darwin-current/dvipng -gamma 1.5 -D 120 -T tight --strict " ^ \
        tmpprefix ^         ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"

Now compile texvc with make to create a texvc executable that knows where the locations of the components are.

See also