 DocumentTools/Canvas/Math - Maple Help

DocumentTools[Canvas]

 Math
 create a math structure with metadata Calling Sequence Math(expression) Math(expression, options) Parameters

 expression - anything position=[posint,posint] - (optional) absolute position of math annotation=string - (optional) annotation attributes=list(equation) - (optional) Maple-Learn math attributes Description

 • 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 [itex] 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. Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Canvas}\right):$

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≔\mathrm{Math}\left(x+y\right)$
 ${m}{≔}{\mathrm{Record}}{}\left({\mathrm{type}}{=}{"math"}{,}{\mathrm{mathml}}{=}{"x+y\left[/itex\right]"}{,}{\mathrm{math}}{=}{x}{+}{y}{,}{\mathrm{id}}{=}{36893627797188378748}{,}{\mathrm{readonly}}{=}{\mathrm{false}}{,}{\mathrm{position}}{=}{\mathrm{undefined}}{,}{\mathrm{gridpos}}{,}{\mathrm{box}}{=}{""}{,}{\mathrm{annotation}}{=}{""}{,}{\mathrm{dependency}}{=}\left(\right){,}{\mathrm{istext}}{=}{\mathrm{false}}{,}{\mathrm{container}}{=}{"group"}\right)$ (1)
 > $m:-\mathrm{math}$
 ${x}{+}{y}$ (2)
 > $m:-\mathrm{mathml}$
 ${"x+y\left[/itex\right]"}$ (3)

The ShowCanvas command respects some of the properties, like annnotation and position:

 > $\mathrm{m2}≔\mathrm{Math}\left(x\left[2\right]+y\left[2\right],\mathrm{position}=\left[600,100\right]\right):$
 > $\mathrm{ShowCanvas}\left(\mathrm{NewCanvas}\left(\left[\mathrm{m2}\right]\right)\right)$
 > $\mathrm{m3}≔\mathrm{Math}\left(x\left[3\right]+y\left[3\right],\mathrm{annotation}="Example 3"\right):$
 > $\mathrm{ShowCanvas}\left(\mathrm{NewCanvas}\left(\left[\mathrm{m3}\right]\right)\right)$

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:

 > $\mathrm{m4}≔\mathrm{Math}\left(\mathrm{%+}\left(1,1\right)=\mathrm{Typesetting}:-\mathrm{mspace}\left(\right),\mathrm{readonly}=\mathrm{true}\right):$
 > $\mathrm{ShowCanvas}\left(\mathrm{NewCanvas}\left(\left[\mathrm{m4}\right]\right)\right)$

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.

 > $\mathrm{m5}≔\mathrm{Math}\left("\left[itex\right]2\left[/itex\right]"\right):$
 > $\mathrm{ShowCanvas}\left(\mathrm{NewCanvas}\left(\left[\mathrm{m5}\right]\right)\right)$

Other properties control behaviour only in the Maple Learn environment.  Some of these are as follows:

 > $\mathrm{cv6}≔\mathrm{NewCanvas}\left(\left[\mathrm{Group}\left(\left[\mathrm{Text}\left("Math Attributes:"\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1,1\right)\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1,1\right),\mathrm{attributes}=\left[\mathrm{readonly}=\mathrm{true}\right],\mathrm{annotation}="Read-only"\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1,1\right),\mathrm{attributes}=\left[\mathrm{result}=\mathrm{false}\right],\mathrm{annotation}="Turn off computation result"\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1\right),\mathrm{attributes}=\left[\mathrm{plot}=\mathrm{false}\right],\mathrm{annotation}="Don\text{'}t plot"\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1\right),\mathrm{attributes}=\left["text"="true"\right],\mathrm{annotation}="Text"\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1\right),\mathrm{attributes}=\left[\mathrm{mathbackground}="red"\right],\mathrm{annotation}="Background color"\right),\mathrm{Math}\left(\mathrm{%+}\left(x,1\right),\mathrm{attributes}=\left[\mathrm{mathcolor}="green"\right],\mathrm{annotation}="Font color"\right)\right]\right)\right]\right):$
 > $\mathrm{ShareCanvas}\left(\mathrm{cv6}\right)$

When fetching a canvas from MapleLearn, the GetMath command calls Math(...) to create record structures.

 > $\mathrm{url}≔"https://learn.maplesoft.com/#/?d=OULPGFDHIFNKDLJJGGMKJKNOARBJLHGRPOOKHKCQHPMFKMOTBFEHCUBUCQFNOGKSAMDOCUEFGMAJMQELFLEQEGOMETNULHFSCUGU":$
 > $\mathrm{cv}≔\mathrm{GetCanvas}\left(\mathrm{url}\right):$
 > $M≔\mathrm{GetMath}\left(\mathrm{cv}\right):$
 > $M\left[3\right]:-\mathrm{math}$
 > $M\left[3\right]:-\mathrm{id}$
 > $M\left[3\right]:-\mathrm{annotation}$
 > $M\left[3\right]:-\mathrm{position}$ Compatibility

 • The DocumentTools[Canvas][Math] command was introduced in Maple 2021.