Skip to content Skip to navigation

Connexions

You are here: Home » Content » Presentation scripting elements

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

      A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

      What is in a lens?

      Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

      Who can create a lens?

      Any individual Connexions member, a community, or a respected organization.

    • External bookmarks
  • E-mail the author

Recently Viewed

This feature requires Javascript to be enabled.

Presentation scripting elements

Module by: Sunil Kumar Singh

Summary: Scripting requires changing baseline of scripting character(s).

Note: You are viewing an old version of this document. The latest version is available here.

Mathematical notation requires scripting around a base entity. The MathML provides scripting capability through scripting elements : msub, msup and msubsup. Scripting in MathML is not limited only to putting a subscript or superscript around an expression, but vertically integrated upper and lower scripts, which are handy to display limits on integrals and to meet such other requirements of rendering structured display.

Rendering of script is done by manipulating certain attributes that elements acquire from the environment such as “xml” or “html” document.

"msub" and "msup" elements "msub" and "msup" elements

Specific attributes :   superscriptshift, superscriptshift Specific attributes :   superscriptshift, superscriptshift

Attribute value types

  • superscriptshift, superscriptshift (default : automatic) : number v-unit

Each of these scripting elements takes two arguments base and subscript, which may be valid MathML expressions. Syntax of the two elements are as given here :



<msub> base subscript </msub>
<msup> base superscript </msup>

Each of these scripting elements takes two arguments base and subscript, which may be valid MathML expressions. Implementation of “msub” element shifts the baseline of the script, while retaining that of the base. In the case of “msup” element, the baseline shifts the script up. In both cases, display style of the scripts are also changed

The amount of shifting can be specified by giving numerical values to “subscriptshift” and “superscriptshift” attributes preferably in "ex" unit. The example here demonstrates implementation of both “msup” and “msub” elements.

Example 1: Subscript and supersubscipt


	    
    <m:math display="block">
     <m:table>
      <m:mtr>
       <m:mtd> 
        <m:msup>
        <m:mi> m </m:mi> 
        <m:mrow> 
          <m:mn> 1 </m:mn>
          <m:mo> &InvisibleComma; </m:mo> 
          <m:mn> 2 </m:mn> 
        </m:mrow> 
        </m:msup>
        </m:mtd>
        </m:mtr>
      <m:mtr>
      <m:mtd> 
        <m:msub subscriptshift="1.5ex"> 
        <m:mi> m </m:mi> 
        <m:mrow> 
          <m:mn> 1 </m:mn>
           <m:mo> &InvisibleComma; </m:mo> 
          <m:mn> 2 </m:mn> 
        </m:mrow> 
      </m:msub>
      </m:mtd>
       </m:mtr>
     </m:table>
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

m 1 2 m 1 2 m 1 2 m 1 2

Observe that “&InvisibleComma;” entity reference impart the meaning that scripts is read one two and not as one multiplied by 2.

"msubsup" element "msubsup" element

Specific attributes :   subscriptshift superscriptshift Specific attributes :   subscriptshift superscriptshift

Attribute value types

  • subscriptshift (default : automatic) : number v-unit
  • superscriptshift (default : automatic) : number v-unit

The element takes three arguments. First argument of the element is base; second argument is subscript; and third argument is superscript. The syntax of the element is :

<msubsup> base subscript superscript </msubsup>

Scripting “msubsup” element affects simultaneous implementation of a subscript and superscript, which are vertically aligned. This is an extremely useful scripting element as this element can be used to display limit values on variety of expression, including an integral sign.

The amount of shifting can be specified by giving numerical values to “subscriptshift” and “superscriptshift” attributes preferably in “ex” unit. The code below demonstrates assigning limiting values to integral with “msubsup” element, while “msup” element is used to construct exponential function.

Example 2: Definite integral limits


	    
    <m:math display="block">
