Lines in default TeX package

Lines in default TeX package

by Colin Fraser -
Number of replies: 7
Picture of Documentation writers Picture of Testers
I am slowly figuring this out and can do arcs and circles but trying to draw intersecting lines, now there is a challenge. I did not think that I would be able to do anything in a geometric sense, but I figured out that I can. What I would like is a way of drawing intesecting lines, parallel lines, lines I can use to intersect arcs and so on. Can anyone suggest something I can look at, or some existing examples. My real problem is that the Moodle this is for is not likely to add a non-default Tex or Latex package, and probably will not upgrade to Moodle 2.0 for quite some time. Any help would be greatly appreciated...   
Average of ratings: -
In reply to Colin Fraser

Re: Lines in default TeX package

by Mauno Korpelainen -

Default package - Mimetex - is not very well documented wink but you can get some tips from Forkosh main site and test...

For example \picture(100){(50,50){\circle(99)} (0,30){\line(180,180)} (0,90){\line(180,-180)}}

gives

Some lines and a circle

so yes - it is possible - but tools are not very "advanced" and it takes some time and effort to combine complex graphs.

See for example http://www.forkosh.com/mimetexmanual.html and there

(IIIf) \picture(  ){ } "Environment", including \line(  ){ } and \circle(  ) 

In reply to Mauno Korpelainen

Re: Lines in default TeX package

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Hi Muano, it took a little while but I figured that mimetex was the default package, so I went there first. the trouble is I got an issue with it. Simple but inelegant... so what has not been implemented? Or what have I not got right? I put this in:

$$$ \picture(100){(50,50){\circle(99)} (0,30){\line(180,180)} (0,90){\line(180,-180)}} $$$ and $$$ \line(180,180) $$$

Edit:I just got the same thing...wow, that was funny... OK, something at my end and not necessarily the server what have I not done?

Attachment latex01.png
In reply to Colin Fraser

Re: Lines in default TeX package

by Mauno Korpelainen -

You have done everything ok - I forgot that \line is one of the blacklisted tex commands in tex filter - to prevent endless lines or spirals ...

You can edit filter/tex/lib.php and remove

'\line',

from line 48 ( in function tex_sanitize_formula($texexp) )

I must stop sending these comments to moodle.org forums - what ever I say I need to add those 'but':s later blush

Edit: Or if you want to keep \line blacklisted you can always install external cgi mimetex and use tags like http://www.imathas.com/cgi-bin/mimetex.cgi?\picture(100){(50,50){\circle(99)}+(0,30){\line(180,180)}+(0,90){\line(180,-180)}} to render such examples with editor image plugin (that's how I usually add these examples to forums)

Edit 2: + there is also an option to use some other tools outside moodle to create those images - for example http://www.imathas.com/editordemo/demo.html with IE and add the image address (mouse right click - properties) to editor image plugin or upload the images (graphs) as images without any script tags, applets etc if you are not allowed to use them

http://www.imathas.com/editordemo/php/svgimg.php?sscr=-7.5%2C7.5%2C-5%2C5%2C1%2C1%2C1%2C1%2C1%2C300%2C200%2Cfunc%2C2x%2B3%2Cnull%2C0%2C0%2C%2C%2Cblack%2C1%2Cnone%2Cfunc%2C-0.5x%2B1%2Cnull%2C0%2C0%2C%2C%2Cblack%2C1%2Cnone%2Cparam%2C3sin(t)%2C3cos(t)%2C0%2C0%2C%2C%2Cblack%2C1%2Cnone

In reply to Mauno Korpelainen

Re: Lines in default TeX package

by Colin Fraser -
Picture of Documentation writers Picture of Testers
Ahh thanks Mauno, but this is not my Moodle, they do not want me playing with their toy. Ever since I told them... a long story..smile I cannot even get access to the database. However, I will pass this along and might be able to get others on-side and get them to make the same comments. Its all politics...

Your last comment seems the best option here.. I can create them in a Moodle I can make the necessary changes to then save the image and upload that. A pain for the moment, but better than nothing.

However, this comment, "...to prevent endless lines or spirals." does concern me a little.

I am thinking here that this becomes the improperly terminated loop? What happens? How is it fixed? A reboot of the server? Not possible, far too many Moodles on it.
In reply to Colin Fraser

Re: Lines in default TeX package

by Mauno Korpelainen -

It is for example possible to use some scripts to produce a huge amount of different graph images in a few seconds and this way attack the server or to produce some unparseable tags ( I have been able to do that since we got our first computers without any latex tags... big grin ) but I suppose \line is not one of the dangerous latex commands in most latex distributions.

For example in mimetex you can use value 600 for x slope and y slope and get

http://korpelainen.net/cgi-bin/mimetex.cgi?\picture(600){ (0,0){\line(600,600)}}

but if you try 601 you get

http://korpelainen.net/cgi-bin/mimetex.cgi?\picture(601){ (0,0){\line(601,601)}}

Different distributions of latex may have different rules for commands and because latexRender blacklisted originally \line (as well as \mbox) as potentially dangerous or unparseable command on some environments moodle did the same...

In reply to Mauno Korpelainen

Re: Lines in default TeX package

by Colin Fraser -
Picture of Documentation writers Picture of Testers
This is all I really wanted..big grin Now I can do that, I should be able to start a Trig page... If only my old Trig teachers could see this..hahahaaaa!!!!!!

$ \picture(350,250){(25,25){\line(300,0)}(25,25){\line(0,220)}(25,245){\line(300,-220)}(310,25){\circle(100;135,180)}(20,100){\line(310,-75)} (25,25){\fbox{\line(5,5)}}(25,25){\line(150,150)}(165,140){Hypotenuse}(120,2){Adjacent}(2,80){\rotatebox{90}{Opposite}}(270,40){\theta}}$


Attachment trig01.gif
In reply to Colin Fraser

Re: Lines in default TeX package

by Mauno Korpelainen -

Mimetex is actually pretty cool... BUT if you want to do the same with other distributions and tex filter you need some tuning... big grin

http://korpelainen.net/cgi-bin/mimetex.cgi?\picture(350,250){(25,25){\line(300,0)}(25,25){\line(0,220)}(25,245){\line(300,-220)}(310,25){\circle(100;135,180)}(20,100){\line(310,-75)} (25,25){\fbox{\line(5,5)}}(25,25){\line(150,150)}(165,140){Hypotenuse}(120,2){Adjacent}(2,80){\rotatebox{90}{Opposite}}(270,40){\theta}}

Nice triangle, Colin!!!