Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Using MimeTeX.

Using MimeTeX: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 1: Line 1:
{Please remove}
{{Please remove}}





Revision as of 12:46, 13 July 2010

Template:Please remove


The Tex Notation system in Moodle 1.9.x and now in Moodle 2.0 is not a true TeX notation system. It is a "failsafe" or a "fallback" to ensure that Users can produce a passable maths markup language document. Using it is not simple, yet this is not a Moodle issue, but rather the issue lies with the manner in which TeX notation has developed. The various brands of TeX and other math markup languages have become something of a nightmare to try and find any reasonable consistency. Most use sub-sets and variations of TeX rules and fonts and symbols that seem to be developed on the whim of the developer rather than any consistent mathematical strategy. Also the lack of user friendly documentation has worked against the easy spread of knowledge here, but what is worse, and this is the problem for the Moodle Community, the lack of directly related documentation in using TeX Notation in Moodle has not been helpful. (Having said these things, I am sure that many people will disagree - but I accept there is a large difference between what the developers of the various TeX "standards" consider "consistent" and reality..:) )

Please help by adding your own examples and rules to these pages. If you notice an error, please change it, if you see something missing, please add it.

TeX Notation in Moodle

For the most part, the TeX Notation has been built using a sub-set of characters from the TeX "default" character set. The trouble is there does not seem to be a "default" character set for TeX. This is one of the most confusing aspects of using TeX Notation in Moodle. When we realise that the documentation we are using is related to the creation of printed documents, and we want to use TeX on line, in Moodle, then further problems occur. There are no environment statements to be made. There are no \begins and \ends. If you go to Administration > Modules > Filters > Filter Manager you will see what filters have been enabled. If you then go to the TeX Notation page, the default preamble is written there and is editable via the text box. You can add in or subtract font packages. You can change the default font package. The issue here also seems to be that to use other fonts you need to install a full TeX notation system other than the TeX Notation system for the fonts to change.

A precise, i.e. simple, description of how to do that would be nice here..:)

Which would, if clearer, provide a nice little tool for developing local strategies for responding to your student needs.

Language Conventions

To invoke the TeX filter is to use the $$ symbols to open and close statements. To invoke a particular command or control sequence, use the backslash, \. A typical control sequence looks like:

 $$ x \ = \ \frac{\sqrt{144}}{2} \ \times \ (y \ + \ 12) $$  
cfmimetex10.gif
Fraction and square root.

Additional spaces are placed into the equation by using the \ without a leading or trailing character. Escape characters, of which there are a few in Moodle's TeX Notation, have the \ in front of them. These are usually set aside for reserved characters.

Available Characters

There seems to be a number of differences between what characters are available in Moodle and what are not. There also seems to be great discrepancies between what the manuals tell you is available and what actually is available. Using MimeTeX 2 shows a lot of what is available, but not all.

Windows and TeX

Using TeX in Windows is simpler than it used to be. Download and install a TeX for Windows program, like MikTeX. (MikTeX is probably the most useful at this point in time for Windows Users.) Also, a graphics package is required for rendering the scripted TeX statements into images, and probably the most readily available and easily installable program useful for this purpose would be ImageMagick. While there may be better programs available for these purposes, these are the most immediately useful. They are easily installed and configured.

Reserved Characters and Keywords

Most characters and numbers on the keyboard can be used at their default value. As with any computing language, though, there are a set of reserved characters and keywords that are used by the program for its own purposes. TeX Notation is no different, but it does have a very small set of Reserved Characters. This will not be a complete list of reserved characters, but some of these are:

 @ # $ % ^ & * ( ) . 

To use these characters in an equation just place the \ in front of them \$ or \%. If you want to use the backslash, just use \backslash. The only exception here seems to be the &, ampersand. See the characters listed in Using MimeTeX 2 for more details.

The Keywords, they are different. There is only one that is of concern here and that it the word "line". If the \line control sequence, or command, is not properly implemented, then the consequences can be indeterminate. Controlling lines is an adventure of its own, so getting it right when written is important, you can always reposition the line, but you might get it really wrong if you do not use it with some caution. To use the \line control sequence, go to your text editor, open the filter\lib.php file, and at about line 48, you will see the word "\line". Delete it from the list. If you do not have direct access to the server, then the whole thing becomes problematic. You may want to download and install your own Moodle and develop things there rather than on your production site. You can write things out in your own Moodle, render the statement, save the image and then upload it to your production site. If something goes seriously wrong, it is easier to restart your own Moodle than it is your production site.

WARNING: If you get a dimension wrong on a line, it can actually prevent you from creating any new TeX. You will see the offending control sequence in its natural state. Everything that you have written to that point will work, but nothing you have written after that will.

Maths Mode

A full TeX version has two modes, a "text mode" and a "maths mode" and Moodle stays in maths mode. Perhaps a better description of what happens is that Moodle allows a writer to enter maths mode when the $$ symbols are written and leave it when the $$ symbol appears a second time.

Superscripts, Subscripts and Roots

Superscripts are recorded using the caret, ^, symbol. An example for a Maths class might be:

 $$ 4^2 \ \times \ 4^3 \ = 4^5 $$
 This is a shorthand way of saying: 
 (4 x 4) x (4 x 4 x 4) = (4 x 4 x 4 x 4 x 4)
 or
 16 x 64 = 1024.
 
 


Subscripts are similar, but use the underscore character.

 $$ 3x_2 \ \times \ 2x_3 $$
 
 

This is OK if you want superscripts or subscripts, but square roots are a little different. This uses a control sequence.

 $$ \sqrt{64} \ = \ 8 $$
 
 

You can also take this a little further, but adding in a control character. You may ask a question like:

 $$ If \ \sqrt[n]{1024} \ = \ 4, \ what \ is \ the \ value \ of \ n? $$  
 
  

Using these different commands allows you to develop equations like:

 $$ The \sqrt{64} \ \times \ 2 \ \times \ 4^3 \ = \ 1024 $$
 
 

Fractions

Fractions in TeX are actually simple, as long as you remember the rules.

 $$ \frac{numerator}{denominator} $$ which produces  .

This can be given as:

 .

This is entered as:

 $$ \frac{5}{10} \ is \ equal \ to \ \frac{1}{2}.$$

See Also

Using TeX Notation