How can I add special characters, chemical symbols etc??

How can I add special characters, chemical symbols etc??

by Adrian Baker -
Number of replies: 27
Hi All

I have searched thoroughly through this forum, but can't see an easy way to add characters such as the barred signs for anti particles, chemical symbols with mass and atomic numbers or even Pi. I tried & pi; (without the space) and didn't get pi as I know it!

π

How can I put up isotopes such as Carbon 14? ie 14 C 6??



I have looked at unicode, but where is say the d bar symbol for an anti-down quark??
Average of ratings: -

Re: How can I add special characters, chemical symbols etc??

by J B -
Hi Adrian

I think you will find what you need by using the Tex notation filter,
settings link in Administration > Modules > Filters > Manage filters

you may need to do a bit of config to get it working:

http://docs.moodle.org/en/TeX_filter


Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
This example using the Tex filter which you can invoke once you have turned it on

$$^{33}_{17}Cl^{16}\xrightarrow{n,n}~^{31}_{15}P^{16 }+~^4_2He^2$$

is taken from here:

http://www.physicsforums.com/showthread.php?t=9021

Notice that the xrightarrow does not parse as discussed here, http://moodle.org/mod/forum/discuss.php?d=111788#p490607, though a replacement with a vector statement might work. You willl also note that the stacking in front of the C appears to be inconsistent with the display you will see in the pafe I referenced, likely because Moodle uses a tex and not latex filtyer, though I have never found full docs explaining what exactly is going on with the Moodle tex filter.....

However, I would suggest you look at asciimath, which you may find faster and more easy to use and can be invoked from theme as opposed as filter (in fact, I recommend that you not install in filter for reasons posted elsewhere) . If you are interested in ursuing asciimathml install, check out the recent math tools postings and let me know if you need some assistance.

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

This different syntax is sometimes really annoying but something like

$ $ ^{33}_{17}Cl^{16}\;\stackrel{n,n}{\rightarrow}\;^{31}_{15}P^{16}+~^4_2He^2 $ $ (no space between double dollars)

could do the same job in mimetex:

$$^{33}_{17}Cl^{16}\;\stackrel{n,n}{\rightarrow}\;^{31}_{15}P^{16}+~^4_2He^2$$

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
But notice that using mimetex in Moodle the 33 and 17 are still not aligned with the 31 and 15 (nor with 4 and 2 for that matter.....) I am looking at what make this pretty in asciimathml as well....

Ahhhh..... here it is, I knew I had seen it somewheres....

`{::}_(\ 92)^238U`

Note that asciimathml simply does not know what to do with leading sub- and superscripts without the initial token.

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
compare using asciimathml:

`{::}_(17)^33 bbCl {::}^16\ \vec{n,n}\ {::}_(15)^31 bbP {::}^16\ +\ {::}_(2)^4bbHe^2`

`{::}_(17)^33 "Cl" {::}^16\ \vec{n,n}\ {::}_(15)^31 "P" {::}^16\ +\ {::}_(2)^4"He"^2`

I discovered that bb is no longer working after installation of the STIX fonts, but either of these will adequately substitute for the tex posted previously.

"\ " is a space. "{::}" is essentially a nullity that allows for the prescript "bb" should embolden text and the quotes escape text from being displayed in italics by asciimath.

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

Nice example Marc! I tested another version with our "super equation editor" and used some non standard spaces (custom input) with Times New Roman as default font and got equation that looks much cleaner than Tex version $$^{33}_{17}Cl^{16}\;\stackrel{n,n}{\rightarrow}\;^{31}_{15}P^{16}+~^4_2He^2$$ :

(UPS - Cl and U got a little bit messed...big grin)

Attachment chemistry.gif

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
Oh my..... wild and crazy transmutation! The Alchemists were right! big grin

Thanks for the image as it provides a glimpse for subscribers at some of the new magic buttons.....

Re: How can I add special characters, chemical symbols etc??

by Adrian Baker -
Hi folks - thanks for the replies

I turned on the latex notation filter and tried typing away....

