Poor quality image rendered with tex

Poor quality image rendered with tex

by Lael Gordon -
Number of replies: 8
Hello again,
I am not satisfied with the quality of the image I am getting using TeX and am wondering if there is anything I can do to improve it. The top image is a screen shot of what a formula looks like in Word using Math Type.
Once I convert the the formula to TeX code and cut and paste it into Moodle it is rendered as the bottom image. Not nearly as clear as the original and much smaller. I fear students will not be able to decipher the denominators.
Any ideas?
Thanks, Lael

Attachment tex_problem2.jpg
Average of ratings: -
In reply to Lael Gordon

Re: Poor quality image rendered with tex

by Mauno Korpelainen -

It depends partly on the distribution of Latex you use and partly the syntax you use. For example here in moodle.org using tetex

R_t= \frac{1}{ \frac{1}{R_{1}} + \frac{1}{R_{2}}+ \frac{1}{R_{3}}\cdot\cdot\cdot } is rendered as $$ R_t= \frac{1}{ \frac{1}{R_{1}} + \frac{1}{R_{2}}+ \frac{1}{R_{3}}\cdot\cdot\cdot } $$

and

\displaystyle R_t= \frac{1}{ \frac{1}{R_{1}} + \frac{1}{R_{2}}+ \frac{1}{R_{3}}\cdot\cdot\cdot }

is rendered as $$ \displaystyle R_t= \frac{1}{ \frac{1}{R_{1}} + \frac{1}{R_{2}}+ \frac{1}{R_{3}}\cdot\cdot\cdot } $$

Google Chart api tex:
example

Mathtran without \displaystyle

example 

and with \displaystyle

example

If you use AsciiMathML Firefox renders

`R_t = 1/{{:1/R_1:}+{:1/R_2:}+{:1/R_3:} cdot cdot cdot}`

or

$ R_t=\frac{1}{ \frac{1}{R_{1}} + \frac{1}{R_{2}}+ \frac{1}{R_{3}}\cdot\cdot\cdot } $

using the defaut font selected in asciimathml script and uses image fallback to given renderer for other browsers.

Attachment examplefrac.gif
In reply to Lael Gordon

Re: Poor quality image rendered with tex

by Hans Dull -
Try using "\dfrac ..." instead of using "\frac ..."like:

R_{t}=\dfrac{1}{\dfrac{1}{r_1}+\dfrac{1}{r_2}+\dfrac{1}{r_3}+...}

$$R_{t}=\dfrac{1}{\dfrac{1}{R_1}+\dfrac{1}{R_2}+\dfrac{1}{R_3}+...}$$
In reply to Hans Dull

Re: Poor quality image rendered with tex

by Mauno Korpelainen -

It's a good option in Latex distributions like MikTex, TeTex or TexLive

as well as

R_t=\cfrac{1}{ \cfrac{1}{R_{1}} + \cfrac{1}{R_{2}}+ \cfrac{1}{R_{3}}\cdot\cdot\cdot }

$$ R_t=\cfrac{1}{ \cfrac{1}{R_{1}} + \cfrac{1}{R_{2}}+ \cfrac{1}{R_{3}}\cdot\cdot\cdot } $$

The only bad thing is that Mimetex does not support \dfrac or \cfrac

It is also possible to use external editors / images like http://www.codecogs.com/components/equationeditor/equationeditor.php

to render tags like

R_t=\cfrac{1}{ \cfrac{1}{R_{1}} + \cfrac{1}{R_{2}}+ \cfrac{1}{R_{3}}\cdot\cdot\cdot } \; and \;
R_t=\dfrac{1}{ \dfrac{1}{R_{1}} + \dfrac{1}{R_{2}}+ \dfrac{1}{R_{3}}\cdot\cdot\cdot }

as

example

In reply to Lael Gordon

Re: Poor quality image rendered with tex

by Ian Wild -
Picture of Plugin developers

Hi All,

Another possibility is to check to see if the image being generated is a GIF or a PNG. I use PNG images because the quality tends to be much better.

Hope this helps,

Ian.

In reply to Ian Wild

Re: Poor quality image rendered with tex

by Mauno Korpelainen -

It does - and there are some tracker issues about png/gif selection in tex filter. Historical background of using gif is based on Mimetex and IE6 but current trend is to replace gifs with pngs and forget IE6.

See for example http://moodle.org/mod/forum/discuss.php?d=139149 for more details.

In reply to Mauno Korpelainen

Re: Poor quality image rendered with tex

by Ramon Eixarch -
In WIRIS we use PNG as default format and quality is good. The image produced by default with the formula submited is
WIRIS editor sample formula
In reply to Lael Gordon

Re: Poor quality image rendered with tex

by Lael Gordon -

Wow, thank you all for the info.

Using "dfrac" worked well and seems like the easiest option for that particular situation. I am a math instructor and by no means an expert at moodle or IT in general. Most of the info presented above was a little over my head. Let let me see if I can get some clarification on a few points and I will also pass this on to our site administrator for some help.

Although changing the code to 'defrac' instead of 'frac' worked fine in that situation, is there a way that I can alter the settings in Math Type so that it will translate a formula into code that will give me a better rendered graphic (for example, it will translate to 'defrac' instead of 'frac')? I am using the most current version of Math Type and have it set to translate to "Tex - LaTex 2.09 or later." I very much wish to avoid always having to alter code once it is in Moodle. I am creating a quiz question database with a large number of questions and altering code individually would be too time consuming. It is also a foreign language that I don't care to spend a lot of time learning.

Or is part of the problem with the TeX filter our site is using? I believe we are using the the filter that comes standard with Moodle. We are running  v1.9.5+. I have noticed that even when creating simple formulas with DragMath they don't end up looking that great. Again, it would be nice not to have to alter the TeX code that DragMath creates. Should we look at using a different filter?

Thanks for everyone's help

Lael Gordon

AVTEC

Seward, Alaska

In reply to Lael Gordon

Re: Poor quality image rendered with tex

by Mauno Korpelainen -

The problem is not in DragMath, MathType or any other editor that outputs code - the problem is that quality of bitmap images simply is worse than for example quality of vector graphics (svg) - or fonts - and png images usually look better than gifs. You can improve a little the quality of latex for screen or printing with various settings like gammacorrection and density (and scaling)...but pixels are pixels...and also your screen resolution and softening of fonts (in MathML) might have some influence...

One more interesting discussion about advantages and disadvantages of different output formats is also in http://moodle.org/mod/forum/discuss.php?d=130417