3 texvc takes LaTeX-compatible equations and produces formatted output in HTML,
4 MathML, and (via LaTeX/dvipng) rasterized PNG images.
5 Input data is parsed and scrutinized for safety, and the output includes an
6 estimate of whether the code is simple enough that HTML rendering will look
9 The program was written by Tomasz Wegrzanowski for use with MediaWiki; it's
10 included as part of the MediaWiki package (http://www.mediawiki.org) and is
11 under the GPL license.
13 Please report bugs at: https://bugzilla.wikimedia.org/ (under "MediaWiki")
19 OCaml 3.06 or later is required to compile texvc; this can be acquired from
20 http://caml.inria.fr/ if your system doesn't have it available.
22 The makefile requires GNU make.
24 Rasterization is done via LaTeX, dvipng. These need to be installed and in
25 the PATH: latex, dvipng
27 AMS* packages for LaTeX also need to be installed. Without AMS* some equations
28 will render correctly while others won't render. Most distributions of TeX
29 already contain AMS*. In Debian/Ubuntu you need to install tetex-extra.
31 To work properly with rendering non-ASCII Unicode characters, a supplemental TeX
32 package is needed (cjk-latex in Debian)
36 Run 'make' (or 'gmake' if GNU make is not your default make). This should
37 produce the texvc executable.
39 Then you'll need to set $wgUseTeX to true in your LocalSettings.php. By default,
40 MediaWiki will search in this directory for texvc, if you moved it elsewhere,
41 you'll have to modify $wgTexvc and set it to the path of the texvc executable.
45 Normally texvc is called from MediaWiki's Math.php modules and everything
46 Just Works. It can be run manually for testing or for use in another app.
48 === Command-line parameters ===
50 texvc <temp directory> <output directory> <TeX code> <encoding>
52 Be sure to properly quote the TeX code!
56 texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1
60 Status codes and HTML/MathML transformations are returned on stdout.
61 A rasterized PNG file will be written to the output directory, named
62 for the MD5 hash code.
64 texvc output format is like this:
65 +%5 ok, but not html or mathml
66 c%5%h ok, conservative html, no mathml
67 m%5%h ok, moderate html, no mathml
68 l%5%h ok, liberal html, no mathml
69 C%5%h\0%m ok, conservative html, with mathml
70 M%5%h\0%m ok, moderate html, with mathml
71 L%5%h\0%m ok, liberal html, with mathml
72 X%5%m ok, no html, with mathml
75 F%s unknown function %s
79 %5 - md5, 32 hex characters
80 %h - html code, without \0 characters
81 %m - mathml code, without \0 characters
86 Unforunately, many error conditions with rasterization are not well reported.
87 texvc will return as though everything is successful, and the only obvious
88 sign of problems for the user is a big X on a wiki page where an equation
91 Try running texvc from the command line to ensure that the software it relies
94 Ensure that the temporary and math directories exist and can be written to by
95 the user account the web server runs under; if you don't control the server,
96 you may have to make them world-writable.
98 If some equations render correctly while others don't, you probably don't have
99 AMS* packages for LaTeX installed. Most distributions of TeX come with AMS*.
100 In Debian/Ubuntu AMS* is in tetex-extra package.
101 To check if that is the problem you can try those two equations:
104 The first uses only standard LaTeX, while the second uses symbol \implies from AMS*.
105 If the first renders, but the second doesn't, you need to install AMS*.
109 Before you start hacking on the math package its good to know the workflow,
112 1. texvc gets called by includes/Math.php (check out the line begining with "$cmd")
113 2. texvc does its magic, which is basically to check for invalid latex code.
114 3. texvc takes the user input if valid and creates a latex file containing it, see
115 get_preface in texutil.ml
116 4. dvipng(1) gets called to create a .png file
117 See render.ml for this process (commenting out the removal of
118 the temporary file is useful for debugging).