Skip to content Skip to navigation

Connexions

You are here: Home » Content » Displaying mathematical content

Navigation

Recently Viewed

This feature requires Javascript to be enabled.

Displaying mathematical content

Module by: Sunil Kumar Singh. E-mail the author

User rating (How does the rating system work?)
Ratings

Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

How to rate a module

Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

:
(0 ratings)

Summary: The topmost element in mathML is "math" element.

Note: Your browser may not currently support MathML. See our browser support page for additional details. You can always view the correct math in the PDF version.

We need to display mathematics in different situations and in different ways. When we do not specify how to display the content, then “math” element simply displays the mathematical content starting from the left side of the browser. We can, however, specify display by providing values to the “display” attribute of math element. This attribute takes two values : "inline" and "block".

It must be emphasized that "math" element is the top level element and serves as the constructor for all MathML elements. A MathML mark ups without this top level element would result in implementation error.

Inline display

Let us consider the implementation of "math" element with its "display" attribute set to the value "inline". The starting tag of "math" element looks like <m:math display="inline"> :

Example 1: Inline display


	    
    <m:math display="inline">
           <m:mrow> 
              <m:mi mathvariant="bold">v</m:mi>
              <m:mo>=</m:mo> 
              <m:mfrac> 
                <m:mi mathvariant="bold">AB</m:mi>
                <m:mi>t</m:mi>
              </m:mfrac> 
          </m:mrow>
     </m:math> 

	    
	  

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

v = AB t v = AB t

Now, we edit the above file, making a single change. We specify the start tag of the "math" element as <m:math>. We find that the display of the content in the browser with the edit affected is same as when "display" attribute was given "inline" value. This is because, the attribute value “inline” is actually the default value of “math” element. However, this left hand display in the browser is not the main feature of "inline" specification. More importantly, "inline" attribute allows us to display the math content embedded right into the bulk of text. See the code below to display two subscripted variables (for the time being, do not bother to know the elements used). Just copy the code and paste the same in a new MS Word document and save as “test.xml”. The display in the MathML enabled browser is shown in the example here :

Example 2: Inline display


	    
<para id="para1"
The object is moving with two different speeds 
<m:math display="inline"> 
   <m:msubsup>
     <m:mi>v</m:mi>
     <m:mn>1</m:mn>
     <m:mrow/>
   </m:msubsup>
</m:math>  and 
<m:math display="inline">
    <m:msubsup>
      <m:mi>v</m:mi>
      <m:mn> 2</m:mn>
      <m:mrow/>
    </m:msubsup>
</m:math> in two equal time intervals. Find the average speed.
</para>
	    
	  

The display looks like :

The object is moving with two different speeds v1 v1 and v 2 v 2 in two equal time intervals. Find the average speed.

Block display

Normally, mathematical content is displayed separated from the body of text as a block. To facilitate this display, we need to provide "block" value to "display" attribute of the "math" element.

Example 3: Block display


	    
The velocity is mathematically expressed in terms of displacement and time as :   
<m:math display="block">
           <m:mrow> 
              <m:mi mathvariant="bold">v</m:mi>
              <m:mo>=</m:mo> 
              <m:mfrac> 
                <m:mi mathvariant="bold">AB</m:mi>
                <m:mi>t</m:mi>
              </m:mfrac> 
          </m:mrow>
     </m:math> 

	    
	  

Save the file after editing as “test.xml”. Note that the main body of the text is clearly separated from body of the text.

The velocity is mathematically expressed in terms of displacement and time as : v = AB t v = AB t

MathML elements

There are scores of elements in MathML. They are grouped under two broad headings :

  1. Presentation elements
  2. Content elements

Presentation elements describe visual represntation of mathematical notation or content in a two-dimensional plane. In other words, these elements emphasize the visual attributes like size, color, alignment and relative postions. The content elements, on the other hand, emphasize the mathematical “sense” of the expression. There are nearly 30 presentation elements and 50 attributes. Content elements are more in numbers - about 120, but they accept only about a dozen attributes.

Presentation elements

Presentation elements fall under following categories :

1: Token elements : These elements display data and text. We must know that the token elements are the only MathML elements permitted to contain character data. It is relevant to know that MathML character data set is Unicode characters, which are about 900 in numbers. In total, the token elements are seven (7) in numbers. The names and their basic role in rendering content are listed here :

Token elements

  • mi : renders identifires and symbols
  • mn : renders numbres
  • mo : renders mathematical opreators
  • mtext : renders text
  • mspace : creates space in both horizontal and vertical directions
  • ms : renders content for processing by other programs
  • mglymph : enables creating new characters

2: Layout elements : They serve as placeholders for text and data at different levels of display matrix or as mechnism to distribute mathematical content in two dimensional space. There are three broad categories of layout elements :

(i) Basic layout elements : They provide basic frame work for structuring mathematical expression in two dimensional space. The basic layout elements are ten (10) in numbers. The names and their basic role in rendering layout are listed here :

Basic layout elements

  1. “mrow” : makes horizontal groups of sub-expressions for variety of purposes
  2. mfrac : renders elements in PQPQ form
  3. msqrt : renders a square root
  4. mroot : renders a radical with an index
  5. mstyle : sets style attributes for the enclosed elements
  6. merror : enclose a syntax error message from a preprocessor
  7. mpadded : manages space around content by manipulating the size of box surrounding content
  8. mphantom : makes content invisible, while maintaining structure
  9. mfenced : surrounds its content with a pair of fences and segregates content's terms with separators
  10. menclose : enclose content with a stretching symbol

(ii) Scripting elments : They provide the mechanism to render sub and super script, under and over scipt and such other scripting lay out. , under proviides For example, msup and msub provide mechanism to script a base character with a pair of scripting characters such as v2 v2 and A1 A1 . The scripting lay out elements are seven (7) in numbers. The names and their basic role in rendering layout are listed here :

