Like many others, I have just been through considerable pain getting the TeX filter to run on Windows and I'd like to post my findings for the sake of anyone else in this unfortunate position. Most, though not all, of the problems involved user permissions or spaces in file paths.
The applications I've been using are:
Windows Server 2003 (Standard Edition)
IIS 6.0
Moodle 1.9.3+ (Build: 20081126)
PHP 5.1.5
IE 6.0
mimeTeX 1.40 (I think)
MikTeX 2.7
Ghostscript 8.6.3
ImageMagick 6.4.9-3 Q16 (2009-02-01)
Most of my efforts were focussed on getting LaTeX (in the form of MikTek) to run as opposed to mimeTeX (which comes with Moodle). For the record, the last 3 applications on the list above perform the necessary file conversions:
MikTeX: .tex -> .dvi
Ghostscript: .dvi -> .ps
ImageMagick: .ps -> .gif
Ghostscript runs from inside MikTeX through dvips.exe.
The following procedure got both the TeX filter and the TeX filter debugger working for me:
STEP 1: Install MikTeX, Ghostscript and ImageMagick
As you might know, they are all downloadable, free, from the relevant web sites. To avoid some of the steps below you may want to install these into file paths that have no spaces.
STEP 2: Enable the TeX Notation filter
Go to Moodle Administration > Modules > Manager filters and click the closed eye next to TeX Notation.
STEP 3. Input the LaTeX renderer settings
Go to Moodle Administration > Modules > TeX Notation and add the latex, dvips and convert paths. If you used the default installation paths these will be:
C:\Program Files\MiKTeX 2.7\miktex\bin\latex.exe
C:\Program Files\MiKTeX 2.7\miktex\bin\dvips.exe
C:\Program Files\ImageMagick-6.4.9-Q16\convert.exe
Press Save changes. If the paths exist, the borders of the little boxes next to them will turn green. Otherwise, they will turn red. Don't put double quotes around the path names as seemingly suggested by the default paths.
You might also like to add \usepackage{amssymb} to the LaTeX preamble to enlarge your symbol set.
STEP 2: Turn on the Moodle debugger
Go to Administration > Server > Debugging and set 'Debug messages' to DEVELOPER. This allows command execution output to display in the TeX filter debugger.
STEP 4: Open the TeX filter debugger
The URL is http://../filter/tex/texdebug.php. If Test 3, 4 or 5 in the debugger produce 'Unable to fork' errors you'll need STEP 5.
STEP 5: Grant permission for the Internet Guest User to use the command function
On your Windows server, go to C:\WINDOWS\system32 and right-click cmd.exe. Choose Properties > Security. Click Add, then Advanced and Find Now. Select the IUSR name and click OK. Grant it Read & Execute permission and click OK.
If you go back to the TeX filter debugger and do Tests 3, 4 or 5 you should find that the 'Unable to fork' errors have gone away. In fact, mimetex (Test 3) should now be working - or at least showing positive signs of life.
STEP 6: Grant permission for the Internet Guest User to use the WINDOWS Temp folder
Go to C:\WINDOWS and right-click Temp. Choose Properties > Security. Add the IUSR user, as before, and grant it permission to Read and Write. This allows ImageMagick to dump temporary files in there while it's doing its stuff.
STEP 7: Edit the texdebug.php file
Open filter\tex\texdebug.php with your favourite editor, e.g. Dreamweaver or Notepad++, and make the following changes:
(i) Add a -q option to the dvips command to make it run quietly, i.e.,
change line 239 in the TexOutput function
from: $cmd = "$CFG->filter_tex_pathdvips -E $dvi -o $ps";
to: $cmd = "$CFG->filter_tex_pathdvips -q -E $dvi";
The output file directive (-o $ps) is redundant so you can remove it if you want.
(ii) Remove the header in the outputTex function, i.e.
comment out line 105:
header("Content-type: text/html");
to stop debugger Test 6 (Check slasharguments setting) producing a warning
If you have no spaces in your latex/dvips/convert file paths all the tests in the TeX filter debugger should now work (though you may find there are certain TeX symbols you can't display, e.g. Bigint). Otherwise:
(iii) Put double quotes around the latex/dvips/convert paths to cope with any spaces, i.e., in the TexOutput function, change line 235
from: $cmd = "$CFG->filter_tex_pathlatex --interaction=nonstopmode $tex";
to: $cmd = "\"$CFG->filter_tex_pathlatex\" --interaction=nonstopmode $tex";
change line 239
from: $cmd = "$CFG->filter_tex_pathdvips -q -E $dvi";
to: $cmd = "\"$CFG->filter_tex_pathdvips\" -q -E $dvi";
change line 243
from: $cmd = "$CFG->filter_tex_pathconvert -density 240 -trim $ps $gif ";
to: $cmd = "\"$CFG->filter_tex_pathconvert\" -density 240 -trim $ps $gif ";
Whether or not you have spaces in your file paths, the TeX filter debugger should now work. If the expression you've entered is okay, it should render beautifully in TeX when you run Test 4 (Show graphic image with Tex/Ghostscript). And if you run Test 5 (Show command execution output..) latex, dvips and convert should all show RETURN CODE: 0.
STEP 8: Edit the latex.php file
This time open filter\tex\latex.php. The changes needed are similar to those in STEP 7.
(i) Add a -q option to the dvips command to make it run quietly, i.e.,
change line 121 in the render function
from: $command = "{$CFG->filter_tex_pathdvips} -E $dvi -o $ps";
to: $command = "{$CFG->filter_tex_pathdvips} -q -E $dvi";
The output file directive (-o $ps) is redundant so you can remove it if you want.
(ii) Line 116 states that latex always returns False on Windows. This is not true, so you can uncomment the next 'return false;' line if you like. What is true is that it will sometimes return false if it doesn't totally like the look of the TeX, but still have a go at rendering it anyway (so you might want to allow this and exclude the 'return false' after all).
If you have no spaces in your latex/dvips/convert file paths the TeX filter should now work. Otherwise:
(iii) Replace the curly brackets in the latex/dvips/convert paths with double quotes, i.e., in the render function, change line 114
from:$command = "{$CFG->filter_tex_pathlatex} --interaction=nonstopmode $tex";
to: $command = "\"$CFG->filter_tex_pathlatex\" --interaction=nonstopmode $tex";
change line 121
from: $command = "{$CFG->filter_tex_pathdvips} -q -E $dvi";
to: $command = "\"$CFG->filter_tex_pathdvips\" -q -E $dvi";
change line 132
from: $command = "{$CFG->filter_tex_pathconvert} -density $density -trim $bg_opt $ps $gif";
to: $command = "\"$CFG->filter_tex_pathconvert\" -density $density -trim $bg_opt $ps $gif";
Whether or not you have spaces in your latex/dvips/convert file paths the TeX filter should now work. Try it out somewhere, e.g. in a Forum.
Further comments:
1. Moodle puts the temporary files associated with latex in the moodledata\temp\latex folder and those associated with mimetex in the moodledata\filter\tex folder, so you can watch them coming and going there if you want.
2. When I enter TeX into a forum reply or post I can't get it to display after posting without refreshing the page. If anyone has solved this problem I'd be happy to hear from them.
3. I'm not sure yet how I feel about loosening the Windows permissions as above. If anyone would like to comment on the risks involved I'd be glad to hear about that too.
I'm hoping most of the TeX filter pain now lies behind me, but having read some of the other posts on this forum I wouldn't bet on it!
Alyson