Help with MiKTex, ImageMagick, & Ghostscript on Windows

Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Robert Duncan -
Number of replies: 18
Greetings. I've just installed MikTex, ImageMagick, Ghostscript, and GS View on my server. I'm fumbling around trying to figure out what to put in the "Path of * binary:" blanks in ../filter/tex/config. What I'm not sure of is which files exactly that I need to call. For example, I'm guessing the path the convert binary should be

c:\Program Files\ImageMagick-6.3.1-Q16\ (followed with convert.exe???)

I have no idea what to call out of the MikTex install, but it sounds like the LaTeX and dvips binaries are both somewhere in

c:\Program Files\MiKTeX 2.5\??

Could someone provide me with some "sample settings" so I can go and search out what would be appropriate for my machine?

Also, once configured, how can I tell that LaTeX is being rendered via MiKTex instead of the default mimeTex?

Thanks,

Rob Duncan
Average of ratings: -
In reply to Robert Duncan

Re: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Miha Drenik -
You might want to rename mimetex.exe to something else at least until you get the other renderer working.

I cannot configure the filter through /moodle/admin/filter.php?filter=filter%2Ftex because on 'Save changes' each backslash '\' is saved as double backslash '\\' in the settings, so lets just do this directly in the moodle database. Open the mdl_config table and edit the following...

name:
filter_tex_latexpreamble
value:
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\RequirePackage{amsmath,amssymb,latexsym}

name:
filter_tex_pathlatex
value:
latex

name:
filter_tex_pathdvips
value:
dvips

name:
filter_tex_pathconvert
value:
convert

Save the edited table and add the path to convert.exe to the system path. MikTeX adds the path to latex.exe and dvips.exe on its own. Reboot.
In reply to Miha Drenik

Re: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Jong-Dae Park -

Thanks for your post. But I could not configure for latex to work.

I could configure latex on a mediawiki site. The procedure was a little bit more complicated than suggested here.

http://www.votapedia.com/index.php?title=Supporting_math_in_MediaWiki1.7_on_Windows_2003_and_IIS6

I wonder what should I do to configure correctly.

Thanks in advance.

In reply to Robert Duncan

Re: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Paul Richardson -
Hi Robert
You've probably sorted your problem ages ago but for the record here's some info about how I got up and started using LaTeX for writing "Z". http://www.odg.cc/z
brgds
Paul
In reply to Robert Duncan

Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Morten Brydensholt -

I have now tested latex on my (Windows) IIS server. No doubt you benefit from the better quality of the images rather than using the mimetex filter.

After searching this forum for help and playing around with the database and sql statements I finally just hacked the tex filter to get it to work.

This is how I got it to work:

Install MikTex$$\surd$$

(I picked up version 2.5 basic and the program installed itself in "C:\Program Files\MiKTeX 2.5").

Install Ghostscript$$\surd$$

