Math Container Component - Maple Help

Home : Support : Online Help : Programming : Document Tools : Components : Math Container Component

DocumentTools[Components]

 MathContainer
 generate XML for a MathContainer Component

 Calling Sequence MathContainer( expr, opts )

Parameters

 expr - (optional) algebraic; an expression. opts - (optional) ; one or more keyword options as described below

Options

 • autofit : truefalse:=false; Indicates whether the component will automatically resize to fit its contents. The default value is false.
 • fillcolor : {list(nonnegint),symbol,string}:=[255,255,255] ; Specifies the background color of the component. The passed value can be either a named color or a list of three integers each between 0 and 255. A list of nonnegative integers is interpreted as RGB values in a 24bit 3-channel color space. The default value is [255,255,255] which corresponds to white.
 • height  posint:=200; The height in pixels of the component. The default value is 200.
 • width  posint:=300; The width in pixels of the component. The default value is 300.
 • minheight  nonnegint:=0; The minimum height in pixels of the component when autofit = true. The default value is 0.
 • minwidth  nonnegint:=0; The minimum width in pixels of the component when autofit = true. The default value is 0.
 • identity : {name,string}; The reference name of the component.
 • scrolldown  truefalse:=false; Specifies whether the component will automatically scroll down when its contents are set, when autofit = false. The default value is false.
 • showborders : truefalse:=true; Indicates whether the components borders will be shown. The default value is true.
 • value : string ; MathML representation of the content expression. This option can only be used if no expression argument expr is passed.
 • visible : truefalse; Indicates whether the component is visible. The default is true.

Description

 • The MathContainer command in the Component Constructors package returns an XML function call which represents a MathContainer Component.
 • The generated XML can be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document can be inserted into the current document using the InsertContent command.

Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Components}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$
 > $e≔\mathrm{sqrt}\left(x\right)$
 ${e}{≔}\sqrt{{x}}$ (1)

Executing the MathContainer command produces a function call.

 > $S≔\mathrm{MathContainer}\left(e,\mathrm{identity}="MathContainer0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-MathContainer}}{}\left({"id"}{=}{"MathContainer0"}{,}{"pixel-width"}{=}{"300"}{,}{"pixel-height"}{=}{"200"}{,}{"dag"}{=}{"LUkmbXNxcnRHNiQlKnByb3RlY3RlZEcvJSttb2R1bGVuYW1lR0ksVHlwZXNldHRpbmdHNiRGJSUoX3N5c2xpYkc2Iy1JI21pRzYkRiUvRidGKDYjUSJ4NiI="}{,}{"visible"}{=}{"true"}{,}{"show-border"}{=}{"true"}{,}{"scroll-down"}{=}{"false"}{,}{"autofit"}{=}{"false"}{,}{"minimum-pixel-width"}{=}{"0"}{,}{"minimum-pixel-height"}{=}{"0"}{,}{"fillcolor"}{=}{"\left[255,255,255\right]"}\right)$ (2)

By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.

 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

That XML representation of a worksheet can be inserted directly.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > $S≔\mathrm{MathContainer}\left(\mathrm{sqrt}\left(y\right),\mathrm{identity}="MathContainer0",\mathrm{autofit}\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

The previous example's call to the InsertContent command inserted a component with identity "MathContainer0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "MathContainer0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

 > $\mathrm{lookup}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right)$
 ${\mathrm{lookup}}{≔}{table}{}\left(\left[{"MathContainer0"}{=}{"MathContainer1"}\right]\right)$ (3)

 > $\mathrm{lookup}\left["MathContainer0"\right]$
 ${"MathContainer1"}$ (4)
 > $\mathrm{GetProperty}\left(\mathrm{lookup}\left["MathContainer0"\right],\mathrm{expression}\right)$
 $\sqrt{{y}}$ (5)

The fillcolor can be specified to match that of a parent Table Cell.

 > $\mathrm{exprs}≔\mathrm{FunctionAdvisor}\left(\mathrm{sin},\mathrm{identities},\mathrm{quiet}\right)$
 ${\mathrm{exprs}}{≔}\left[{\mathrm{sin}}{}\left({\mathrm{arcsin}}{}\left({z}\right)\right){=}{z}{,}{\mathrm{sin}}{}\left({z}\right){=}{-}{\mathrm{sin}}{}\left({-}{z}\right){,}{\mathrm{sin}}{}\left({z}\right){=}{2}{}{\mathrm{sin}}{}\left(\frac{{z}}{{2}}\right){}{\mathrm{cos}}{}\left(\frac{{z}}{{2}}\right){,}{\mathrm{sin}}{}\left({z}\right){=}\frac{{1}}{{\mathrm{csc}}{}\left({z}\right)}{,}{\mathrm{sin}}{}\left({z}\right){=}\frac{{2}{}{\mathrm{tan}}{}\left(\frac{{z}}{{2}}\right)}{{1}{+}{{\mathrm{tan}}{}\left(\frac{{z}}{{2}}\right)}^{{2}}}{,}{\mathrm{sin}}{}\left({z}\right){=}{-}\frac{{I}}{{2}}{}\left({{ⅇ}}^{{I}{}{z}}{-}{{ⅇ}}^{{-I}{}{z}}\right){,}{{\mathrm{sin}}{}\left({z}\right)}^{{2}}{=}{1}{-}{{\mathrm{cos}}{}\left({z}\right)}^{{2}}{,}{{\mathrm{sin}}{}\left({z}\right)}^{{2}}{=}\frac{{1}}{{2}}{-}\frac{{\mathrm{cos}}{}\left({2}{}{z}\right)}{{2}}\right]$ (6)
 > $S≔\mathrm{seq}\left(\mathrm{MathContainer}\left(\mathrm{identity}=\mathrm{cat}\left("MathContainer",i\right),\mathrm{autofit},\mathrm{showborders}=\mathrm{false},\mathrm{fillcolor}="#ddeeff"\right),i=1..\mathrm{numelems}\left(\mathrm{exprs}\right)\right):$\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Table}\left(\mathrm{alignment}=\mathrm{center},\mathrm{width}=300,\mathrm{widthmode}=\mathrm{pixels},\mathrm{Column}\left(\right),\mathrm{seq}\left(\mathrm{Row}\left(\mathrm{Cell}\left(\mathrm{Textfield}\left(s\right),\mathrm{fillcolor}="#ddeeff"\right)\right),s=S\right)\right)\right):
 > $\mathrm{cmptab}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right):$$\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{numelems}\left(\mathrm{exprs}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{SetProperty}\left(\mathrm{cmptab}\left[\mathrm{cat}\left("MathContainer",i\right)\right],\mathrm{expression},\left(\mathrm{eval}\left(\mathrm{exprs},1\right)\right)\left[i\right]\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$

 > 

Compatibility

 • The DocumentTools:-Components:-MathContainer command was introduced in Maple 2015.
 • For more information on Maple 2015 changes, see Updates in Maple 2015.
 • The fillcolor, width, minheight and minwidth options were introduced in Maple 2016.
 • For more information on Maple 2016 changes, see Updates in Maple 2016.
 • The DocumentTools:-Components:-MathContainer command was updated in Maple 2020.
 • The scrolldown option was introduced in Maple 2020.
 • For more information on Maple 2020 changes, see Updates in Maple 2020.