The ‘mtable” element represents a table of rows and columns. It accepts only “mtr” or “mlabeldtr” elements as its child. Both of these define a single row in the table. The only difference between the two row elements is that “mlabeldtr” can be used to label the particular row defined by it. The “mtr” element represents a simple row. Each of these row forming elements takes child elements to define the columns.
The “mtable” element requires that all rows have same numbers of columns. If the columns in any row mismatches, then that row is padded with empty column(s). For example, when one column definition in the first row involving “y” is removed, then tables is rendered as shown below :
Example 1: Table short of one column
<m:math display="block">
<m:mtable frame="solid" columnlines="solid" rowlines="solid">
<m:mtr>
<m:mtd>
<m:mi>x</m:mi>
</m:mtd>
<m:mtd>
<m:mi>z</m:mi>
</m:mtd>
</m:mtr>
<m:mtr>
<m:mtd>
<m:mn>1</m:mn>
</m:mtd>
<m:mtd>
<m:mn>2</m:mn>
</m:mtd>
<m:mtd>
<m:mn>3</m:mn>
</m:mtd>
</m:mtr>
</m:mtable>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
Evidently, output is not what was intended. It is, therefore, always advisable to maintain same numbers of columns in each row. If there is no content, then that column should be kept as an empty column. Introducing the column definition back without any content restores the structure of table.
<m:mtd>
</m:mtd>
The out put now is :
Example 2: Table with same numbers of columns
<m:math display="block">
<m:mtable frame="solid" columnlines="solid" rowlines="solid">
<m:mtr>
<m:mtd>
<m:mi>x</m:mi>
</m:mtd>
<m:mtd>
</m:mtd>
<m:mtd>
<m:mi>z</m:mi>
</m:mtd>
</m:mtr>
<m:mtr>
<m:mtd>
<m:mn>1</m:mn>
</m:mtd>
<m:mtd>
<m:mn>2</m:mn>
</m:mtd>
<m:mtd>
<m:mn>3</m:mn>
</m:mtd>
</m:mtr>
</m:mtable>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
Displaying table
Attribute value types
- align (default : "axis") : (top | bottom | center | baseline | axis) [ rownumber ]
- rowalign (default : "baseline") : (top | bottom | center | baseline | axis)+
- columnalign (default : "center") : (left | center | right) +
- groupalign (default : "left") : group-alignment-list-list
- alignmentscope (default : "true") : (true | false) +
- columnwidth (default : "auto") : (auto | number h-unit | namedspace | fit) +
- width (default : "auto") : auto | number h-unit
- rowspacing (default : "1.0ex") : (number v-unit) +
- columnspacing (default : "0.8em") : (number h-unit | namedspace) +
- rowlines (default : "none") : (none | solid | dashed) +
- columnlines (default : "none") : (none | solid | dashed) +
- columnlines (default : "none") : none | solid | dashed
- frame (default : "none") : none | solid | dashed
- framespacing (default : 0.4em, 0.5ex) : (number h-unit | namedspace) (number v-unit | namedspace)
- equalrows (default : "false") : true | false
- equalcolumns (default : "false") : true | false
- displaystyle (default : "false") : true | false
- side (default : "right") : left | right | leftoverlap | rightoverlap
- minlabelspacing (default : "0.8em") : number h-unit | namedspace
The default setting for “frame”, “rowlines” and columnlines are “none”. For this reason, the rendering of a table with bare “mtable” results in a frame-less invisible table. Only content of the columns are displayed. A 2X3 table is drawn with default values in the example given here.
Example 3: Table with defualt values
<m:math display="block">
<m:mtable>
<m:mtr>
<m:mtd>
<m:mi>x</m:mi>
</m:mtd>
<m:mtd>
<m:mi>y</m:mi>
</m:mtd>
<m:mtd>
<m:mi>z</m:mi>
</m:mtd>
</m:mtr>
<m:mtr>
<m:mtd>
<m:mn>1</m:mn>
</m:mtd>
<m:mtd>
<m:mn>2</m:mn>
</m:mtd>
<m:mtd>
<m:mn>3</m:mn>
</m:mtd>
</m:mtr>
</m:mtable>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
The “mtable” element has large number of attributes and it would be difficult to use all of them. Good news is that we are using only few of them at the most. The dimensional attributes of table frame, rows and columns are largely determined by the implementation of a particular renderer. Also, the default values of key attributes are so chosen that default table architecture is suitable for most of the situations. For example, width controlling attributes “width” and “columnwidth” are set to “auto”. This means that width of the table as a whole and the columns shall be adjusted in accordance with the algorithm of the renderer, whereby they are expected to be set “as needed”. We may ofcourse set specific values whereby content in the table is expected to be wrapped around.
Assignment to table attributes follows a typical format. The reason for special mechanism arises out of the fact that we are required to set some the attributes on individual row or column. The format is simple. It is presented with a “+” sign at the end indicating that the attribute can be applied to individual rows and columns. A general format for columns would expand explained here :
(x y z)+ : It is a sequence of values separated by space. The values can be one or more (i.e. can be repeated) of x,y and z for corresponding columns. Starting from the first, the values are applied till the last column. If there are more values than required, then remaining would be discarded and if there are less than required then the last of the sequence would be repeated.
This means that a large number of attributes such as “rowalign”, “columnalign”, “columnwidth”, “rowspacing”, “columnspacing”, “rowlines” and “columnlines” can be set to individual rows and columns with the valid values as specified above.
The example here illustrates setting of “columnalign” and “rowalign” elements. Note that the impact of “columnalign” is more visible than “rowalign” element.
Example 4: Aligning content
<m:math display="block">
<m:mtable frame="solid" columnlines="solid" rowlines="solid"
rowalign="top baseline center" columnalign="right center left">
<m:mtr>
<m:mtd>
<m:mi>xyx</m:mi>
</m:mtd>
<m:mtd>
<m:mi>y</m:mi>
</m:mtd>
<m:mtd>
<m:mi>z</m:mi>
</m:mtd>
</m:mtr>
<m:mtr>
<m:mtd>
<m:mn>12</m:mn>
</m:mtd>
<m:mtd>
<m:mn>2</m:mn>
</m:mtd>
<m:mtd>
<m:mn>3111</m:mn>
</m:mtd>
</m:mtr>
</m:mtable>
</m:math>
Save the file after editing as “test.xml”. The display looks like :









"This is a great primer on MathML."