mirror of
https://github.com/moodle/moodle.git
synced 2025-02-22 02:49:53 +01:00
228 lines
14 KiB
HTML
228 lines
14 KiB
HTML
<!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, 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 <BR> <STRONG><FONT
|
||
color=#800080><Add></FONT><BR>
|
||
<FONT color=#800080><output></FONT>+<FONT
|
||
color=#800080></output><BR></FONT> <FONT
|
||
color=#800080></Add><BR></FONT></STRONG><BR>Binary Operators have 3
|
||
‘output’ elements e.g. for fraction in Latex this is<BR> <FONT
|
||
color=#800080><STRONG><Divide</STRONG> <FONT
|
||
color=#000000>brackets=</FONT><FONT
|
||
color=#0000ff>"false"</FONT><STRONG>></STRONG></FONT><BR>
|
||
<STRONG><FONT color=#800080><output1></FONT>\frac<FONT color=#800080><FONT
|
||
color=#000000>{</FONT></output1></FONT><BR>
|
||
<FONT color=#800080><output2></FONT>}{<FONT
|
||
color=#800080></output2><BR></FONT>
|
||
<FONT color=#800080><output3></FONT>}<FONT
|
||
color=#800080></output3><BR></FONT> <FONT
|
||
color=#800080></Divide></FONT><BR></STRONG><BR>Functions have 2 ‘output’
|
||
elements e.g. for square root in Latex this is<BR> <STRONG>
|
||
</STRONG><FONT color=#800080><STRONG><SquareRoot</STRONG> <FONT
|
||
color=#000000>brackets=</FONT><FONT
|
||
color=#0000ff>"false"</FONT><STRONG>><BR>
|
||
<output1><FONT
|
||
color=#000000>\sqrt{</FONT></output1><BR>
|
||
<output2><FONT
|
||
color=#000000>}</FONT></output2><BR>
|
||
</SquareRoot></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>
|
||
<FONT color=#800080><STRONG><DefiniteIntegral</STRONG> <FONT
|
||
color=#000000>reverse=</FONT><FONT
|
||
color=#0000ff>"true"</FONT><STRONG>><BR>
|
||
<output1> <FONT
|
||
color=#000000>\int_{</FONT></output1><BR>
|
||
<output2><FONT
|
||
color=#000000>}^{</FONT></output2><BR>
|
||
<output3><FONT
|
||
color=#000000>}</FONT></output3><BR>
|
||
<output4><FONT
|
||
color=#000000>\,\mathrm{d</FONT></output4><BR>
|
||
<output5><FONT
|
||
color=#000000>}</FONT></output5><BR>
|
||
</DefiniteIntegral></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> </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> <STRONG> <FONT color=#800080>
|
||
<Infinity><BR>
|
||
<output><FONT
|
||
color=#000000>\infty</FONT></output><BR>
|
||
</Infinity></FONT></STRONG><BR><BR>Groupings have 2 ‘output’ elements e.g.
|
||
for square brackets in Latex this is<BR> <FONT
|
||
color=#800080><STRONG><BracketsSq><BR>
|
||
<output1><FONT
|
||
color=#000000>\left[</FONT></output1><BR>
|
||
<output2><FONT
|
||
color=#000000>\right]</FONT></output2><BR>
|
||
</BracketsSq></STRONG><BR></FONT><BR>Matrix in Latex is as
|
||
follows:<BR> <STRONG><FONT
|
||
color=#800080><Matrix><BR>
|
||
<matrixStart><FONT color=#000000>\left(
|
||
\begin{array}{ccc}</FONT></matrixStart><BR>
|
||
<rowStart /><BR>
|
||
<elementStart /><BR>
|
||
<elementEnd /><BR>
|
||
<elementSeparator><FONT color=#808000><![CDATA[ &
|
||
]]></FONT></elementSeparator><BR>
|
||
<rowEnd> <FONT
|
||
color=#000000>\\</FONT> </rowEnd><BR>
|
||
<rowSeparator /><BR>
|
||
<matrixEnd><FONT color=#000000>\end{array}
|
||
\right)</FONT></matrixEnd><BR>
|
||
</Matrix></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. 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> </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 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> <FONT
|
||
color=#800080><STRONG><NthRoot</STRONG> <FONT
|
||
color=#000000>reverse=</FONT><FONT color=#0000ff>"true"</FONT> <FONT
|
||
color=#000000>brackets=</FONT><FONT
|
||
color=#0000ff>"false"</FONT><STRONG>><BR>
|
||
<output1><FONT color=#000000>\sqrt[</FONT>
|
||
</output1><BR>
|
||
<output2><FONT
|
||
color=#000000>]{</FONT></output2><BR>
|
||
<output3><FONT
|
||
color=#000000>}</FONT></output3><BR>
|
||
</NthRoot></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> </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 Sum in Latex.
|
||
Obviously, the default order for this is 0,1,2,3, and it is being
|
||
changed to 1,2,3,0.<BR> <FONT
|
||
color=#800080><STRONG><Sum</STRONG> <FONT color=#000000>order=</FONT><FONT
|
||
color=#0000ff>"1,2,3,0"</FONT><STRONG>><BR>
|
||
<output1> <FONT
|
||
color=#000000>\sum_{{</FONT></output1><BR>
|
||
<output2><FONT
|
||
color=#000000>}={</FONT></output2><BR>
|
||
<output3><FONT
|
||
color=#000000>}}^{</FONT></output3><BR>
|
||
<output4><FONT
|
||
color=#000000>}</FONT></output4><BR>
|
||
<output5></output5><BR>
|
||
</Sum></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> <FONT
|
||
color=#800080><STRONG><name</STRONG> <FONT
|
||
color=#000000>AutoBrackets=</FONT><FONT
|
||
color=#0000ff>"false"</FONT><STRONG>><FONT
|
||
color=#000000>Latex</FONT></name></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> </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> <STRONG><FONT
|
||
color=#800080><Sine><BR>
|
||
<output1><FONT color=#000000>\sin</FONT>
|
||
</output1><BR> <output2
|
||
/><BR> </Sine></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> <STRONG> </STRONG><FONT
|
||
color=#800080><STRONG><SquareRoot</STRONG> <FONT
|
||
color=#000000>brackets=</FONT><FONT
|
||
color=#0000ff>"false"</FONT><STRONG>><BR>
|
||
<output1><FONT
|
||
color=#000000>\sqrt{</FONT></output1><BR>
|
||
<output2><FONT
|
||
color=#000000>}</FONT></output2><BR>
|
||
</SquareRoot></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> </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> <STRONG><FONT
|
||
color=#800080><Add> <BR>
|
||
<initial><FONT
|
||
color=#000000><times/></FONT></initial><BR>
|
||
<output</output> <BR>
|
||
</Add><BR></FONT></STRONG><BR> ‘a x b x c’ would then be converted
|
||
to,<BR>
|
||
<times/><BR>
|
||
<ci>a</ci><BR>
|
||
<ci>b</ci><BR>
|
||
<ci>c</ci> </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> </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> <STRONG><FONT
|
||
color=#800080><Union><BR>
|
||
<initial><FONT
|
||
color=#000000>union(</FONT></initial><BR>
|
||
<output><FONT
|
||
color=#000000>,</FONT></output><BR>
|
||
<final><FONT color=#000000>)</FONT></final><BR>
|
||
</Union></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> </DIV></SPAN></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></BODY></HTML>
|