(I chose GPL Ghostscript 8.56. I also installed GSview 4.8 but I'm not sure if I need this).

Install ImageMagick$$\surd$$

(I chose the binary for Windows: ImageMagick-6.3.3-5-Q16-windows-dll.exe).

I rebooted the server and opened Control panel -> System -> Advanced -> Environment variables -> System variables -> Path and checked that the binaries were known by the server: "C:\Program Files\ImageMagick-6.3.3-Q16;C:\Program Files\MiKTeX 2.5\miktex\bin;...". $$\surd$$

Both latex.exe and dvips.exe are in the MikTex path and convert.exe is in the ImageMagick path.

Now Moodle has to know that a new tex filter is to be used. I tried hard to alter the filter settings and to invoke sql statements to get things rigth but often resulted in putting the server to it's knees (and manually shut down latex.exe using 50% of the servers cpu).

For me the safe way was to hack the Moodle -> filter -> tex -> defaultsetting.php. Make a copy first. One never knows...  $$\surd$$

Change the following in line 10-12:

if (!isset($CFG->filter_tex_latexpreamble) or $force) {

set_config( 'filter_tex_latexpreamble', " \\usepackage[latin1]{inputenc}\n \\usepackage{amsmath}\n \\usepackage{amsfonts}\n \\RequirePackage{amsmath,amssymb,latexsym}\n");

}

with this:

if (!isset($CFG->filter_tex_latexpreamble) or $force) {

set_config( 'filter_tex_latexpreamble', " \\usepackage[latin1]{inputenc}\n \\usepackage{amsmath}\n \\usepackage{amsfonts}\n \\usepackage{amssymb}\n \\RequirePackage{amsmath,amssymb,latexsym}\n");

$$\surd$$

Change the following in line 38-49:

elseif (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') {

// note: you need Ghostscript installed (standard), miktex (standard)

// and ImageMagick (install at c:\ImageMagick)

set_config( 'filter_tex_pathlatex',"\"c:\\texmf\\miktex\\bin\\latex.exe\" " );

set_config( 'filter_tex_pathdvips',"\"c:\\texmf\\miktex\\bin\\dvips.exe\" " );

set_config( 'filter_tex_pathconvert',"\"c:\\imagemagick\\convert.exe\" " );

}

else {

set_config( 'filter_tex_pathlatex','' );

set_config( 'filter_tex_pathdvips','' );

set_config( 'filter_tex_pathconvert','' );

}

With this:

elseif (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') {

// note: you need Ghostscript installed (standard), miktex (standard)

// and ImageMagick (install at c:\ImageMagick)

set_config( 'filter_tex_pathlatex','latex' );

set_config( 'filter_tex_pathdvips','dvips' );

set_config( 'filter_tex_pathconvert','convert' );

}

else {

set_config( 'filter_tex_pathlatex','latex' );

set_config( 'filter_tex_pathdvips','dvips' );

set_config( 'filter_tex_pathconvert','convert' );

$$\surd$$

The blue text is the new settings.

Log on to Moodle and go to the Admin menu -> Modules -> Filters -> Tex Notations Setting and press the button 'Reset to defaults'.  $$\surd$$

Hopefully this works for you too.

Best regards

Morten

 

Attachment tex.gif
In reply to Morten Brydensholt

Re: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Pedro Crispim -
Don't forget we need to have php_imagick.dll and php_perkl.dll extensions enabled.
In reply to Morten Brydensholt

回應: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Su Dung-jou -

Dear Morten,

I follow your steps to set up "TeX Notation" in my system. However, it can not show formula correctly, for example:

    Input:  {3} \over {4}  (here, "$$" has removed to show formula correct)
    output: 3over4

And, I trace the output ".tex" file found the "\" has been removed before wrote to ".tex". Do you know how to fix this?

In reply to Su Dung-jou

Ang: 回應: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Morten Brydensholt -

Su Dung-jou,

If I input:

   $$${3} \over {4}$$$

I also get some nasty output.

However if I input:

   $$${3} \over{4}$$$

(without the last space) I get the correct Latex-output.

I believe this is a conflict between different filters in Moodle.

Hope this helps.

Morten

In reply to Morten Brydensholt

回應: Ang: 回應: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Su Dung-jou -

Dear Morten,

Thanks your reply, but it still not work.

I think I need to trace the output function to solve this problem.

 ps.:The problem is the leading slash for each function removed when wrote to ".tex" file.

In reply to Su Dung-jou

Re: 回應: Ang: 回應: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Cristina Berisso -

Hello Su,

Where is it (in which tool, i.e. quiz, lesson, text page, web-page, etc.) that you are trying to include the Math notation and which is not correctly processed? You may be experiencing the same issue I had when trying to include Math notation into the "cloze" type questions. If that is the case, please read the following posting (in the Quiz forum). Hope it helps.

Cristina

In reply to Cristina Berisso

回應: Re: 回應: Ang: 回應: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Su Dung-jou -

Hi Cristina,

Thanks your help. Your answer remined me to check PHP setting.

In my php.ini, the value of magic_quotes_sybase is set to "on". So, I try to set it off. After restart IIS, the formular Shown is correct.

Su

In reply to Morten Brydensholt

회신: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Jong-Dae Park -

Hi Morten!

I followed the step you suggested but I got the same mimetex output. I am using Windows 2003 server and Apache webserver. I wonder how tex filter choose mimetex or latex.

Thanks in advance.

J-D Park

In reply to Jong-Dae Park

Ang: 회신: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Morten Brydensholt -

Hi Jong-Dae Park

It's been a while since I played around with these settings, so I can hardly remember the issues.

Maybe these suggestions can point you in the right direction:

You must restart the server itself (the computer) to get the extensions to work with your new path settings. It's not enough to restart the Apache-server.

Miha Drenik also suggested on mandag, 29 januar 2007, 03:19
  "You might want to rename mimetex.exe to something else at least until you get the other renderer working."

To verify ImageMagick is working properly, type the following in an MS-DOS Command Prompt window (the run-command from the start menu):

  convert logo: logo.gif
  identify logo.gif
  imdisplay logo.gif
 

Each of the above lines should be typed in one by one. The first line produces nothing (besides a flickering open and close of a window). And the second line produces nothing (besides a flickering open and close of a window). But the third line should invoke a new window to open with the image of the magician. This means ImageMagick is properly installed and the path to convert.exe works.

To test the path to Latex you can simply create a new (empty) text-document "newdocument.txt" and rename it to "newdocument.tex". When you click this tex-document the server should open it with Latex.exe (producing some error messages in a command window).

Hopefully these actions will narrow your search for a solution.

Best regards

Morten

 

In reply to Morten Brydensholt

회신: Ang: 회신: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Jong-Dae Park -

Hi! Morten,

Thanks for your help.

I reinstalled Miktex 2.6 and it works.

Thanks again.

Jong-Dae Park

In reply to Jong-Dae Park

Ang: 회신: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Morten Brydensholt -

By the way; I use Moodle version 1.7.

I saw another thread where people are having the same problem on a Linux-server and using Moodle 1.6.5.

Just opening the mind for an issue on different versions of Moodle...

Best regards

Morten

In reply to Morten Brydensholt

회신: Ang: 회신: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Jong-Dae Park -

Hi! Morten,

May I ask one more question?

I want to  make the fractional expression bigger.

eqn

The fractional expression is too small and I want to get bigger image.

Thanks.

Jong-Dae Park

In reply to Jong-Dae Park

Ang: 회신: Ang: 회신: Ang: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Morten Brydensholt -

Hi Jong-Dae Park

Glad to hear you finally got LaTex to work.

On this matter you could use "displaystyle":

$$$\displaystyle f(x,y)=\frac{2a}{x+y}$$$ gives:

$$\displaystyle f(x,y)=\frac{2a}{x+y}$$

I'm not aware of any other way that works with the LaTex-filter.

Best regards

Morten

Attachment math1.gif
In reply to Morten Brydensholt

Re: Help with MiKTex, ImageMagick, & Ghostscript on Windows

by Ralf Krause -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
In Moodle and the normally integrated mimeTeX you will get these things:

$$$\small f(x,y)=\frac{2a}{x+y}$$$      $$\small f(x,y)=\frac{2a}{x+y}$$

$$$\large f(x,y)=\frac{2a}{x+y}$$$      $$\large f(x,y)=\frac{2a}{x+y}$$

$$$\LARGE f(x,y)=\frac{2a}{x+y}$$$      $$\LARGE f(x,y)=\frac{2a}{x+y}$$