MathML - Matrices


Advertisements

<mtable> tag is used to draw matrices.

Syntax

mtable is similar to table tag of HTML and this tag uses mtr, mtd elements which are similar to tr and td tags of HTML.

<mtable> <mtr> <mtd></mtd></mtr></mfrac>

Attributes

Here is the description of all the attributes of this tag −

  • align − To specify the vertical alignment of the table . Valid values are: axis, baseline, bottom, center, top. Default is axis.

  • class, id, style − Used with stylesheets.

  • columnalign − To specify the horizontal alignment of the cells. Valid values are: left, center and right. Default is center.

  • columnlines − To specify column borders. Valid values are: none, solid and dashed. Default is none.

  • columnspacing − To specify the space between table columns.

  • displaystyle − If true more vertical space is used for displayed equations , if false, a more compact layout is used to display formulas.

  • frame − To specify borders of the entire table. Valid values are: none, solid and dashed. Default is none.

  • framespacing − To specify additional space added between the table and frame.

  • href − To specify a hyperlink to a specified uri.

  • mathbackground − To specify the background color. Valid formats are #rgb, #rrggbb and html color names.

  • mathcolor − To specify the text color. Valid formats are #rgb, #rrggbb and html color names.

  • rowalign − To specify vertical alignment of the cells. Valid values are axis, baseline, bottom, center and top. Default is baseline

  • rowlines − To specify row borders. Valid values are: none, solid and dashed. Default is none.

  • width − To specify width of the entire table.

Example

Let's draw a 3 x 3 metric.

<math xmlns = "http://www.w3.org/1998/Math/MathML">
   <mrow>
      <mo>[</mo>
      <mtable>
         <mtr>
            <mtd><mn>1</mn></mtd>
            <mtd><mn>0</mn></mtd>
            <mtd><mn>0</mn></mtd>
         </mtr>
         
         <mtr>
            <mtd><mn>0</mn></mtd>
            <mtd><mn>1</mn></mtd>
            <mtd><mn>0</mn></mtd>
         </mtr>
         
         <mtr>
            <mtd><mn>0</mn></mtd>
            <mtd><mn>0</mn></mtd>
            <mtd><mn>1</mn></mtd>
         </mtr>
      </mtable>
      <mo>]</mo>
   </mrow>
</math> 

Output

[ 1 0 0 0 1 0 0 0 1 ]
Advertisements