<m:math display="block">
    <m:mrow> 
    <m:mi> y </m:mi>
     <m:mo> = </m:mo>
      <m:mrow> 
        <m:msubsup> 
          <m:mo> &int; </m:mo> 
          <m:mn> 0 </m:mn> 
          <m:mn> 1 </m:mn> 
        </m:msubsup> 
        <m:mrow> 
          <m:msup> 
            <m:mi> &ExponentialE; </m:mi> 
            <m:mi> x </m:mi> 
          </m:msup> 
          <m:mo> &InvisibleTimes; </m:mo> 
          <m:mrow> 
            <m:mo> &DifferentialD; </m:mo> 
            <m:mi> x </m:mi> 
          </m:mrow> 
        </m:mrow> 
      </m:mrow> 
      </m:mrow> 
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

y = 0 1 x x y = 0 1 x x

"munder" element "munder" element

Specific attributes :   accentunder Specific attributes :   accentunder

Attribute value types

  • accentunder (default : automatic) : true | false

The “munder” takes two arguments. First one is the base and second one is the scripting character. The syntax of the element is :

<munder> base underscript </munder>

The scripting character is placed below the base character/ expression. The “accentunder” attribute is either “true” or “false”, which determines whether the underscript is implemented as accent or limit. The implementation of accent is drawn closer to the base and is of the same size as that of base. On the other hand, limit is drawn relative away from the base and is reduced in size.

If under-script is an “mo” element, the value of its “accent” attribute is used as the default value of “accentunder”. However, an explicitly given value overrides the default.

Example 3: Underscripting


	    
    <m:math display="block">
<m:math display="block">
          <m:mrow> 
        <m:munder accentunder="true"> 
          <m:mrow> 
            <m:mi> x </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> y </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> z </m:mi> 
          </m:mrow> 
          <m:mo stretchy='true'> &OverBar; </m:mo> 
        </m:munder> 
        <m:mtext> &ThinSpace; vs &ThinSpace; 
        </m:mtext> 
        <m:munder accentunder="false"> 
          <m:mrow> 
            <m:mi> x </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> y </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> z </m:mi> 
          </m:mrow> 
          <m:mo stretchy='true'> &OverBar; </m:mo> 
        </m:munder> 
      </m:mrow>
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

x + y + z ¯   vs   x + y + z ¯ x + y + z ¯   vs   x + y + z ¯

"mover" element "mover" element

Specific attributes :   accent Specific attributes :   accent

Attribute value types

  • accent (default : automatic) : true | false

The “mover” takes two arguments. First one is the base and second one is the scripting character. The scripting character is placed below the base character/expression. The syntax of the element is :

<munder> base overscript </munder>

The “accent” attribute is either “true” or “false”, which determines whether the underscript is implemented as accent or limit. The implementation of accent is drawn closer to the base and is of the same size as that of base. On the other hand, limit is drawn relative away from the base and is reduced in size.

Example 4: Overscripting


	    
    <m:math display="block">
      <m:mrow> 
        <m:mover accent="true"> 
          <m:mi> x </m:mi> 
          <m:mo> &Hat; </m:mo> 
        </m:mover> 
        <m:mtext> &ensp;&ensp;vs&ensp;&ensp; </m:mtext> 
        <m:mover accent="false"> 
          <m:mi> x </m:mi> 
          <m:mo> &Hat; </m:mo> 
        </m:mover> 
      </m:mrow> 
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

x ̂   vs   x ̂ x ̂   vs   x ̂

If over-script is an “mo” element, the value of its “accent” attribute is used as the default value of “accent”. However, an explicitly given value overrides the default.

Example 5: Overscripting


	    
    <m:math display="block">
        <m:mrow> 
        <m:mover accent="true"> 
          <m:mrow> 
            <m:mi> x </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> y </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> z </m:mi> 
          </m:mrow> 
          <m:mo stretchy='true'> &OverBar; </m:mo> 
        </m:mover> 
        <m:mtext> &ThinSpace; vs &ThinSpace; 
        </m:mtext> 
        <m:mover accent="false"> 
          <m:mrow> 
            <m:mi> x </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> y </m:mi> 
            <m:mo> + </m:mo> 
            <m:mi> z </m:mi> 
          </m:mrow> 
          <m:mo stretchy='true'> &OverBar; </m:mo> 
        </m:mover> 
      </m:mrow>
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

