Prob with TeX vs Drag Math

Prob with TeX vs Drag Math

by jeff ciaccio -
Number of replies: 4

I am using Moodle 2.0

I have entered an equation using just TeX, but I get question marks as if it cannot interpret something correctly.

When I do it in drag math, I get exactly the same statement when I insert it into a text field, but it renders correctly.

Here is the input.  Notice the only difference in the top and bottom TeX is some white space.  Does that matter? 

Here is the output.

Why do I get all the question marks when inputting directly?  Is there a way to fix this?  I'd like to use GIFT to import some questions, but not if they won't render correctly.  

Thanks! 

Average of ratings: -
In reply to jeff ciaccio

Re: Prob with TeX vs Drag Math

by jeff ciaccio -

After playing around with it, I realized it IS a white space issue.

I found a tutorial that said white space was not important, so can somebody please tell me where I can find a good tutorial on TeX as used for math in Moodle including white space rules?

Thanks! - Jeff C 

In reply to jeff ciaccio

Re: Prob with TeX vs Drag Math

by Mauno Korpelainen -

There is no one version/one syntax/one distribution of LaTeX or TeX...each distribution can handle white spaces in a different way, as a common rule you should never write such code inside tokens that is not latex/tex - no html tags, no css, no html entities, no white spaces.

In fact when you use moodle 2 and tinymce you don't see things Wysiwyg - if you add more than one "normal space" in editor mode tinymce changes the additional spaces to non breaking spaces even though in editor content area it looks like they were normal spaces (but no   shown):

$$\alpha        \beta$$

 If you press HTML button and add extra spaces in code mode tinymce strips extra spaces and you get

$$\alpha \beta$$

 and single spaces are in most cases ignored.

If you disable editor from your profile you are able to add as many normal spaces as possible and they are not stripped but they are still ignored by latex this time and you see

$$\alpha \beta$$ even if there are lots of normal spaces between alpha and beta

and finally here an example about different kinds of spaces added as html entities in text mode and converted by moodle so that in source you see just spaces but latex code tells that something there is not "normal" - the evil whitespaces smile

$$\alpha            ​   \beta$$

In reply to Mauno Korpelainen

Re: Prob with TeX vs Drag Math

by Ravi Vare -

Hei Mauno,

I am facing same problem (especially in moodle 2.1)

[We have discussed it]

Is there any remedies?

...Without disable any HTML editor?

Best regards,

Ravi

P.S.

By removing spaces in code of maths expression,

It renders properly.

In reply to Ravi Vare

Re: Prob with TeX vs Drag Math

by Mauno Korpelainen -

You can in most cases press the HTML button in Tinymce toolbar and add (copied) latex there

HTML

The main problem in writing latex in editor mode is that the first space given by your keyboard is usually unicode character "space" (U+0020) - the same character that you get with html entity   or   - but Tinymce is using a workaround for adding several spaces in queue and it converts the following spaces (after the first space) to nonbreaking spaces ( ) even if you don't see the difference in editor content area. And Latex syntax can ignore normal spaces but it does not understand what nonbreaking spaces are and shows odd characters...

The other possible way to get whitespaces to your editor mode is to copy latex examples from some web pages and there can be for example line breaks etc in the visible code - or bold, italics, red, font size 16px,...any css tags that are used to make the code look more pleasant and you may need to copy the examples first to some simple texteditor (notepad) or use the Paste as plain text-plugin. Still it does not always work since many unicode characters can look like "normal spaces" or they may be invisible whitespaces like in that previous (last) example.

Most math plugins strip some unicode spaces but do not try to strip all possible whitespaces.

Testing Dragmath: $$a+b+a   + b$$

As you can see it is possible to add whitespaces directly in Dragmath - and dragmath is always used in editor mode smile

 

Average of ratings: Useful (1)