moodle/lib/dragmath/doc/newformat.html

228 lines
14 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>DragMath Documentation - Adding an output format</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16525" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#000080 size=5><STRONG>Adding an output format</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2>
<p>
The formats supplied
are Maple,&nbsp;Latex, MathML and Maxima, with the corresponding files found in
the \formats folder. These files can be edited to reflect the syntax you prefer. These
files can also be used as templates for creating files for different formats.
There are a number of rules and options that you need to be aware of to
successfully create an XML file for a new format.</p>Each math object has
its own element in the XML document, with a familiar name describing it, for
example “Add”. Within this element there are a number of sub-elements depending
upon how many arguments the object has.</FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><BR>N-ary operators
have a single output element e.g. for addition this
is&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; <STRONG><FONT
color=#800080>&lt;Add&gt;</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<FONT color=#800080>&lt;output&gt;</FONT>+<FONT
color=#800080>&lt;/output&gt;<BR></FONT>&nbsp;&nbsp;&nbsp; <FONT
color=#800080>&lt;/Add&gt;<BR></FONT></STRONG><BR>Binary Operators have 3
output elements e.g. for fraction in Latex this is<BR>&nbsp;&nbsp;&nbsp; <FONT
color=#800080><STRONG>&lt;Divide</STRONG> <FONT
color=#000000>brackets=</FONT><FONT
color=#0000ff>"false"</FONT><STRONG>&gt;</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<STRONG><FONT color=#800080>&lt;output1&gt;</FONT>\frac<FONT color=#800080><FONT
color=#000000>{</FONT>&lt;/output1&gt;</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<FONT color=#800080>&lt;output2&gt;</FONT>}{<FONT
color=#800080>&lt;/output2&gt;<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<FONT color=#800080>&lt;output3&gt;</FONT>}<FONT
color=#800080>&lt;/output3&gt;<BR></FONT>&nbsp;&nbsp;&nbsp; <FONT
color=#800080>&lt;/Divide&gt;</FONT><BR></STRONG><BR>Functions have 2 output
elements e.g. for square root in Latex this is<BR>&nbsp;&nbsp;<STRONG>&nbsp;
</STRONG><FONT color=#800080><STRONG>&lt;SquareRoot</STRONG> <FONT
color=#000000>brackets=</FONT><FONT
color=#0000ff>"false"</FONT><STRONG>&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt;<FONT
color=#000000>\sqrt{</FONT>&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output2&gt;<FONT
color=#000000>}</FONT>&lt;/output2&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/SquareRoot&gt;</STRONG></FONT><BR><BR></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2>N-ary functions have 'n' output elements
e.g. for definite integral in Latex it has
5</FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2>&nbsp;&nbsp;&nbsp;
<FONT color=#800080><STRONG>&lt;DefiniteIntegral</STRONG> <FONT
color=#000000>reverse=</FONT><FONT
color=#0000ff>"true"</FONT><STRONG>&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt;&nbsp;&nbsp;<FONT
color=#000000>\int_{</FONT>&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output2&gt;<FONT
color=#000000>}^{</FONT>&lt;/output2&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output3&gt;<FONT
color=#000000>}</FONT>&lt;/output3&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output4&gt;<FONT
color=#000000>\,\mathrm{d</FONT>&lt;/output4&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output5&gt;<FONT
color=#000000>}</FONT>&lt;/output5&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/DefiniteIntegral&gt;</STRONG></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT
size=2></FONT></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV></DIV>
<DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2>Symbols have 1 output element e.g. for
Infinity in Latex this is<BR>&nbsp;&nbsp;<STRONG>&nbsp;<FONT color=#800080>
&lt;Infinity&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output&gt;<FONT
color=#000000>\infty</FONT>&lt;/output&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/Infinity&gt;</FONT></STRONG><BR><BR>Groupings have 2 output elements e.g.
for square brackets in Latex this is<BR>&nbsp;&nbsp;&nbsp; <FONT
color=#800080><STRONG>&lt;BracketsSq&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt;<FONT
color=#000000>\left[</FONT>&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output2&gt;<FONT
color=#000000>\right]</FONT>&lt;/output2&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/BracketsSq&gt;</STRONG><BR></FONT><BR>Matrix in Latex is as
follows:<BR>&nbsp;&nbsp;&nbsp; <STRONG><FONT
color=#800080>&lt;Matrix&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;matrixStart&gt;<FONT color=#000000>\left(
\begin{array}{ccc}</FONT>&lt;/matrixStart&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;rowStart /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;elementStart /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;elementEnd /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;elementSeparator&gt;<FONT color=#808000>&lt;![CDATA[ &amp;
]]&gt;</FONT>&lt;/elementSeparator&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;rowEnd&gt;&nbsp;<FONT
color=#000000>\\</FONT>&nbsp;&lt;/rowEnd&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;rowSeparator /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;matrixEnd&gt;<FONT color=#000000>\end{array}
\right)</FONT>&lt;/matrixEnd&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/Matrix&gt;</FONT></STRONG><BR><BR><BR>The syntax within these tags is used
when converting an expression to that particular format. The actual arguments of
the objects appear in the syntax between each pair of tags. For example consider
½ in Latex format.&nbsp; It has 3 output elements. So the first part will be
\frac{, then the first argument will be appended to the string giving us,
\frac{1, then the 2nd output will be appended, \frac{1}{, then the 2nd
argment, \frac{1}{2 and then the final output, \frac{1}{2}. A similar process
takes place with all the object types of objects, with the argument being
appended between each pair of output elements.<BR><BR>There are various options
that can be set to allow more control over the
output.</FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT
size=2></FONT></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2><U>Reverse</U><BR>If you find the arguments
of a binary operator&nbsp;being output in the wrong order for a format, you can
reverse the order of them by setting, reverse=”true”. An example of this is with
the N-th root in Latex,<BR>&nbsp;&nbsp;&nbsp; <FONT
color=#800080><STRONG>&lt;NthRoot</STRONG> <FONT
color=#000000>reverse=</FONT><FONT color=#0000ff>"true"</FONT> <FONT
color=#000000>brackets=</FONT><FONT
color=#0000ff>"false"</FONT><STRONG>&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt;<FONT color=#000000>\sqrt[</FONT>
&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output2&gt;<FONT
color=#000000>]{</FONT>&lt;/output2&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output3&gt;<FONT
color=#000000>}</FONT>&lt;/output3&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/NthRoot&gt;</STRONG></FONT><BR><U></U></FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT
size=2><U></U></FONT></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><U>Argument Order</U></DIV>
<DIV>If you find the arguments of an N-ary Function being output in the wrong
order for a format, you can re-arrange the order of them by setting,
order=”#1,#2,#3,...,#n”. An example of this is with the&nbsp;Sum in Latex.
Obviously, the default order&nbsp;for this is&nbsp;0,1,2,3, and it is being
changed to 1,2,3,0.<BR>&nbsp;&nbsp;&nbsp; <FONT
color=#800080><STRONG>&lt;Sum</STRONG> <FONT color=#000000>order=</FONT><FONT
color=#0000ff>"1,2,3,0"</FONT><STRONG>&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt; <FONT
color=#000000>\sum_{{</FONT>&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output2&gt;<FONT
color=#000000>}={</FONT>&lt;/output2&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output3&gt;<FONT
color=#000000>}}^{</FONT>&lt;/output3&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output4&gt;<FONT
color=#000000>}</FONT>&lt;/output4&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output5&gt;&lt;/output5&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/Sum&gt;</STRONG></FONT><BR></DIV><br>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2><U>AutoBrackets</U><BR>By default, round
brackets are placed around n-ary operators and binary operators where necessary
to ensure operator precedence is preserved. For presentational formats, such as
Latex this is often unnecessary, so there is the option to turn automatic
placing of brackets on/off. This is set in the element that specifies the name
of the format. An example of this is shown for
Latex,</FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2>&nbsp;&nbsp;&nbsp; <FONT
color=#800080><STRONG>&lt;name</STRONG> <FONT
color=#000000>AutoBrackets=</FONT><FONT
color=#0000ff>"false"</FONT><STRONG>&gt;<FONT
color=#000000>Latex</FONT>&lt;/name&gt;</STRONG></FONT><BR><U></U></FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT
size=2><U></U></FONT></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2><U>Brackets on Functions<BR></U>Brackets
are added by default around the argument of a function. For example Sine in
Latex is,<BR>&nbsp;&nbsp;&nbsp; <STRONG><FONT
color=#800080>&lt;Sine&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt;<FONT color=#000000>\sin</FONT>
&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;output2
/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/Sine&gt;</FONT></STRONG><BR><BR>Brackets are
automatically added after the \sin and after the 2nd output, resulting in
"\sin(arg)". This is often the desired result but if you need to turn the
brackets off, they can be set for each individual function. An example of
turning them off is shown here for Square root in
Latex,<BR>&nbsp;&nbsp;<STRONG>&nbsp; </STRONG><FONT
color=#800080><STRONG>&lt;SquareRoot</STRONG> <FONT
color=#000000>brackets=</FONT><FONT
color=#0000ff>"false"</FONT><STRONG>&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output1&gt;<FONT
color=#000000>\sqrt{</FONT>&lt;/output1&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output2&gt;<FONT
color=#000000>}</FONT>&lt;/output2&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/SquareRoot&gt;</STRONG></FONT><BR><U></U></FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT
size=2><U></U></FONT></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2><U>Initial</U><BR>As well as the structured
number of output elements for each type of object, there is the option of having
an initial element. The data in this element is added to the string before any
other output element is. An example of its use for describing multiplication in
MathML Content is shown below.<BR>&nbsp;&nbsp;&nbsp; <STRONG><FONT
color=#800080>&lt;Add&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;initial&gt;<FONT
color=#000000>&lt;times/&gt;</FONT>&lt;/initial&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output&lt;/output&gt;&nbsp;<BR>&nbsp;&nbsp;&nbsp;
&lt;/Add&gt;<BR></FONT></STRONG><BR>&nbsp;a x b x c would then be converted
to,<BR>&nbsp;&nbsp;&nbsp;
&lt;times/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;ci&gt;a&lt;/ci&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;ci&gt;b&lt;/ci&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;ci&gt;c&lt;/ci&gt; </FONT></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><U><FONT face=Arial
size=2></FONT></U></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><U><FONT face=Arial
size=2>Final</FONT></U></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial size=2>N-ary operators can also have an optional 'final'
element for adding data after everything else. An example of this is with Union
in Maxima.</FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2>&nbsp;&nbsp;&nbsp; <STRONG><FONT
color=#800080>&lt;Union&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;initial&gt;<FONT
color=#000000>union(</FONT>&lt;/initial&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;output&gt;<FONT
color=#000000>,</FONT>&lt;/output&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;final&gt;<FONT color=#000000>)</FONT>&lt;/final&gt;<BR>&nbsp;&nbsp;&nbsp;
&lt;/Union&gt;</FONT></STRONG></FONT></FONT></FONT></FONT></DIV></DIV></FONT></FONT></DIV></FONT></DIV></FONT></DIV></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face=Arial size=2><FONT face=Arial
size=2><FONT face=Arial size=2><FONT face=Arial><FONT size=2><FONT face=Arial
size=2><FONT face=Arial><FONT size=2><FONT face=Arial size=2><SPAN
class=875382513-08082007>&nbsp;</DIV></SPAN></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></BODY></HTML>