LaTeX images looking "thin"

LaTeX images looking "thin"

by Jay Theriot -
Number of replies: 10
Is there a setting that I am missing? my latex *.gifs are looking "thin" with some parts of the symbols fading into the background.
Average of ratings: -
In reply to Jay Theriot

Re: LaTeX images looking "thin"

by Jay Theriot -
I changed a couple of lines of code in latex.php to use .png instead of .gif and the output is clear.
Average of ratings: Useful (1)
In reply to Jay Theriot

Re: LaTeX images looking "thin"

by Martin Villarica -
Hi, sorry about the newbie question: May I ask which lines in the php code you changed to use .png instead of .gif?

Thanks very much.
In reply to Martin Villarica

Re: LaTeX images looking "thin"

by Jay Theriot -
The files are in /moodle/filter/tex/. The files are filter.php, pic.php and latex.php.

Line 157 in filter.php was changed from
$filename = $md5 . ".gif";
to
$filename = $md5 . ".png";

Line 107 in latex.php was changed from
$gif = "{$this->temp_dir}/$filename.gif";
to
$gif = "{$this->temp_dir}/$filename.png";

Line 149 in latex.php was changed from
unlink( "{$this->temp_dir}/$filename.gif" );
to
unlink( "{$this->temp_dir}/$filename.png" );

Line 43 in pic.php was changed from
$md5 = str_replace('.gif','',$image);
to
$md5 = str_replace('.png','',$image);

I think I got them all. There are references to the variable $gif. I left them as $gif although better form would have me replace them to $png. I got the filter working the way I liked with minimal edits to the original code and left the rest.

latex.php is here. filter.php is here. pic.php is here.

Hope this helps. I don't know why .png's render so much better on my system. I have a Gentoo server with all the latest packages installed. I think that ImageMagick's convert may be the culprit.
Average of ratings: Useful (3)
In reply to Jay Theriot

Re: LaTeX images looking "thin"

by Dakota Duff -

PNG is available? Why isn't it the default?!?

I switched over to jsMath because the GIFs that were output were so ugly. Maybe now I'll go back!

In reply to Dakota Duff

Re: LaTeX images looking "thin"

by Dakota Duff -

At least on my server the PNG images look identical to the GIF images.

I'll be sticking with jsMath.

In reply to Jay Theriot

Re: LaTeX images looking "thin"

by Matthew Whelpton -
I just wanted to say that I had the same problem and this edit fixed it for me. So, first, thanks for a simple and effective solution. And, second, I agree, why isn´t png the default - at least until the poor rendering problems on gifs is solved...?
Thanks again, Matthew.
In reply to Matthew Whelpton

Re: LaTeX images looking "thin"

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I guess it's because every single graphical web browser out there supports GIF wink, but no all of them support PNG (IE 6.0 and below have problems with some PNG features; and yes, lots of people are still using IE 6.0 unfortunately).

Saludos, Iñaki.

In reply to Iñaki Arenaza

Re: LaTeX images looking "thin"

by Mauno Korpelainen -

You should actually modify also 4th file - see http://moodle.org/mod/forum/discuss.php?d=120418#p532389 

IE6 is not the only reason - the original reason might be Mimetex that is compiled to render gifs - not pngs - so even if you make these changes and use Mimetex from folder filter/tex you get gifs and if you use local distribution of latex together with Ghostscript or ImageMagick you can get pngs...

There have been some tracker issues last year about changing the administration of this gif/png selection to settings of tex filter which would make much more sense than changing files of tex filter each time you upgrade moodle - and if we had some "universal tex renderer" (Google Chart API tex is using mimetex type code but renders pngs that are visible also in IE6) life would be so much easier - with or more likely without IE6.

Microsoft has set the kill date for IE6 as April 8, 2014, when it wraps up all support for Windows XP. So we have to suffer 4 more years... wink

In reply to Mauno Korpelainen

Re: LaTeX images looking "thin"

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Mauno,

I have just found MDL-10197 that discusses exactly this topic, and have attached a patch there with a proposed solution (I see you are a watcher of the bug, so you'll probably receive an email about it wink)

Saludos, Iñaki.

In reply to Jay Theriot

回應: LaTeX images looking "thin"

by Meng-Hsi Chiu -

1. GIF file too thin seems like figure 1.

2. In Moodle 2.0.3+, you can just set at: "SETTINGS, Site administration, Plugins, Filters, Tex Notations", "Convert output format" from GIF to PNG seems like figure 2.

3. PNG file is better seems like figure 3.

Attachment Tex Notation convert output format from gif to png.png