Basic layout elements

  1. msub : displays subscript
  2. msup : displays superscript
  3. msubsup : displays sub and super script simultaneously
  4. munder : displays under script
  5. mover : displays over script
  6. munderover : displays under and over script simultaneously
  7. mmultiscripts : displays multiple vertically sub and super scripts simultaneously

(iii) Table forming elements : They provide schemata for the formation of a table. They are six (6) in numbers :

Table elements

  1. mtable : creats table
  2. mlabeledtr : creats a labelled row
  3. mtr : creates a row
  4. mtd : creats a column
  5. maligngroup : Grouping element
  6. malignmark : creats alignment markings

Child elements and arguments

Most of the elements (other than empty elements in content MathML) enclose child elements. Some of the elements, however, require that certain numbers of child elements or blocks of child elements be present. In such cases, these conditional child elements or blocks of child elements are called arguments.

Consider the example. Here “msub” element requires a minimum of two child elements. The child elements “mo” and “mi” in this example are, therefore, called arguments.

Example 4: Arguments


	    
      <m:math display="block">
        <m:msub>
          <m:mi> A </m:mi>
          <m:mn> 1 </m:mn>
        </m:msub>
      </m:math> 
 	    
	  

Save the file after editing as “test1.xml” and see the display. The display looks like :

A 1 A 1

Consider another example given below. Here, “mfrac” element requires exactly two arguments. In case, there are more than two child elements, then “mrow” is to place child elements in two blocks as “mfrac” would take only two arguments –first block representing numerator and second block representing denominator of a ratio. The group of child elements enclosed within each pair of "mrow" tags consitutes one argument of the "mfrac" element.

Example 5: Child elements


	    
    <m:math display="block">
           <m:mrow> 
              <m:mi>v</m:mi>
              <m:mo>=</m:mo> 
              <m:mfrac> 
           <m:mrow> 
              <m:mi>a</m:mi>
	      <m:mo>+</m:mo>
              <m:mi>b</m:mi>
           </m:mrow> 
              <m:mi>c</m:mi>
              </m:mfrac> 
          </m:mrow>
     </m:math> 

	    
	  

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

v = a + b c v = a + b c

Creating table

We have chosen this advance topic right in the beginning with a purpose. Matter of fact, it is important to introduce this topic from the point of view of presenting display of example output in a well structured form. The basic purpose here is to acquire capability to distribute display of math content in different parts of the browser window – without taking recourse to “xml” elements. Hence, our purpose is not to know the details of creating various types of tables in mathML (we shall learn this topic in details later), but to know only elementary idea about creating table so that we get the capability to format the mathematical content display as per the requirement in hand.

For the reason cited as above, the creation of table, is limited to creating invisible table (without border) with rows and columns so that mathematical expressions are suitably placed on the matrix of the browser and is not rendered simply as a continuous line of display.

The top most table element "mtable" contains "mtr" (row) and "mtd" (column) elements. A general construct for 2 rows 2 columns is given here. It is not very difficult to infer from the code lay out that "mtr" element, following "mtable" element defines a single row, which in turn, are split in columns as defined by "mtd" elements.

Example 6: Codes for creating table


	    
<m:math display="block">
<m:mtable>
	<m:mtr>
		<m:mtd>
		....
		</m:mtd>
		<m:mtd>
		....
		</m:mtd>
	</m:mtr>
	<m:mtr>
		<m:mtd>
		....
		</m:mtd>
		<m:mtd>
		....
		</m:mtd>
	</m:mtr>
</m:mtable>
</m:math> 
 	    
	  

We can now use the table matrix to fill in with the mathematical content. A simple example is given below :

Example 7: Structured display


	    
      <m:math display="block">
    <m:mtable>
      <m:mtr>
	<m:mtd>
	  <m:mtext>The value of x is :</m:mtext>
	</m:mtd>
	<m:mtd>
	  <m:mn>10</m:mn>
	</m:mtd>
      </m:mtr>
      <m:mtr>
	<m:mtd>
	  <m:mtext>The value of y is :</m:mtext>
	</m:mtd>
	<m:mtd>
	  <m:mn>20</m:mn>
        </m:mtd>
	</m:mtr>
    </m:mtable>
      </m:math> 
 	    
	  

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

The value of x is : 10 The value of y is : 20 The value of x is : 10 The value of y is : 20

Grouping with mrow element

This topic is also a preparatory in the sense that we encounter this element now and then in any of coding effort we undertake. Its primary function within a parent element is to combine child elements enclosed between its tags as one unit for the parent element and align them horizontally. This grouping is important in order to meet the requirement of elements, which takes certain number of arguments.

The MathML coding frame work, however, is aware of the cluttering of codes due to repetitive use of this element. For this reason, "mrow" element is inferred even if not applied with certain elements. It is not necessary to remember the list of these elements capable to infer "mrow" as the same is implied logically. The elements, which require zero or one or exactly one argument, enforce child elements inside it to be clubbed together as one argument. For this reason, elements, requiring zero or one or exactly one argument, infer “mrow” even without explicit "mrow" tags. A square root element, for example, takes zero or one argument and as such implements “mrow” impicitly. Similar is the case with “mtd” element and other elements, requiring one argument. It must be understood that if there is only one child element, then there is no need to implement "mrow" for grouping either inexplicitly or explicitly.

Inferred “mrow” is a great help. Imagine if you were to write a pair of “mrow” tags for each of the “mtd” column tags for creating a simple table.

Content actions

Give Feedback:

E-mail the module author | Rate module ( How does the rating system work?)

Rating system

Ratings

Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

How to rate a module

Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

(0 ratings)

Download:

Add module to:

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 (?)

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.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks