Difference between revisions of "Enabling math markup"

From Organic Design wiki
m
(merge from old article which redirects here now)
Line 4: Line 4:
 
|status = in use
 
|status = in use
 
}}
 
}}
{{info|This procedure is only required to be run on platforms which were not installed with the [[install a new server]] procedure as maths markup should already be enabled after running that procedure. Also math markup is enabled in all [[OD/Wikia|Organic Design wikia]] by default too.}}
+
{{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)}}
  
Enabling math markup requires the following binaries [[W:LaTeX|latex]], [[W:dvips|dvips]], [[W:Ghostscript|gs]], and [[W:ImageMagick|ImageMagicks]] convert . These must all be available in $PATH.
+
OCaml 3.06 or later from [http://caml.inria.fr caml.inria.fr] is required to compile ''texvc''
The binary ''texvc'' must also be available, either as a binary or source installation.
+
{{code|<pre>
==Installation of texvc==
+
apt-get install dvipng tetex-extra cjk-latex ocaml
===From source===
+
</pre>}}
#Note: OCaml 3.06 or later is required to compile texvc; this can be acquired from http://caml.inria.fr/ if your system doesn't have it available.'' The apt-get commands <code>apt-get install dvipng tetex-extra cjk-latex ocaml</code> (documented in [[Debian Post Install]]) install OCaml.
 
#Inside each mediawiki instance ./math directory there is a README file which documents the process involved to make an executable from source called ''texvc''. Basically from in the math directory you type <code>make</code> and check that texvc has been compiled.
 
 
 
===Binary===
 
The <code> apt-get install mediawiki-math</code> creates the texvc executable in /usr/local/bin.
 
 
 
 
 
You should then test that it works from the command line for example;
 
 
 
  texvc /tmp /var/www/mediawiki-1.12.0/math "y=x+2" iso-8859-1
 
 
 
should create a file in /var/www/mediawiki-1.12.0/math.
 
  
 +
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.
 
Make sure the directories 'tmp' and 'math' under 'images' exist and are writable.
  
==LocalSettings.php customization==
+
== LocalSettings.php customization ==
 
The following lines need to be added;
 
The following lines need to be added;
 
{{code|<PHP>
 
{{code|<PHP>
$wgUseTex = true;               # and
+
$wgUseTex = true;             # and
$wgTexvc   = 'usr/bin/texvc';  # alternative location from 'sudo apt-get install mediawiki-math' installation
+
$wgTexvc = 'usr/bin/texvc';  # alternative location from 'sudo apt-get install mediawiki-math' installation
 
$wgMathDirectory = "$IP/images/math"; # optional
 
$wgMathDirectory = "$IP/images/math"; # optional
 
</PHP>
 
</PHP>
 
}}
 
}}
  
==See also==
+
== See also ==
 
*[http://www.mwusers.com/forums/showthread.php?t=8168&highlight=math Thread on mwusers]
 
*[http://www.mwusers.com/forums/showthread.php?t=8168&highlight=math Thread on mwusers]
 +
*[[:Category:Articles containing maths|Articles containing maths]]
 +
*There was a problem extracting the database on 13/11 due to duplicate entries in the math table, see [[13 November 2006]].
 +
 +
== Example ==
 +
The following maths code
 +
{{code|<pre><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></pre>}}
 +
 +
Should gives the following output
 +
{{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>}}
 +
 +
== Transparency ==
 +
I replaced the line defining the ImageMagick ''convert'' command in ''/wiki/math/render.ml'' which makes it output a transparent PNG and also increases the quality  by rendering the vector larger and downsizing with the default ''Mitchell'' filter. After making changes to ''render.ml'', you must rebuild the ''texvc'' executable by issuing a ''make clean'' and ''make''.
 +
{{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>}}

Revision as of 10:19, 14 January 2009

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)


OCaml 3.06 or later from caml.inria.fr is required to compile texvc

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.

LocalSettings.php customization

The following lines need to be added;

{{{1}}}

See also

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 gives 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]

Transparency

I replaced the line defining the ImageMagick convert command in /wiki/math/render.ml which makes it output a transparent PNG and also increases the quality by rendering the vector larger and downsizing with the default Mitchell filter. After making changes to render.ml, you must rebuild the texvc executable by issuing a make clean and make.

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