I typed in $ $ sqrt( x + y ) $ $ (no spaces in the $) as a test and it worked.... sort of.

When I looked at the page, the correct notation was there, but blue and a hyperlink. I clicked on this link and got to a debug page. Why? I tried the 6 options with my sqrt (x+y) and got error messages such as:

sh: /home/bscphysi/public_html/moodle/filter/tex/mimetex.linux: Permission denied
The shell command
"/home/bscphysi/public_html/moodle/filter/tex/mimetex.linux" -e "/home/bscphysi/public_html/moodle/uploaddata/filter/tex/aeafd206b7a69e98185e3584006592d5.gif" -- '\Large sqrt (x+y)'
returned status = 126
File size of mimetex executable /home/bscphysi/public_html/moodle/filter/tex/mimetex.linux is 491043
The file permissions are: 100644
The md5 checksum of the file is c294ab11905323bb5cb0f451241bedc1
Image not found!
Warning: Cannot modify header information - headers already sent by (output started at /home/bscphysi/public_html/moodle/filter/tex/texdebug.php:149) in /home/bscphysi/public_html/moodle/filter/tex/texdebug.php on line 104
No text output available

Clearly something wrong here... I searched some more and managed to turn debug mode in the admin settings from off to normal, but no change.


What am I doing wrong??