x + y + z ¯   vs   x + y + z ¯ x + y + z ¯   vs   x + y + z ¯

"munderover" element "munderover" element

Specific attributes :   accent accentunder Specific attributes :   accent accentunder

Attribute value types

  • accent (default : automatic) : true | false
  • accentunder (default : automatic) : true | false

The “mover” takes three arguments. First one is the base and second and third ones are the under and over scripting characters respectively. The scripting character is placed below and above the base character/expression. The syntax of the element is :

<munderover> base underscript overscript </munderover>

This element allows simultaneous under and over scripting and is tailor-made constructor to render both scripts simultaneously. The scripting with this element suits in providing limit values to integral sign.

Example 6: Simultaneous under and over scripting


	    
    <m:math display="block">
  <m:munderover>
    <m:mo> &int; </m:mo>
    <m:mn> 0 </m:mn>
    <m:mi> &infin; </m:mi>
  </m:munderover>

    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

0 0

This element is not a necessity though, as the same can be implemented using “munder” and “mover” one after another. The reason of this equivalence is that implementing either “munder” or “mover” does not change horizontal width of the base, which is being scripted.

Example 7: Simultaneous under and over scripting


	    
    <m:math display="block">
  <m:mover>
    <m:munder>
      <m:mo> &int; </m:mo>
      <m:mn> 0 </m:mn>
    </m:munder>
    <m:mi> &infin; </m:mi>
  </m:mover>
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

0 0

"mmultiscripts" element "mmultiscripts" element

Specific attributes :   subscriptshift superscriptshift Specific attributes :   subscriptshift superscriptshift

Attribute value types

  • subscriptshift (default : automatic) : number v-unit
  • superscriptshift (default : automatic) : number v-unit

This element is same as “msubsup” element in that it renders vertically aligned pair of sub and super scripts, but with one enhancement that it can render multiple pairs such scripts. The syntax of the element is as given below :

<mmultiscripts> base (subscript superscript)* [ <mprescripts/> (presubscript presuperscript)* ] </mmultiscripts>

The multiple sign after pair of subscript and superscript indicates that the pair can be repeated. If it is required to render pair of scripts before the base, then the same is indicated by presence of an empty element “mprescripts” as shown in the syntax. An absence of this empty element will indicate that prescripts are not to be rendered. The pair prescripts are optional as such notation are rare in mathematics. A code for three pairs of the scripts are given in the example :

Example 8: Implementation of multiple script pairs


	    
    <m:math display="block">
    <m:mmultiscripts>
      <m:mi> A </m:mi>
      <m:mi> i </m:mi>
      <m:mi> j </m:mi>
      <m:mi> k </m:mi>
      <m:mi> l </m:mi>
      <m:mi> m </m:mi>
      <m:mi> n </m:mi>
   </m:mmultiscripts>
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

A i j k l m n A i j k l m n

It is evident that the implementation of “mmultiscripts” with one pair of scripts would be equivalent to implementation of “msubsup” implementation. An implementation that requires that one of the script in any pair is missing, we may provide either an empty element <none/> or empty “mi”.

Example 9: Implementation of multiple script pairs with missing value


	    
    <m:math display="block">
      <m:mmultiscripts>
       <m:mi> A </m:mi>
       <m:mi> i </m:mi>
       <m:mi> j </m:mi>
       <m:mi> k </m:mi>
       <m:mi> l </m:mi>
       <m:mi> </m:mi>
       <m:mfrac>
        <m:mi> x </m:mi>
        <m:mi> y </m:mi>
       </m:mfrac>
      <m:mprescripts/>
       <m:mi> a </m:mi>
       <m:mi> b </m:mi>
       <m:mi> c </m:mi>
       <m:mi> d </m:mi>
      </m:mmultiscripts>
    </m:math> 

	    
	  

Save the file after editing as “test.xml”. The display looks like :

A i j k l x y a b c d A i j k l x y a b c d

Comments, questions, feedback, criticisms?

Send feedback