DocumentTools[Canvas]
Math
create a math structure with metadata
Calling Sequence
Parameters
Description
Examples
Compatibility
Math(expression)
Math(expression, options)
expression
-
anything
position=[posint,posint]
(optional) absolute position of math
annotation=string
(optional) annotation
attributes=list(equation)
(optional) Maple-Learn math attributes
The Math command is used by GetMath when extracting math from a canvas. It packages a math expression up into a record where it can be saved alongside other information relevant to the context of the canvas application, such as the id, position, and annotation.
It can also be useful to use the Math command when constructing a canvas that will later be deployed to Maple Learn, especially when a non-default property is needed to change the behaviour and/or look of the math in the Learn canvas.
When the position option is given, the math will be located at those [x,y] pixel coordinates on the canvas.
When the annotation option is given, the math will have a text message beside it on the canvas.
When the attributes option is used, those attributes will be added to the MathML <math> tag. Some such attributes can control the behaviour and/or display of the expression when dispatched to Maple Learn via the ShareCanvas command. Most often these attributes are ignored by ShowCanvas. See the examples section for some examples of properties that are recognized.
with⁡DocumentTools:-Canvas:
The Math command simply returns a record detailing properties of the given expression. A significant property is called "math", and can be accessed via the colon-dash syntax.
m≔Math⁡x+y
m≔Record⁡type=math,mathml=<math xmlns='http://www.w3.org/1998/Math/MathML'><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow></math>,math=x+y,id=36893627797188378748,readonly=false,position=undefined,gridpos,box=,annotation=,dependency=,istext=false,container=group
m:-math
x+y
m:-mathml
<math xmlns='http://www.w3.org/1998/Math/MathML'><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow></math>
The ShowCanvas command respects some of the properties, like annnotation and position:
m2≔Math⁡x2+y2,position=600,100:
ShowCanvas⁡NewCanvas⁡m2
m3≔Math⁡x3+y3,annotation=Example 3:
ShowCanvas⁡NewCanvas⁡m3
Some tricks can be used to format the math, such as using InertForm to prevent automatic simplification. Here Typesetting:-mspace() is also used to create a blank:
m4≔Math⁡`%+`⁡1,1=Typesetting:-mspace⁡,readonly=true:
ShowCanvas⁡NewCanvas⁡m4
Incomplete expressions that can't be represented as a Maple data-structure can be written directly in MathML. Here is an example that leaves the numerator of a fraction blank.
m5≔Math⁡<math><mfrac><mspace/><mn>2</mn></mfrac></math>:
ShowCanvas⁡NewCanvas⁡m5
Other properties control behaviour only in the Maple Learn environment. Some of these are as follows:
cv6≔NewCanvas⁡Group⁡Text⁡Math Attributes:,Math⁡`%+`⁡x,1,1,Math⁡`%+`⁡x,1,1,attributes=readonly=true,annotation=Read-only,Math⁡`%+`⁡x,1,1,attributes=result=false,annotation=Turn off computation result,Math⁡`%+`⁡x,1,attributes=plot=false,annotation=Don't plot,Math⁡`%+`⁡x,1,attributes=text=true,annotation=Text,Math⁡`%+`⁡x,1,attributes=mathbackground=red,annotation=Background color,Math⁡`%+`⁡x,1,attributes=mathcolor=green,annotation=Font color:
ShareCanvas⁡cv6
When fetching a canvas from MapleLearn, the GetMath command calls Math(...) to create record structures.
url≔https://learn.maplesoft.com/#/?d=OULPGFDHIFNKDLJJGGMKJKNOARBJLHGRPOOKHKCQHPMFKMOTBFEHCUBUCQFNOGKSAMDOCUEFGMAJMQELFLEQEGOMETNULHFSCUGU:
cv≔GetCanvas⁡url:
M≔GetMath⁡cv:
M3:-math
M3:-id
M3:-annotation
M3:-position
The DocumentTools[Canvas][Math] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
See Also
Annotate
GetCanvas
NewCanvas
Script
ShareCanvas
Text
Download Help Document
What kind of issue would you like to report? (Optional)