(I'm still looking at the ASCimath sugestion!)



Re: How can I add special characters, chemical symbols etc??

by Adrian Baker -
Ok, just tried again having logged in and out and doing a few other site admin things and now my expression is still blue, but when i click on it, the correct notation comes up, in normal text in a small window.
Why won't this come up on the page without the hyperlink??

Actualy though the Latex isn't working. If I use the suggested link above:

$ $ ^{33}_{17}Cl^{16}\;\stackrel{n,n}{\rightarrow}\;^{31}_{15}P^{16}+~^4_2He^2 $ $

(without spaces) I get EXACTLY the same text, but as a blue hyperlink!!

All very puzzling..



I also went to

/moodle/filter/tex/texdebug.php

as I'm trying all kinds of things here! However, it appears some files are missing. I got:

Checking executables

Error: latex executable (/usr/bin/latex) is not readable
Error: dvips executable (/usr/bin/dvips) is not readable
Error: convert executable (/usr/bin/convert) is not readable

base filename for expression is 'd1e56126337cd6e29b16fe759232ce90'

Processing TeX expression:

f(x)=\Bigint_{-\infty}^x~e^{-t^2}dt
$ /usr/bin/latex --interaction=nonstopmode /home/bscphysi/public_html/moodle/uploaddata/temp/latex/d1e56126337cd6e29b16fe759232ce90.tex
OUTPUT:
RETURN CODE: 127
$ /usr/bin/dvips -E /home/bscphysi/public_html/moodle/uploaddata/temp/latex/d1e56126337cd6e29b16fe759232ce90.dvi -o /home/bscphysi/public_html/moodle/uploaddata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps
OUTPUT:
RETURN CODE: 127
$ /usr/bin/convert -density 240 -trim /home/bscphysi/public_html/moodle/uploaddata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps /home/bscphysi/public_html/moodle/uploaddata/temp/latex/d1e56126337cd6e29b16fe759232ce90.gif
OUTPUT:
RETURN CODE: 127
Does this help anyone?

Thanks

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
OK..... with the caveat that by no means should you view me as an expert on the Moodle Tex filter (I have been told that Tex filter questions should be posted to the filter forum....) let me give this a shot.

As I understand it, the moodle tex filter tries to use tex based on the applications that your error messages tell you are "not readable" (latex, dvips and convert), and it falls back to mimetex (assuming mimetex has been properly installed.)

It sounds like you may have gotten mimetex working (I may be a bit confused in the details), but the initial tex attempt is failing, hence the responses when you do the debug.

No, it is unlikely you will find full docs on the tex filter, though there are folks here, though not necessarily on this forum, who will try to talk you through getting tex up and running (but that won't be me.....)

When you get tired of thrashing about with the tex filter let me know and I think we can resolve your problems in about 5 minutes..... Well Mauno will probably take me to task for being a poltroon, but there you go....

Re: How can I add special characters, chemical symbols etc??

by Sharon Goodson -

And NEVER view me as a Moodle TeX filter expert *lol* - that said though, I thought I would mention the problems I ran into with our hosted Debian server.

For whatever reason, the Moodle default filters don't act right on a Debian server. There are suggestions at the bottom of the page link James provided - but I ended up installing ASCIIMathML.js and simply disabled the other filters. I had to tweak a little, but it works. Then I installed Dragmath, still some minor tweaking, but it certainly solved the problem.

If you find you do have a Debian server, I'd be happy to provide more details

PS: Mauno - Where can I get those magic buttons?  big grin

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

Sharon,

in current standard packages of moodle nowhere but Marc has given me a lot of feedback and help in testing AsciimathML plugins - it may still take several months to get all "magic buttons" sorted for HTMLArea and versions before 2.0 ... tinymce plugins for moodle 2.0 may be ready before HTMLArea plugins but my guess is that on January most moodlers can use a separately installed equation editor in moodle using asciimathml, latexmathml or latex either with local Latex/Mimetex/AsciimathML or with external Mimetex/Mathtex from some public server. I have installed both Mimetex and mathtex as cgi + Latex (Tex Live) to my test server, Marc can offer his Mimetex for some users and there are some "public servers" available - maybe moodle.org should have one Mimetex/mathtex server available too.

Like Marc explained the problem with local Tex is usually that either paths to Latex filter files are not correct (files do not exist if Latex is not installed or files may not be readable or you need symbolic links etc) or you need to change permissions of files inside local moodle folder/filter/tex to allow exe file mimetex.exe run - permission to read exe file is not always enough...

For such cases where people can't or are not at all allowed to use local Latex external mimetex or mathtex is a good choice. The new code of AsciimathML fallback scripts allows also IE users to see equations and graphs (as images) - we needed to install separate MathPlayer (MathML) and (Adobe)SVG viewer plugins to IE before - now with help of the scripts that Peter Jipsen and David Lippman have written graphs and equations are seen also in IE (IE does not support mathML and SVG) - FF, Opera and Safari can do it better with native MathML support. Cleaner, faster and maybe more usable than current mathematics  & physics & chemistry with standard Tex.

I have added some new features to AsciimathML scripts and will add more features but Peter and David has done all that enormous work (several years) to make this possible.

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

By the way this example from documentation may have caused a lot of confusion...

$ $ sqrt( x + y ) $ $ is not correct TeX syntax (in common) and I changed it to documentation (thanks Samuli...)

sqrt needs slash \ and the formula should be

$ $ \sqrt{x + y} $ $

http://tracker.moodle.org/browse/MDLSITE-573

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -
As an example of external scripts - if you paste to image plugin

http://www.imathas.com/editordemo/php/svgimg.php?sscr=-7.5,7.5,-5,5,1,1,1,1,1,300,200,func,sin(x),null,0,0,,,black,1,none

it should produce (from imathas server) code

<img title="test" alt="test" hspace="0" src="http://www.imathas.com/editordemo/php/svgimg.php?sscr=-7.5,7.5,-5,5,1,1,1,1,1,300,200,func,sin(x),null,0,0,,,black,1,none" border="0" />

that looks like this
test


And if you don't have a working latex or local mimetex try to paste to image plugin Image URL:

http://www.forkosh.dreamhost.com/mimetex.cgi?\alpha\beta\gamma

It should give moodle image tags

<img title="test" alt="test" hspace="0" src="http://www.forkosh.dreamhost.com/mimetex.cgi?\alpha\beta\gamma" border="0" />

that looks like this

test


But please try to use local Latex/Mimetex - if possible... We also need to write some documentation about using those new plugins before people start using them...

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -
I moved this discussion to Mathematics Tools forum - although the original question was about Chemistry...wink

I will explain later in documentation how to use svgimg.php from local server inside moodle to avoid straining those servers that Peter, David, John and others use for their important work to make world of Mathematics in www perfect wink

Re: How can I add special characters, chemical symbols etc??

by Adrian Baker -
Thanks for the answers..... but ..errr What??
The thing about the graph - is that for general info or a fix or a test maybe? mixed

I'll check if I have a Debian server (it is Linux) but other than that I'm afraid I don't really understand what your answers tell me.

My tex plugin is installed (i think), but not working. What have I done wrong, or more specifically, what do I do to fix this?

Thanks
Adrian B

N.B. Rereading my comments above makes it seem a bit critical of you all - it isn't meant to be I just don't understand what is wrong or what to do. Sorry! smile





Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

Do you have access to your server and can you change permissions of files and folders?

File size of mimetex executable /home/bscphysi/public_html/moodle/filter/tex/mimetex.linux is 491043
The file permissions are: 100644

644 means that nobody can execute (run)file /home/bscphysi/public_html/moodle/filter/tex/mimetex.linux

Try to set permission to 755

---------------------------------

The other error messages

Error: latex executable (/usr/bin/latex) is not readable
Error: dvips executable (/usr/bin/dvips) is not readable
Error: convert executable (/usr/bin/convert) is not readable

might mean that there is no separate Latex installed on your server or those files are not there where default settings of moodle try to find them. That's why moodle tries to use Mimetex but it can't because permissions do not allow it and mimetex can't create a gif image from code you have given...

----------------------------

Sorry for this graph info - it has nothing to do with your original question. The other part of that post tried to explain that even if you never get local Latex or mimetex to work you can use some external mimetex/latex server with img tags (editor has image plugin for adding images and you can add Image URL to field Image URL - it does not have to be an image...) - for example http://latex.codecogs.com/gif.latex?f(x)=\displaystyle\frac{(x+1)^2}{(x+1)}=(x+1) gives http://latex.codecogs.com/gif.latex?f(x)=\displaystyle\frac{(x+1)^2}{(x+1)}=(x+1)

The best result (quality) you get if you have fully functional Latex installed or if you use for example AsciimathML or jsMath. Getting Asciimath to moodle is another story so I won't explain that anymore but you could read some post from this forum... and to be able to use TeX you need to study the syntax or need to have some equation editor that can output valid code...

One optional place for testing code and getting external equations (images) is http://www.sitmo.com/latex/ that gives a png image test or as downloaded image

Attachment equation.png

Re: How can I add special characters, chemical symbols etc??

by Adrian Baker -
Thanks for your reply.

I reset the file permission from 0644 to 0755 as suggested.... and Yippee, it worked!! I appreciate the help and understand that i now have mimetex working. This is an excellent start.

I can't find the three files listed as missing. Don't these appear when setting up moodle or when enabling Tex filter?
If not, how do I get them installed.


Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

You don't really need those 3 files if you use mimetex from folder moodle/filter/tex/ - they are not parts of moodle, they are parts of larger packages like Latex or ImageMagick.

If you have full access to your server and know the distribution of your linux ( for example Debian Etch ) you should find info from net about installing a full latex package to the server. For example http://www.tug.org/texlive/debian.html has some info about installing TeX Live to Debian Etch and http://www.ctan.org/starter.html has some info about Latex distributions. It takes quite a lot of time and disk space to get through all steps and may be difficult on hosted sites...

Re: How can I add special characters, chemical symbols etc??

by Sharon Goodson -
Thanks Mauno! All that is some great info! We are moving to a Moodle Partner in the next days, so I'll be anxious to see what your options are there (and have the latest install)!

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
I have heard that the sky is the limit depending on your MP and your LSA ;=}

Seriously, though, I would want them to set up jmol for you, as well as provide tinyMCE with asciimathml and dragmath (they can contact Mauno as far as the latest greatest integration) and then stay away from the doubledollars (if they turn on tex) and rely on asciimathml.

Additionally, as I mentioned somewhere in the Math Tools forum, as dragmath is totally extensible through its xml files (as opposed to asciimath which has tables internal to the js), you can also experiment with using dragmath to create your formulas and then save them in either drg format or in text format in that from an instructional stance I am sure you could identify a repertoire if you will of standard expressions you use regularly....

I think it would be handy to have a repository at moodlecommons or elsewhere with asciimath and dragmath files for commonly used expressions in math, chemistry and other disciplines. I was actually starting to build a course as a container and any "activities" addressing such will be gladly added and then uploaded...... you may have noted that Mauno and I were like a couple of schoolboys (well that ain't all bad) playing with methods to build the same expression. While its true that this was indulged in probably to keep us from work surprise it does help to explore the idiosyncracies of the tools, which will eventually improve them (or at least thats the rationale I keep telling myself.....)

Re: How can I add special characters, chemical symbols etc??

by Adrian Baker -
Hi again.

Having been very pleased to get mimetex working I set about doing some of the things I wanted to do with it. However, I came across another problem... sad
It doesn't work in Quiz answers!

I can use $$ \pi$$ mesons ($ $ \pi$ $ mesons) in a question, but not in an answer!

Is this fixable?

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
I have come across a number of issues with quiz module, some of them relating to when a page is parsed. After quite a bit of fiddling and discussions with Andy Kemp who brought this to my attention, I eventually determined that the simplest way to resolve these issues at present was to implement asciimathml (sorry if I sound like a broken record) via themes as that provided me the greatest coverage and works in quiz and hotpots and virtually anywhere else.

I have amended the asciimathml doc so that it contains info on how to do this.

In the meantime, if you do resolve your specific issue, please feel free to add your solution to the docs, either as a footnote to the existing math tools doc or as a separate doc with a link from there.

Re: How can I add special characters, chemical symbols etc??

by Adrian Baker -
No problem with the broken record! big grin

I've read the asciimathml documentation but it isn't that clear how to proceed at first reading. I've not edited many php files before and don't want to mess up my Moodle installation! I'm sure it is obvious what to do if you regularly fiddle around with these files, but I'm still quite new to Moodle and am not yet that familaiar with all its workings...

I'll look into it when I have a little more time next week, but asciimath does seem the way forwards.

Re: How can I add special characters, chemical symbols etc??

by Mauno Korpelainen -

Adrian,

if you need a very simple way to test asciimath without modifying several files here you have one way to do it. Unzip the attached file "mascii.zip" and move those 4 tiny files to your moodle site. That's it - supposing your theme is either standard theme or is using meta tags of standard theme - most Moodle Themes do.

File theme/standard/meta.php has links to asciimathml fallback scripts and in folder lib/editor/common you have two versions of asciimathml fallback scripts - if you never need graphs or calculator test AMM.js instead of AMMimetex.js in theme meta.php - and if you don't use graphs you can delete also d.svg

Try to write `alpha` to see if AsciimathML works. Try some more examples from http://korpelainen.net/examples.txt

If you have problems with the following emoticons in equations:

smiley : )  smile
sad : (  sad
heart heart
yes ( y ) Yes
no ( n ) No
egg $$($$ $$)$$ egg

change them from Administration -> Appearance -> HTML editor to some other form like (yes), (oh no), (egg),...
---------------------------

And if http://schmoodle.alaskapolicy.net/cgi-bin/mimetex.cgi stops responding Marc has pulled the plug on...

Re: How can I add special characters, chemical symbols etc??

by Sharon Goodson -

Note to self: jmol, tiny mice, asciimathml, dragmath - no to doubledollars (I hate seeing those, especially in restaurant guides - so vague). I look forward to the move, if we can ever synchronize it. We're starting to have some real problems at our current host, primarily because they're a low-end singledollar outfit, suited for simpler, less intensive setups. 

But anyway, that's a great idea about the repository! And your rationale is 120% solid!

Re: How can I add special characters, chemical symbols etc??

by Marc Grober -
BTW Sharon,

I set up http://docs.moodle.org/en/Web_Hosts to provide for folks to provide details regarding their experiences with various web hosts. I would certainly like to see your comments regarding your experiences moving to your new web host, as well as any discussion of your service under your SLA (we are building some additional docs intended to help folks make intelligent decisions about web hosting ....)